5 ms·
Oh, I understand it at that level. I did a compilers course in Scheme with Kent Dybvig; I know how continuations are implemented (the whole "there is no single
by Vivtek 17y ago
Oh, I understand it at that level. I did a compilers course in Scheme with Kent Dybvig; I know how continuations are implemented (the whole "there is no single stack" thing) but my programming mind, the not-really-verbal part that actually does the coding, just doesn't grok them.
Just like closures; I knew more or less what they were - but this January I ran into my first situation where I really, truly saw how they made a particular situation easier - like, easier in a way that nothing else did - and since then I can't live without closures. That insight suddenly reorganized everything I thought I knew about programming.
I'm still waiting for that to happen with continuations.
- pg 17y agoIt may never happen. You might never need to use raw continuations when writing user applications. They'd be something you more often used through some library that depended on them. E.g. I never explicitly use continuations in HN.
- silentbicycle 17y agoIn other words, continuations provide necessary infrastructure for adding various constructs to a language, but they're sufficiently general that you're unlikely to use them directly. Also, the first edition of _Essentials of Programming Languages_ has a great chapter on turning an interpreter into a compiler using continuations (Chapter 12). I hear it got cut from later editions, though.
- Vivtek 17y agoYeah, hence my ten-year estimate. Sooner or later I'll end up designing my own language for fun; continuations will probably click then. (Actually, I'm already designing my own language for fun, but it compiles to Perl, so continuations are still not really on the table.)
- gruseom 17y agoWell tell us about your closure epiphany. I want to know the details!
- Vivtek 17y agoIt wasn't really all that exciting - I was writing an IRC bot for fun, a Roberts Rules of Order moderator. Well, Roberts Rules of Order imposes a structure on events that requires timing, so for instance, if somebody gets the floor, then one minute or two minutes later, we warn them their time is expiring. The epiphany was twofold. First, I realized that passing an anonymous function pointer to a queue is a lot more general than defining, say, a bunch of event names. This makes the design of the event queue really lightweight. The second part of the epiphany was that anonymous function pointers in Perl are closures, with lexical bindings to the environment at the time the pointer is created. So my event queue reduced to a simple list of times and closures - magic! Events are entirely general and you can spin off just the event queue logic as a separate module without restricting any later options about what types of event you'll be queuing. It was probably the most satisfying programming I'd done in a decade. I should note that I stopped doing programming for my bread and butter in 2003 or 2004, and switched to technical translation instead (easy to quote, no debugging, no disputes about what was done or whether it met the user's expectations - it's like programming for hire without any of the downsides!) So I program for fun and to build my own tools, with the result that a month or two may go by without my writing much of anything. That's lots of time for the subconscious to reorganize between exposures, so essentially I'm relearning programming a couple of times a year. Lately I think I'm getting kind of good at it.