Unrelatedly (perhaps) I tried writing some basic software in forth and it was pretty horrific. Even something as simple as representing a variable length array feels like fighting the language
Unrelatedly (perhaps) I tried writing some basic software in forth and it was pretty horrific. Even something as simple as representing a variable length array feels like fighting the language
It would be a PITA to strip it from its business-related stuff in order to publish it, so you will probably never see it online. I guess it's the same for other "serious" users.
> Unrelatedly (perhaps) I tried writing some basic software in forth and it was pretty horrific. Even something as simple as representing a variable length array feels like fighting the language
Yeah, don't fight the language, that's the key. And don't do stuff because that's what every other language is doing. "Solve the problem you've got!" Moore said. It could seem dead obvious, but it's actually difficult to prevent yourself from trying to solve problems you think you will have tomorrow, or from solving problems others have.
More specifically don't try to avoid using Forth variables because they are global and you've been taught that globals are absolute evil madness that eat kitties for breakfast. Instead, pick perhaps a couple of values that travel everywhere, causing "stack juggling" in your program, and make them global variables. Maybe hide those global variables behind regular words if you really really really intend to reuse parts of that program.
But really, solve the problem you have now. This also means you should make programs that will actually be useful for you. It can be difficult because this generally involves complicated stuff like connecting to a web server or GUI. Just be pragmatic and use native libraries (or whatever you can find that looks decent, gets the job done, and can be used by the Forth system you're using) to deal with the complicated crap others have been doing for decades. Forth hates complexity, any cheat is fair game.
It’s a bit like saying the only thing anyone ever seems to do with Common Lisp is to make macros which redefine the syntax of language. How frustrating! We’ll if they didn’t want to make use of macros, why were they using lisp in the first place?
Part of the appeal of forth is making your own forth environment. That is the whole answer I think.
Edit: notably there are applications of forth which don’t involve reinventing the wheel, like Postscript and Bitcoin Script. In these domains devs aren’t so likely to engage in this activity.
Then what? Or is that the whole hobby?
But there are various actual products which result from efforts to create a minimal forth that are interesting. One of my favorites is the J1 CPU: https://www.excamera.com/sphinx/fpga-j1.html
Also I think many of these personal forths have explored interesting areas of programming language design, and when I have read about those which have been made public I often learn something new. It's like code poetry.
It might be instructive to compare FORTH to e.g. the previously discussed language K, which is similarly terse in some ways. It turns out that a few convenience features - including first-class- and higher-order- functions, neither of which really sit well within the FORTH stack-focused model - can make a real difference.
The last thing that causes the phenomenon you describe to happen is likely the culture around forth, likely as a result of the relative ease and utility of making domain-specific abstractions compared to general abstractions in forth. The community seems to not appreciate libraries and reusable code to the same extent as other ecosystems, preferring instead to share ideas, which each developer can then adapt to fit their particular project in a very minimalist manner instead of adopting some convoluted general solution.
1. https://www.excamera.com/files/j1demo/docforth/
2. https://www.excamera.com/sphinx/fpga-j1.html
Edit - also mentioned here by adastra22, I see.
I think there's a gap between what you're trying to solve and what you think you're trying to solve, and that's giving a massive impedance mismatch between what you're trying to do and how you're trying to do it.