💾 Archived View for gemlog.blue › users › sloum › 1598592551.gmi captured on 2022-04-29 at 12:51:55. Gemini links have been rewritten to link to archived content
⬅️ Previous capture (2020-09-24)
-=-=-=-=-=-=-
As many around the smallnet know, I tend to avoid the web (outside of work... where I do horrible things for money and hate myself a little more each day for it). However, I recently thought it would be fun to check out web assembly. By fun I mostly mean 'something to do at night after my wife goes to sleep'.
I had recently abandoned a project in which I was writing an interpreter for a forth-like language (forth-like in syntax at least). Strings defeated me. Oh man are strings a pain in the ass. Dealing with strings and the memory associated with them sucks. Be that as it may, I thought maybe the project would be fun to port over to wasm and have a web frontend so that friends could easily play around with the interpreter. Which is what I have done.
The end goal is to combine my little interpreted language with the concept of a previous image processing dsl I created awhile back called filtress. Where nimf works on a stack and a heap, filtress had just a few registers and was really limited in what it could do. I thought it would be fun to have a wasm specific nimf word for loading an image (via your browser) and having a bunch of supporting words to handle image manipulation. Since you can write new words in nimf you could achieve quite complex image mutations that involve loops and conditions and all sorts of fun stuff. The idea is that the image you see in your browser would get updated any time there was a change to image data (at most once per line of command entry, which could be multiple commands). You could then save the modified image locally, as well as the script you wrote to modify it.
I have not gotten to all that yet (it seems getting the image data over from js to go may prove tricky, but definitely doable and I have someone else's code to check out for that part). For the moment it is a basic proof of concept interpreter (it sadly lacks the ability to query the user for input at the moment - coming soon?).
Anyway, if you are interested:
Nimf language documentation (WWW)
Easy Forth - Learning material (WWW)
Getting it to work via wasm was not too difficult. There is a good bit of extra boilerplate and an unstable syscall/js api... but things mostly worked (a lot articles on the web use outdated api versions it seems). It worked great locally and then there was a bit of a hiccup getting it to work on an actual server: apache did not know the mimetype and refused to serve the file. Adding `application/wasm wasm` to `etc/mime.types` and restarting the server did the job. Right now I expose a function to the js and have the js call it whenever text is sent via the input field. I could do it all from go and avoid the js module entirely, but it seemed like more of a pain.
Anyway, that is enough js and web stuff for awhile. Back to my book (still reading Dhalgren). Have a good evening geminispace!