Tags: leostera/lam
Tags
Embeddable Scheduler, Emulator fixes, DOM FFIs, and more! First of all thanks to @kvakvs for helping me debug emulator fixes. In particular my misunderstanding of the behavior of `call*` instructions in the BEAM bytecode made for some very wonky bugs. I owe you a beer! 🍻 Changelog Examples: More examples: fib, a fib dumper that times a pure JS, a JS in web worker, and an Erlang implementation, fixes to the empty and grep examples as well. Yes, this is Erlang code manipulating the DOM. Compiler: * Fixed bug in CodeTable where we were ignoring 4 bytes before the beginning of the instruction section * Fixed bug in Compact Term Encoding where 10000 would be picked up as a small value and thus the rest of the instructions would be nonsense Emulator: * Introduce Opaque References * Registers are now ensured to have a fixed size (although this may change) * Coordinator run loop has been split into a setup and a run function that can be used to _step_ the coordination process * Scheduler now implements a Stepper that can be used to execute a number of iterations over the computation -- this makes the emulator embeddable into larger event loops, such as the DOMs request animation frame loop * Schedulers and the Coordinator now can communicate more cleanly * Pids can now know whether they are the main Pid or not * Runtime trait now requires a function for yielding control so the loops aren't starving the CPU Runtime: Native * Secondary Schedulers are spawned on a separate thread to let the Main Scheduler begin work ASAP * Schedulers can communicate with the Coordinator via an unbound channel between the threads -- this right now allows for halting the system, but is the basis to build process stealing and inter-scheduler message routing Runtime: Web * Implement opaque Refs for DOM Element * Add (NIFs) native interfaces for : * `document.getElementById(name)` * `document.createElement(tag)` * `element.appendChild(element)` * `element.innerText = text` * Expose a `step` function to run a configurable number of iterations over the LAM program that can be used to hook into the Request Animation Frame loop. This way we get 60fps rendering _and_ WebAssembly speeds. --- Changes across the board! But it's letting me explore a few interesting things: * yes, we can build web apps with Erlang / Elixir ✔️ * we need to find a nice way of defining custom NIFs * Enjoy it and let me know what works, what breaks, and cool things you want to build with LAM! 🚀 / Leandro