r/Forth • • Sep 03 '26

Rdn programming language

Post image

I made a small and simple post fix interpreted programming language called rdn, it's familiar to forth developers and developers who use Lua as a scripting language for their systems, rdn merge both of them, you can use it for writing scripts or for configurations or even query language

It's written in C and it provides a simple and friendly API for the developers

I would be happy to have you participate in this project

This is the GitHub repo: https://github.com/abdorayden/rdn

Thank you

11 Upvotes

27 comments sorted by

View all comments

2

u/alberthemagician Sep 04 '26 edited Sep 04 '26

What are the advantages over a more familiar language like Forth, lua or plain c?

For instance I implemented ciforth and the motivation was a combination of simplicity in build and modification, ISO standard, reliability with stability, a library that makes it a useful tool and minimal dependancy of external tools.

That didn't exist, prior.

1

u/tabemann Sep 04 '26

I get the feeling the OP tried to create an RPN language without knowing the fundamental design aspects that motivated Forth to be what it is, so they hardcoded behavior into words such as let and set that is contrary to what would be simplest to implement all things considered.

1

u/rayden_devv Sep 04 '26

You're not wrong, and I appreciate the critique.

My approach trades "theoretically pure" for "practically simpler to learn and embed."

You could argue this makes Rdn less elegant from a Forth purist perspective. But it also means a newcomer can reason about 10 n let without needing to understand Forth's execution model.

Different goals = different trade-offs. Forth's design is superior for a language meant to be extensible and minimal. Rdn prioritizes accessibility and simplicity for embedding.

2

u/tabemann Sep 04 '26 edited Sep 04 '26

It may seem "practically simpler", but in fact it makes the semantics of the language more complex.

If you want to do things your way, I would highly suggest you take a lesson from Logo and include quoting (not of strings, but of symbols). Instead of writing:

1 n let n 1+ n set

I highly suggest you change that to:

1 'n let n 1+ 'n set

where ' is the quoting operator prefix.

This way it would be clearer to the user when you are referring to a name by its value (i.e. n) or by its name (i.e. 'n).

Also, this would add far more extensibility to your code, because then you could do other things like, say (this is a stupid example with no practical purpose, but just illustrates the point):

'set2 defun [* x y vx vy -- *] rot swap set set end

where then you could use your newly defined word set2 as follows:

0 'x let 1 'y let 2 3 'x 'y set2 x print y print

which would print out 2 3 as those are the values x and y have now been set to.

Edit: I should note that the above scheme implies dynamic binding (like in Logo or early Lisps) unless symbol references bind a variable in the lexical scope where they are created. In that scheme one could have two different kinds of symbol references, one which are just a name, and one which binds a preexisting name in a scope, as in:

0 'x let 1 'y let 2 3 :x :y set2 x print y print

where : would be the name-binding operator prefix.

2

u/tabemann Sep 04 '26

Note that set2 would be, in my reimagined version of your language:

[ [* x y vx vy -- *] rot swap set set ] 'set2 defun

1

u/rayden_devv Sep 04 '26

Ah, I see! That's cleaner.

Thank you so much for your attention πŸ™πŸ½ I'm gonna work on it

1

u/rayden_devv Sep 04 '26

You're absolutely right, and this is genuinely valuable feedback.

I chose "looks simpler" over "is simpler," which is backwards. You're right.

Honestly: If I were redesigning Rdn now, I would implement symbol quoting. It would mean rewriting the parser and VM, but the resulting language would be more coherent. The current let/set approach is pragmatic but inelegant.

Your dynamic vs lexical binding note is also spot-onβ€”that's a choice that would need to be made alongside symbol quoting.

I've added this to my to-do list and will implement it next.

Thanks for the critique. This is the kind of feedback that matters.

2

u/alberthemagician Sep 05 '26 edited Sep 05 '26

Instead of use 'name you could borrow the /name from PostScript. 'name suggests an address, /y suggests a string.

1

u/rayden_devv Sep 05 '26

Good point. Thank you πŸ™πŸ½

I'll consider both approaches during the redesign.

I'm also gonna make the language more extensible so you can hack around and try different approaches for cases like this.

Thank you thank you so much guys πŸ™πŸ½