💾 Archived View for gemlog.blue › users › sloum › 1595221160.gmi captured on 2024-08-18 at 20:51:43. Gemini links have been rewritten to link to archived content
⬅️ Previous capture (2020-09-24)
-=-=-=-=-=-=-
I have had a stressful and busy weekend, but have managed to work on a few projects:
A while back I wrote a line based text editor for my pubnix's shell. It is called chalk. It is written in python3. Some users/friends on rawtext.club encouraged me to work on a code walkthrough. So I started on that. It will be ~9 chapters that walks through every line of code in a sensible order with testable results for each chapter. I am hoping it will encourage people to write simple tools that they can actually use and not just have as toys. I do most of my gopher phlogging using chalk and it has been great for that purpose. I'm three chapters in currently, but imagine it will likely be another week or two before I finish it. Once it is done I will be posting it either here or my rawtext.club gemini capsule.
I do not know the Forth programming language, at least not very well. I had read about it and it sounded interesting, but was maybe beyond me a few years back. Now though, it is pretty cool. Rather than just learn the language I decided to have extra fun by implementing a forth style interpreter in golang (I thought about C, but decided to start in golang and maybe scoot it over to C if I actually like the result). Really, it is a toy project... but it is teaching me a lot about stack based programming.
Currently I have a working REPL with a bunch of builtin commands. Aside from in conjunction with some commands (giving names to functions and constants) it only supports integers currently. That said, it does fully support creation of new 'words' (think functions or maybe macros). My next two steps are branching and loops. Then file i/o and includes.
It is not exactly a true forth implementation, but it does use a stack as its main data structure and a map/hash/associative-array/whatever for storing new words and builtin words. It has been pretty fun to figure out. Particularly since I dont know how to program in forth. I am reading through this pretty cool document:
and implementing each section in my interpreter as I go. I imagine as the complexity ramps up I will need to do some major redesigns of some things, but I think my evaluation loop is pretty solid so far... so hopefully it will do ok. I am dreading getting strings and characters working... but I am a few chapters away from that so I have time. It would be fun to eventually be able to make something non-trivial with my own interpreter. In theory if I work out the code generation side of things I could likely transpile to golang and produce binaries using the go compiler, but I'll be happy to have a decent interpreter.
Alright, time to get if/else/then working. Have a good night!