3 ms·
My brother just finished writing a forth like interpreter for a freshman CS project (in java, not Bash, thankfully). It is a really nice language for learning t
by sudobash1 5y ago
My brother just finished writing a forth like interpreter for a freshman CS project (in java, not Bash, thankfully). It is a really nice language for learning the basics of an interpreter without worrying about the parser side too much.
- shadowofneptune 5y agoNow that I think about it, the grammar is entirely regular, yes?
- Someone 5y agoI’m not sure Forth has a grammar in the traditional sense. I think any grammar needs to cover immediate words because you cannot ignore CREATE… DOES>. Those can do anything, so how do you handle them? There’s also BASE (the current number conversion radix). It makes parsing integers context-dependent.
- codr7 5y agoIt's just a stream of tokens, which are either literals or identifiers; it's the only language I know that has less syntax than Lisp.
- vitiral 5y agoAnd "tokens" are literally "any string of non whitespace characters." One of it's biggest downfalls imo is that the toeknizer is too simple. I'm making GitHub.com/civboot/fngi as a "better than forth".
- codr7 5y agoOh, I've been down that rabbit hole for a long, long time :) It makes a nice foundation for syntactic experiments. https://github.com/codr7/gfoo https://github.com/codr7/gfoo https://github.com/codr7/forthy2 https://github.com/codr7/forthy2
- zengargoyle 5y agoForth is a really nice language for learning raw machine code then adding an assembler then moving up to a HLL in a few printed pages of code. The ultimate macro assembler. Back in 1986 teenage me found this library book that described Forth as "a ball of mud" which later made sense. A small core of machine specific bits form the core, you have to make that by hand. Then you accumulate and write an assembler on top of that. Then there's the I/O and logistics of the system. Then there's the whole interpreter/compiler all the same. It's the ultimate bootstrap. From laying down bytes in memory to a hybrid interpreter/compiler that you can say "take this word and make it a thing" and it can fart out this little polished turd. Forth is a ball of mud that you start at the beginning and at the end you end up with a shiny turd of a https://en.wikipedia.org/wiki/Dorodango https://en.wikipedia.org/wiki/Dorodango. Forth is bottom up insted of top down. The concepts teaching/learning wise start at the bottom and lead up to the top. You can't learn that starting with Python or Fortran or C or BASIC, or even Assembler. Bottom up. Forth might not be the best Pascal/Basic/Python learning some stuff language, but Forth is the best bits in memory to HLL "full-stack" language. I wish your brother had done it on raw hardware instead of in Java. It is a really nice language for learning.