Scalæ By the Bay has ended
Back To Schedule
Sunday, November 13 • 11:40am - 12:20pm
Don’t Blow Your Stack: Recursive Functions for Beginners in Scala

Sign up or log in to save this to your schedule, view media, leave feedback and see who's attending!

Recursion is a fundamental building block of algorithmic design and a corner stone of many functional data structures. The Scala compiler has direct support for tail recursion and indirect support for mutually recursive function calls with a compiler plugin. So what makes a function recursive and what shape must it have to allow for tail call elimination? For that matter, what is tail call elimination? What does it mean to be mutually recursive? How does all this get translated into working, non-stack blowing code at compilation time? In this beginner-friendly look at all things recursion we’ll show how to take an imperative function and transform it into a recursive function. Through live code examples, attendees will see how to keep code referentially transparent without the need for external mutable variables while correctly handling state between “loops." Finally, we’ll introduce a new compiler plugin that adds mutual tail recursion and demonstrate how it can simplify complex, twisted logic.

avatar for Owein Reese

Owein Reese

A hands on manager who continues to write code at work and in his spare time. His group is distributed across the country and he loves being able to work and hire anyone from anywhere. At MediaMath, they are responsible for globally deployed systems capable of handling peak traffic... Read More →

Sunday November 13, 2016 11:40am - 12:20pm PST