Come see my proglang-from-scratch any% run!
I've somehow managed to implement a toy programming language in the few spare hours I could find last week (plus one stress-filled Sunday). Tonight I'll try to repeat doing it from scratch in 20 minutes at lodis, so that everyone can see how amazing concatenative programming languages are!
(Hopefully it will be entertaining if I fail too đ )
https://dukop.dk/en/event/6472/
#malmö #catlangs
#concatenative
Andy Alderwick
in reply to Job • • •I was hoping to catch this on Jitsi but got called away
There wouldn't happen to be a recording of your livecoding, by any chance?
Devine Lu Linvega
in reply to Andy Alderwick • • •https://www.youtube.com/watch?v=cUmPHmeg2DU
cat-22: a one-week concatenative programming language
YouTubeJob
in reply to Devine Lu Linvega • • •@neauoire @alderwick
And as they say in cooking shows: "here is a version of the language that I prepared earlier"
https://blindedcyclops.neocities.org/cat22/cat22
(mind you, it's still full of typos and probably bugs too, and the interface is currently very weird)
I will probably keep tinkering with the language, despite starting it mainly as a personal challenge, because it turned out to be too much fun to play with!
A catlang in 20 minutes
blindedcyclops.neocities.orgAndy Alderwick
in reply to Job • • •@neauoire Oh thank you so much for the links!
I love the â[something] ?heads; tails;â representation of branching!
In early Uxn development we had a conditional flag â?â, but we could only apply it to primitives. It saw a lot of use with what was our RETURN and JUMP opcodes, but it was hard to see the use of something like âADD?â or âMUL?â since the stack depth might have changed but execution carried on in the same place.
So it's really nice to see it work well!
Job
in reply to Andy Alderwick • • •@alderwick @neauoire Well, honestly, cat-22 also mainly uses it in the equivalent of JUMP and RETURN instructions - it's just that the wide opcodes make jumps implicit (any value larger than built-in primitive opcode is a jump address), and the use of an encoded return flag removes the separate opcode for it.
> it was hard to see the use of something like âADD?â or âMUL?â
Wouldn't that have been the equivalent of a single-instruction jump though? Or was the conditional flag non-consuming?
Andy Alderwick
in reply to Job • • •@neauoire This is much more like assembly than FORTH, so with the conditional flag it would either execute the opcode or not. After a âMUL?â instruction we would have the following stack changes:
2 7 1 â 14
2 7 0 â 2 7
I analysed our assembly code and â[address] [true/false] JUMP? POPâ came up everywhere, because we didn't need the jump address after an unsuccessful test and it wasn't automatically popped. So we switched to a new opcode for conditional jump and repurposed the flag.
Job
in reply to Andy Alderwick • • •@alderwick @neauoire aaaah, I forgot that uxn uses the *the stack* to determine the address to jump to! That was the missing bit of context. Yes, I see your point now.
I assume that consuming the address regardless of true/false condition introduced other issues?
Devine Lu Linvega
in reply to Job • • •Andy Alderwick
in reply to Job • • •@neauoire Ah cool, glad I filled in that gap!
We did play around with automatically removing arguments. âJUMPâ takes only one and we know we won't need it, so âJUMP?â was easy.
âMUL?â could have been fun, we know âMULâ reduces the stack by one, so âMUL?â could discard just one of the arguments to keep it balanced:
2 7 1 â 14
2 7 0 â 2
but by the time we consider âDUP?â we were struggling to define what the semantics should be. Other uses for that flag were more attractive đ
Job
in reply to Andy Alderwick • • •@alderwick @neauoire Ah, yeah that looks messy.
Also, I'm pretty sure that I saw a presentation recently by someone (Anton Ertl maybe?) lamenting that ?DUP makes Forth almost impossible to statically type check, so that's more proof that you probably made the right call there.
Devine Lu Linvega
in reply to Job • • •https://git.sr.ht/~rabbits/uxnbal
~rabbits/uxnbal - Uxntal validator, written in Tal - sourcehut git
git.sr.ht