12 ms·
Tail Call Optimization: The Musical (2019) [video]
- progre 6y agoThis is wonderful, big props to the girl with the less trained singing voice for going through with it.
- bjoli 6y agoI am a good singer (as in: I have done it for a paying audience of about 1000 and gotten away with it). That was in a format where singing was expected, and with an audience primed to whatever I was doing. I was nervous, since I am not used to singing like that (I am a professional bassoon player, working full time in a symphony orchestra). The risk of me bombing was rather small. This thing is different in just about every way. Would I stand up and sing in a tech conference? Not without vomiting before going on stage (not sure whether that is an exaggeration for comic effect). It requires more than just a little chutzpah.
- amelius 6y agoYeah, from a mental perspective it's probably closer to stand-up comedy than a singing performance. Also you've got to enjoy it because otherwise, what's the point.
- mourner 6y agoOne of my favorite tech presentations ever! So much uplifting enthusiasm, witty and whimsical humour and good taste in the songs, love it. Really happy that it belatedly got on the HN frontpage — it really deserves more views. Go Anjana & Natalia!
- scribu 6y agoEh... To me it seems just as cringe as Steve Balmer shouting "Developers Developers Developers".
- adkadskhj 6y agoYea, i applaud them for having fun with this and making content they and many others can enjoy. But it's not for me. I think my "cringe" comes from a form of empathy where i envision myself there doing the same thing, and i am _not_ confident enough to do this lol. I loathe public speaking, i freeze up and nearly faint (seriously). So i can't even come close to watching these types of presentations and enjoy them. Nothing to do with the presenters, everything to do with me. But i'm glad they had fun and that people enjoy it :)
- blacktriangle 6y agoAnd yet here we are decades later still talking about that rant. And it was true too, say what you will about MS, their commitment to supporting their developers is unmatched.
- payelsarkar28 6y agoFollow
- jpetitcolas 6y agoOne of the funniest and clearest explanation I've ever seen! That's a must-see talk for all JS developers! Congrats Anjana and Natalia! :)
- saagarjha 6y agoCute! Major props to the two for the execution :) Sadly, these days Safari is the only engine that does TCO. It also keep track of a decent number of frames (currently 128). For more details on the implementation (called Shadow Chicken), see https://webkit.org/blog/6240/ecmascript-6-proper-tail-calls-in-webkit/ https://webkit.org/blog/6240/ecmascript-6-proper-tail-calls-....
- sitkack 6y agoTail calls are coming to Wasm. Aside, calling tail calls TCO makes it sound like it is just an optimization, which it is not. Tail calls enable beautiful control flow inside of state machines. It is a new fundamental capability and not an optimization.
- cben 6y agoIt makes a big difference when a language spec (such as Scheme) requires it. If only some implementations have it, and you can't assume it when coding, then it's "just an optimization". https://en.wikipedia.org/wiki/Tail_call#By_language https://en.wikipedia.org/wiki/Tail_call#By_language has a list.
- wffurr 6y agoSome backstory on the "disastrous meeting" that led to the abandonment of TCO by every browser vendor other than Safari here: https://stackoverflow.com/questions/54719548/tail-call-optimization-implementation-in-javascript-engines https://stackoverflow.com/questions/54719548/tail-call-optim...
- leoc 6y agoI see Broadway is reviving a '70s production again. ;) TCO is about the same vintage as Chicago.
- deleted 6y ago[deleted]
- YesThatTom2 6y agoHow did I miss this in 2019? It is so excellent!
- vasergen 6y agoI didn't know that nodejs supports TCO under the flag (like on video), but unfortunately it was only for versions from 6 to 8. Curious why did they removed it
- qsort 6y agoIn a practical working environment it creates more problems than it solves. It's an optimization that effectively turns non-working code into working code, in ways that aren't always obvious or predictable and possibly in different ways across different compilers/interpreters. I'd rather the code blow up in my face immediately than spend time wondering why it gets optimized on engine X and not on engine Y, or why seemingly trivial code changes cause the function to have drastically different runtime behavior. Clojure did this right. No TCO, loop/recur construct instead. As a side note at the cost of being snarky, it's also probably a good thing that developers who get overexcited about recursion are being encouraged to use proper functional idioms instead of abusing it.
- swiley 6y agoI feel like tail calls are pretty obvious, the c++ grammar even explicitly calls them out.
- rbanffy 6y agoThis is a magic vs. no-magic thing. TCO is a magical thing that implicitly changes the behavior of code with the same syntax. The code says the stack should blow up, but the compiler saves you from it. I'll side with the Python teaching that explicit is better than implicit. If the code says the stack will blow, then the compiler/runtime should not try to avoid that.
- yvdriess 6y agoThere's nothing magical about a language that says that a tail-call will reuse the same frame/record/instance. It's only magical and unreliable when it's not in the language spec.
- phplovesong 6y agoshared sense of shame
- booleanbetrayal 6y agoThat was awesome. I imagine a huge amount of time was spent in putting that together, and it was well worth it. Who knew TCO could be so approachable?
- linkdd 6y agoYep Tail Call "Optimization" is nice. But what about recursive functions that cannot be tail call "optimized"? First example that comes to mind is the Tower of Hanoi algorithm: def toh(ndisk, source, via, target): if ndisk > 0: toh(ndisk - 1, source, target, via) target.append(source.pop()) toh(ndisk - 1, via, source, target) The function calls itself 2 times. Same thing is the fibonacci function which relies on the 2 previous results. Here, you'll certainly need memoization and other techniques to not blow up the stack.