3 ms·
As someone who has written a forth, and knows a tiny sliver of what lisp can do, the huge difference is that Forth can't deal with arbitrary data structures in
by mikewarot 5y ago
As someone who has written a forth, and knows a tiny sliver of what lisp can do, the huge difference is that Forth can't deal with arbitrary data structures in anything close to the ease of Lisp. If you want to ingest a chunk of source code, tokenize, parse and put it all in an abstract syntax tree, you're far better off doing it in lisp.
Forth doesn't really do data structures. Stoical is a forth variant that did, but it died out.
- 7thaccount 5y agoThere are a lot of Lisps out there, but even more Forths (like the one you've written), although people like to argue what it means to be a Forth. One desktop/server Forth that I have enjoyed is 8th and it is a Forth in the since that it is a concatenative language using words and a stack, but it also is like GForth in that it comes with garbage collection, while it also has support for various data structures like arrays/maps/JSON/matrix, file IO, GUI, database, cross compilation...etc. It still takes my brain awhile to use, but my workflow is pretty similar to the one I use with Python.
- mostlylurks 5y ago>Forth doesn't really do data structures It doesn't hand you a ready-made solution due to its extreme minimalism, but that doesn't mean that you can't have arbitrary data structures (and have them be quite ergonomic). All it takes is a handful of lines (each) to have words for defining C-like structs, sum types, separate stacks for distinct datatypes, RAII, even generics. You only need to implement these things once, afterwards you can simply reuse that solution. To expect the language, standard library, or popular frameworks to provide all the abstractions one will ever need is unfortunately a very common attitude these days. In general, but particularly in the case of forth, it is very beneficial to understand that you are allowed to make your own abstractions. Nothing is forcing you to stay on the lowest levels of abstraction, where you only directly utilize tools the language has given you. In fact, such an approach is quite antithetical to writing forth.
- andrewflnr 5y agoThere's a very good reason for this "common attitude", and it is network effects with their benefits for productivity. If the standard library includes a useful abstraction, then your code and my code that use that abstraction have an easier time interoperating, and so does the entire rest of the world. That's really handy.