Tag: Scheme
A Dynamic Forth Compiler for WebAssembly
In yet another ‘probably-useless-but-interesting’ hobby project, I wrote a Forth compiler and interpreter targeting WebAssembly. It’s written entirely in WebAssembly, and comes with a compiler that dynamically emits WebAssembly code on the fly. The entire system (including 80% of all core words) fits into a 10k (5k gzipped) WebAssembly module. You can try it out here, or grab the code from GitHub.
What follows are some notes on the design, and some initial crude speed benchmarks.
More Fun with Monad Do-notation in Scheme
In a previous post, I played around with monad do-notation in Scheme (well, Racket) to have a nicer syntax to play with asynchronous callbacks. This do-notation is actually quite fun to use with other monads as well. What’s interesting is that the same notation gets entirely different meanings and forms depending on which monad you use it with.
There are many interesting monads, and this post shows only a couple of simple ones in action in Scheme (for which you can find the code here).
Flattening Callback Chains with Monad Do-Notation
A few unrelated topics on my reading list made me want to randomly experiment with a few things. I wanted to understand monads a bit better, see how they applied to callback-based asynchronous programming, and play around with macro programming in a Lisp dialect. This is a partial log of the theoretical-and-probably-not-directly-applicable-but-nevertheless-fun rabbit hole I dived into.
The Callback Pyramid Problem JavaScript (and especially Node.js) uses lots of asynchronous APIs. These are implemented by adding an extra callback parameter to asynchronous methods, where the callback parameter is a function that receives the result of the call when it’s finished.