by 6d65 · 5y ago · 0 comments
I've watched a couple of episodes and went started my own. I learned a bit of arm64 assembly, and now I have both an interpreter and a compiler to M1 binaries. Very fun experience.
One day I'll slap a F#/OCaml'esque syntax on top of it with typed functions, structs, interfaces and see if it works.
At their core(it seems to me), concatenative languages are about function (words) composition.
So, instead if having "words", I would make them functions, with typed arguments, and simple argument matching (no more dups and swaps). This would probably make the language less flexible, but will make it more readable.
Anyway, FORTH is nice.
Which is not a bad thing. Go nuts. Just realize that there may be some degree of prior art for what you're doing.
I was planning to investigate this space just for fun. Most likely nothing will come out if it and that's ok, it's just a learning opportunity.
Interesting idea. Wouldn't it require some compiler magic, though? E.g. you can't type a Y combinator.
What I mean is that FORTH words seem to be functions taking stuff from stack and pushing stuff back. The composition is done by chaining them together.
This probably works fine with repl driven development(same as in lisp), you find out during development that your words cannot be composed. But as mentioned by others it may make the code hard to read, having to keep the state id the stack at all times in your head.
I was thinking just adding a light syntax, ex:
let add a b = a b +
// optional type annotation
let square a = a a *
let add-square = add square
Maybe add some type inference, support for structs, match expressions. But at the core keep the low level FORTH nature, with an interpreter and compiler.
It remains to be seen if it's possible to reach a balance here. FP programmers may be disappointed this is not a proper FP language, while FORTH programers may say it's a syntax ridden abomination.
I would say with some tooling (editor support, test framework, god forbid package manager), it can be an interesting option for embedded development.
: add {: a b :} a b + ;