!!Con 2019- Tail Call Optimization: The Musical!! by Anjana Vakil & Natalia Margolis
Confreaks Confreaks
42.1K subscribers
93,589 views
0

 Published On Jun 3, 2019

!!Con 2019- Tail Call Optimization: The Musical!! by Anjana Vakil & Natalia Margolis

“Stack overflow”! “Maximum call stack size exceeded”!! “Too much recursion”!!!

You may have seen errors like these thrown when you attempt to run a deeply recursive function. Computers can be so dramatic! But what’s the conflict, exactly, between recursion and call stacks? And is there any hope for resolving it into a happy ending? In this musical talk we’ll see why recursion poses a problem for the finite-memory call stack in our language runtime (we’ll use a JavaScript engine as an example), and learn how “Tail Call Optimization” (TCO) - a particularly cool implementation feature of some engines - lets us get around that problem, when paired with so-called “tail-recursive” functions. We’ll sing our way through the meaning of these terms to explore how TCO messes with the call stack (in a useful way!), as we mess with the lyrics to some of our favorite animated musical songs (in a nerdy way!).

show more

Share/Embed