Follow

Check out the amazing little mascot that @rek designed for the Uxn VM.

· · Web · 5 · 5 · 34

@neauoire @rek y'all are making me want to go write my little VM-driven lang i've been thinking about for a few years now <3

@neauoire @rek totally. i studied parsing/lexing for Advent Of Code 2020 so it should be a little easier to come back to now

was thinking about tuplespace-oriented programming. back in school, i learned about the use of Linda as a synchronization primitive (with a data payload!), and thought a little later about how you could tie that idea into some sort of a micro-Erlang. Like...

("add1", x, y) -> ("catadd", x+y)
("add2", x, y) -> ("catadd", x+y)
("catadd", x) ("catadd", y) -> ("IO", [str x] ++ [str y])

...with inputs placed into the tuplespace:
("add1", 1), ("add1", 2), ("add2", 3), ("add2", 4)

...would indeterminately output either "36" or "63"

@nfd @rek I've considered doing a lisp like but never really nailed the parsing of parens depth stuff.. Forth was more realistic with my current skills.

@neauoire @rek oh, you ever checked out parser combinator libraries (e.g. markkarpov.com/tutorial/megapa)? i learned a bunch of stuff in 2020 but software-wise this might've been the best

@nfd @rek yeah but I don't wanna use anything I'm not building.. I have this curse you see huh..

@neauoire @rek NIH Syndrome, we call it :D

Some functional programming courses actually cover how to implement your own parser combinator libraries--and in fact, once you've got the basic connections to the data structures all together, these sorts of libraries can actually be made of highly generic components. Pedagogically, it probably is a pretty solid choice for a first sizable FP project, especially in a language at least like Haskell. might be worth revisiting if y'all ever poke around in that world

@neauoire @nfd @rek i hate parsing but i wrote an Ometa/2 parser.

for a lisp reader you just have a stack. when you encounter '(' you push a new empty list to the stack and then read symbols, hashes and strings one at a time and append to the list. when you read ')' you pop the stack and append the list to the list underneath.

the usual special cases are quotes and quasiquote. '( is alwas read as though it was (quote and `( is read as (quasiquote. when you read a comma before something like ,foo then that is read as (unquote foo).

strictly speaking you do not need to implement quoting just to read s-expressions. they are part of the macro processing facilities though and they are nicer than typing out the quote/quasi/unquote forms.

congratulations you parsed lisp.

@icedquinn @nfd @rek Oh I'm familiar with the process. I've implemented a few lisps before in javascript, namely Ronin.

wiki.xxiivv.com/site/ronin.htm

My fear is more that I wouldn't be a good job of it in C at this time/

@nfd @rek anways, I hope you take the time to try implementing this. It's a ton of fun.

@neauoire @rek what is the motivation for implementing the tools (and required toolchain for development and debugging, docs and maintenance to avoid bitrot etc) on top of something like this over say, a sdl based c backbone and lua (or if you're feeling ultra tiny, rxi's fe)?

I feel like some of the resilience goal is lost by the whole toolchain becoming more esoteric; it may be a different kind of philosophical win though.

@neauoire @rek love the mascot and more interesting vms are always welcome, just wondering if its shifting the goalposts a little to plan to port all the tools to this thing

@maxc @rek the tools are already written in C+SDL, their codebase is very small, but a lot of the code is deduplicated for each one.

The emulator will be pretty rigid and contain all the helpers, The assembler/emulator will both remain in C+SDL, but I'm planning on making one for Plan 9 as well, and one for the the browser too.

The roms of the apps will be working everywhere. They will be tiny too. It's a way of doing cross platform.

@neauoire @rek would the same cross platform and deduplication goal not be true of refactoring out the common parts to a c library which was portable to Linux, plan9, and webasm though?

@maxc @rek I could port SDL2 to libdraw, to canvas, to.. but ouff. I'm not game.

@neauoire it already has a webasm port, I think as part of emscripten? I think resource management is a bit of a pain but it's super widely used so it can't be too bad. No idea about plan9 portability though

@maxc I don't want to get anywhere near emscripten, cross-compiling my tools with em is a terrible awful process that I will not try again.

@neauoire 👍 totally fair, but what's the approach for porting the c backend/vm otherwise? Separate implementation entirely in js or just the glue code to canvas/webgl and audio, and then some non-em webasm? Separate again for the plan9 drawing/audio libs?

It all just seems like a very long process with a lot of stuff to maintain, and a vm on top of that!

But, if that's the plan that's fine and commendable - just a surprising lot of work for a deliberately minimal toolkit.

@maxc the emulator/vm is very simple(400 lines of C atm), that i will make the equivalent in plan9, and a little js canvas emulator. It's not that much work so far, maybe there's some complexity that I'm not seeing down the line. I'm working on something like a PPU at the moment for this.

Sign in to participate in the conversation
Merveilles

Merveilles is a community project aimed at the establishment of new ways of speaking, seeing and organizing information — A culture that seeks augmentation through the arts of engineering and design. A warm welcome to any like-minded people who feel these ideals resonate with them.