Hacker News new | ask | show | jobs
by j1elo 825 days ago
Oh boy, this reminds me of the good (not-so-)old times! Some years ago I was writing embedded C for Atmel AVR32 chips, and needed them to do several things "at the same time".

Started from learning about Protothreads (cooperative concurrency) as described by Adam Dunkels [1], and ended up devising a Task manager/runner library with a main loop, so multiple protothreads could be scheduled easily. At any given point in time, any of the scheduled tasks could be running or yielding on some continuation point.

There's some beauty in grasping these concepts from the ground up. Some time later I had to learn JavaScript, and the concept of async/await clicked so fast and nicely in my mind. Saving distances, the core idea is fundamentally the same, and that was enlightening (and fun!)

[1]: https://dunkels.com/adam/pt/