My Matryoshka dolls

7 views
Skip to first unread message

The Beez

unread,
Apr 17, 2026, 9:12:51 AM (12 days ago) Apr 17
to 4tH-compiler
Hi 4tH-ers!

I always wanted to make my own language. The idea of seeing a program run under a compiler or interpreter I'd written all by myself seemed fascinating (and it was!)

Now, there wasn't much information on how to do that - and the stuff I got made it look incredibly complex. Until I wrote an RPN calculator in C. And that started 4tH. Yes, I still had NO idea of how to do it, I just winged it. And it worked. It was still just an RPN calculator with flow control, but it was the start.

Then followed uBasic/4tH - and that slowly grew into a capable language as well. And then I watched https://www.youtube.com/watch?v=A3gTw1ZkeK0 - and I thought: "Python? Really? Yuk!" - and rewrote the whole darn thing in uBasic/4tH.

So in essence, I wrote a language in a language I wrote, which was written in a language I wrote.

Now - OLL (that's the name) came with a "Disclaimer":

Disclaimer

The language (Our Little Language (.oll)) is by far not a complete language, and the interpreter only expects perfectly written code. Don't use this for production purposes, and only use it for the educational purpose of learning about creating and interpreting programming languages. The Instruction in Our Little Language (.oll) are: 

PUSH, POP, ADD, SUB, PRINT, READ, JUMP.EQ.0, JUMP.GT.0

I thought that was a little thin. So I expanded a few and added a few other. It was still a lame language, but a little bit more viable.

Still, it's rare to find a program over half a kB. Because every single jump requires careful planning. It feels like writing assembly code. But every now and then you find something suited for this thing, like the Collatz conjecture.

It's simple: even means division by two, uneven means multiplication by three and add one. Every single number collapses to the 4 -2 - 1 sequence, and then we're done.

You'll find the program here: https://sourceforge.net/p/forth-4th/code/1751/

Now you may know that .OLL can be transpiled to uBasic/4tH. Which I did. I also found out that the uBasic/4tH transpiled program is 3.5 times faster than the OLL VM. I didn't know that. But it's nice to know!

Hans Bezemer
Reply all
Reply to author
Forward
0 new messages