Skip to main content


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

in reply to Job

I was hoping to catch this on Jitsi but got called away :flan_piteous:

There wouldn't happen to be a recording of your livecoding, by any chance? :flan_cheer:

in reply to Andy Alderwick

YES 😁
https://www.youtube.com/watch?v=cUmPHmeg2DU
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!

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!

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?

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.

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?

in reply to Job

that bit is kind of a pain to handle in the type checker, because the stack can be in either one of two states after this.
This entry was edited (3 weeks ago)
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 😊

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.

in reply to Job

Oh, I should have kept on reading before answering haha. Yeah, this sort of stuff is a pain to deal with during the arity checking.
https://git.sr.ht/~rabbits/uxnbal
This entry was edited (3 weeks ago)

Lo, thar be cookies on this site to keep track of your login. By clicking 'okay', you are CONSENTING to this.

⇧