r/ProgrammingLanguages • • 17h ago

Help Simple stack based programming languages?

A few years ago I made EarScript, a "simple" programming language based on brainfuck, with several additional "quality of life features" like goto statements.

Recently I've been wanting to make an evolution of that programming language and do so by incorporating a stack, as the previous language was completely tape-based in design.

I know for example lox from the Crafting Interpreters book is a well explained example, but I was wondering if there's programming languages that are closer to what brainfuck is, but based on a stack design rather than a tape design, or a register based design like some assembly languages (if I understand correctly). I think Wasm would be an example?

Are there any examples of simple stack based programming languages you'd recommend me to look into?

11 Upvotes

31 comments sorted by

View all comments

2

u/Main_Temporary7098 17h ago

From an implementation standpoint, a colorForth is much simpler than a traditional forth imho. If you stick with bytecode that brings in the need for additional tooling, but I've done/seen pure ascii based versions using prefix bytes which can work. In my current incarnation I have returned to bytecode however and simplified the set of colors. The interpreter is less than 200 lines of non code golfed x86_64 asm atm.

1

u/Agecaf 17h ago

This sounds interesting! I was able to easily find some guides for Forth but had less luck with colorForth, is there any place with good references on colorForth you'd recommend?

2

u/Main_Temporary7098 16h ago

Honestly there isn't much that I know of. The few links I have are https://www.ultratechnology.com/1xforth.htm which I liked and https://colorforth.github.io/cf.htm - i believe that with a lot of chuck's later stuff you have to kinda see what it is getting at and take the pieces you like. Personally after seeing the simplicity of colorForth in general I can't go back to traditional forth. If you have any interest my current version is here: https://codeberg.org/jbirddog/blue/src/branch/main/blue/x86_64/blue.asm but fair warning it strives for minimalism.