6 ms·
Chuck Moore always says he did not invent FORTH, but discovered it. It's fascinating the relationship between Lisp and Forth. I am quite sure there is somethin
by yiyus 8y ago
Chuck Moore always says he did not invent FORTH, but discovered it.
It's fascinating the relationship between Lisp and Forth. I am quite sure there is something about these two old simple languages and the concept of duality in mathematics that we are missing.
- garmaine 8y agoYou're not the only one to observe this. It was observed and explored by Manfred von Thun with Joy, a purely functional programming language based on Forth. Modern "concatenative" languages continue this tradition: https://en.wikipedia.org/wiki/Concatenative_programming_language https://en.wikipedia.org/wiki/Concatenative_programming_lang...
- carapace 8y agoI've been working with Joy for a few years now and I have to say that it seems to me to combine the best parts of Forth and Lisp. It's ridiculously elegant.
- garmaine 8y agoDo you have a link to whatever project you are working on? I'm interested in Joy but not aware of anyone working on or with it in recent decades.
- carapace 8y agoSure! I developed an interpreter for Joy in Continuation-Passing Style in Python: http://joypy.osdn.io/ http://joypy.osdn.io/ I had just implemented type inference[1] when I got smashed over the brain by Prolog. So now the Python code is in limbo because the Prolog implementation of Joy is blindingly elegant[2]. In Prolog, the Joy interpreter is also the Joy type inferencer.[2] The compiler (from Joy expressions to new Prolog rules) is five lines long.[2] [1] http://joypy.osdn.io/notebooks/Types.html http://joypy.osdn.io/notebooks/Types.html [2] https://osdn.net/projects/joypy/scm/hg/Joypy/blobs/tip/thun/thun.pl https://osdn.net/projects/joypy/scm/hg/Joypy/blobs/tip/thun/...
- garmaine 8y agoThanks! Yes, there's a real connection between concatinative languages and logic languages. In some sense you can think of a concatinative logic language as Joy with the ability to push "unknown" values onto the stack, as well as a few constraint manipulatives. That's somewhat orthogonal, but it makes sense an interpreter for Joy would be quite compact in prolog. Thanks for the links, I'll review your work later!
- carapace 8y agoCheers! You might also like: http://conal.net/papers/compiling-to-categories/ http://conal.net/papers/compiling-to-categories/ He transforms Haskell to a point-free form that's suspiciously like Joy... ;-)
- thaumasiotes 8y ago> It's fascinating the relationship between Lisp and Forth. Is there more to the relationship than "Lisp is written as a preorder tree, and Forth is written as a postorder tree"?
- astrobe_ 8y agoShort answer: no. Longer answer: actually another common feature is that both can execute code at compile-time (macros). Full answer: really, no. They are fundamentally different: Lisp is a decent symbolic language, Forth is a decent portable assembler.
- HelloNurse 8y agoReally, no. They are fundamentally identical executable lambda calculus, despite Lisp's attempts to look abstract by shrouding itself in parentheses and Forth's attempts to look like "portable assembler" by exposing most implementation details.
- samatman 8y agoThere is an ancestral relationship. Chuck Moore studied under McCarthy directly.
- MycroftJones 8y agoYep. And back in the 1970's Chuck Moore wrote a book describing the implementation and design of FORTH, and it is pretty close to LISP. And I asked Chuck Moore directly, in person, if there was a connection to LISP, and he said "yes".
- yiyus 8y agoThey are both very different, technically, but culturally they are very similar. Both of them are extremely simple and build complex programs from a few fundamental principles. Both of them are disengaged from the more mainstream languages. Both of them broaden your perspectives as a programmer. Both of them have excellent books that were written a long time ago but are still relevant today. Both of them gave rise to specialized hardware (stack computers and Lisp machines). Both of them encourage you to write your own interpreter when you are learning them... Although both languages are very different, learning one or the other actually is a quite similar experience.
- knowingpark 8y agoStarting Forth by Leo Brodie is a classic book. Forth is a very elegant language. I came across a javascript implementation of it recently, which you can look up yourself :)
- baldfat 8y agoAs a kid I went from basic to assembly. When I was shown Forth by my dad's friend I was totally caught up in Forth on my C64. I later tried Pascal which is also great but it wasn't close to forth in my mind. It was awesome Except you had to pay for the language and I am guessing that is why it died. Currently my preferred language is Racket because it is so fun and practical, reminds me of the earlier days of Python but much more thought out. You write you code (which is fun) and you have an executable all within one setting.
- peteri 8y agoArmed with that and a copy of Threaded Interpretive Languages by Loeliger (How I found out about the book is beyond me) from the library I managed to put together a complete(ish) Forth for the Apple ][ running ProDOS. I think the magic bit with Forth is that it's easy to see how to write one by the time you've finished Starting Forth.
- 3rdAccount 8y agoIs it though? Man, maybe I'm dumb :) I wish there was an easy checklist: Create stack data structure, create return stack, create primitives ...etc.
- knowingpark 8y agohttps://factorcode.org/ https://factorcode.org/
- 3rdAccount 8y agoWhat does Factor have to do with my question? Yes it's a concatenative language that is still maintained although Slava left. I'm guessing it wouldn't make a great example if you're suggesting going through source.
- RodgerTheGreat 8y agoWhen I read SICP, I worked through the exercises in Forth. I had to implement my own garbage collector, create dialect extensions for nice list notation, build a thunk-based mechanism for closure... with the right groundwork laid, Forth can keep up pretty well. I was always somewhat dissatisfied that cute metacircular lisp interpreters leave as tautologies so many important details of their own mechanics.
- deleted 8y ago[deleted]
- yvdriess 8y agoIt functions as a good way to whet the appetite of the reader or student. SICP's meta-circular implementation occupies a kind of sweet spot, it imparts to students that only just grokked recursion to understand how the programming language itself is just a program they can understand and tinker with. The state machine implementation of the Scheme interpreter sort of breaks the meta-circularity to dismantle the tautologies.
- 3rdAccount 8y agoHow did you learn how to write your own Forth? Brodie shows how to just think in and use one already written right?
- Tomte 8y agoJones Forth is an extremely readable tutorial how to write a Forth.
- 3rdAccount 8y agoI've gone through it before, but it has been ages. Maybe I'll check again...thanks.