I’ve been dissecting Forth Haiku code (Brad Nelson’s https://forthsalon.appspot.com).
I was hoping to find a simple way to get at GPUs, without having to take a deep dive through lots of hoary explanations of tangled code and having to reverse-engineer a mental model of how this stuff works.
I’m not done yet, but, this video is a snapshot of what I’ve figured out thus far, along with some spin-offs.
pipeline
I cleaved Nelson’s code into stand-alone pieces, most of them running on the command line
only one piece - a rendering slave - needs to run in the browser, getting commands from a command-line daemon that creates a websocket to the renderer and keeps the websocket open and acts as the tail-end of the code-generation pipeline
I’m surprised at how snappy the response is
this suggests the beginnings of REPLs for the 21st century - we don’t need to build REPLs into languages, but, maybe we just need to tune languages for use in small pieces for use in a command-line based REPL
2-stage compilation
I’m very impressed with this simple technique, I think that this programming pearl should be in every programmer’s toolbelt
I have long believed that staged computation is a useful technique for simplifying problems, and was looking for simple, practical examples - this code forms a good example on the road to thinking about Parts Based Programming
2 lines of special purpose code (Forth-ish code) generates 118 lines of Javascript that can be converted to a similar amount of GLSL - easily
this strengthens my feelings against over-using GPLs (general purpose programming languages) and strengthens my argument for building small, special purpose SCNs (lightweight DSLs) for zeroing in on solving real problems in small pieces using multiple notations
this gives me the same “feeling” I got when I first saw one line of SmallC code generate many lines of 8080 assembler code - it’s a tool that helps create low level code to control hardware
I began thinking about cellular automata (e.g. Game of Life) and discovered that this needs more than what Forth Haiku provides
I suspect that additions to the pipeline / renderer to support cellular automata are not out of reach (especially with Claude to help)
I think that cellular automata should be interesting, because I suspect that this “new media” called “computers” can alleviate the need for some of the hoary math needed to explore certain concepts - we might be able to visualize certain concepts instead of staring at equations
Miscellaneous References
code repo “as is”
smallc (not required viewing for this article)
See Also
Email: ptcomputingsimplicity@gmail.com
Substack: paultarvydas.substack.com
Videos: https://www.youtube.com/@programmingsimplicity2980
Discord: https://discord.gg/65YZUh6Jpq
Leanpub: [WIP] https://leanpub.com/u/paul-tarvydas
Twitter: @paul_tarvydas
Bluesky: @paultarvydas.bsky.social
Mastodon: @paultarvydas
(earlier) Blog: guitarvydas.github.io
References: https://guitarvydas.github.io/2024/01/06/References.html









