4 ms·
I haven't written a Forth, but have read a lot about it. Essentially you start out writing some assembly definitions as named routines and once those are defin
by 4thaccount 8y ago
I haven't written a Forth, but have read a lot about it.
Essentially you start out writing some assembly definitions as named routines and once those are defined you start using that. Forth doesn't have a compiler in the traditional sense. Rather it has a dictionary with stored definitions that you either run from or add to. Besides that, your main data structure is the stack. So your code reads from the stack, does some calculation, returns data to the stack, and calls the next word. This can be very powerful as the implementor can truly understand the entire language. Who can say that about C, Python...etc? With that being said, the whole thing is super Spartan, so unless you implemented a feature, it isn't there. So although Forth is cool, the scientific work I do with matrices would require me to rewrite all of that in my Forth, so it would be a non-starter. Forth really shines for hardware work in my opinion.
Look at JonesForth as an intro to building your own Forth, and Leo Brodie's books on how to use Forth. Every Forth system written probably shares the same core design, but they are all different and as unique as snowflakes. Look at 8th as an example of a very affordable commercial Forth based language written by one man that can cross compile to Windows, Linux, BSD, Mac, Android, & iPhone , has a built-in GUI, encrypted binaries, is pretty speedy and well supported with a small but happy user base. It is an interesting point that there are few languages with that level of features and stability that are not made from the work of lots of people.