3 ms·
The only thing anyone ever seems to do with forths is write another forth. Why is this? Unrelatedly (perhaps) I tried writing some basic software in forth and
by bowsamic 5y ago
The only thing anyone ever seems to do with forths is write another forth. Why is this?
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
- orthoxerox 5y agoBecause forth is an exercise in minimalism, its answer to most features is YAGNI. The coolest thing about it is how easy something as weird as forth maps to the quite different different underlying (register-based) hardware, so you can use a forth to bootstrap something with more sugar.
- zozbot234 5y ago> Unrelatedly (perhaps) I tried writing some basic software in forth and it was pretty horrific. 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.
- Gordonjcp 5y agoPossibly a variable-length array wasn't a good fit for the problem you were trying to solve.
- bowsamic 4y agoA variable length array is a basic building block of programming. A huge number of programs will use one
- Gordonjcp 4y agoA concrete slab is a basic building block of a pavement, but it's not particularly useful or appropriate for a wristwatch. 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.
- bowsamic 4y agoHow would you go about allowing the user to enter and store data at runtime without knowing the size of the data in advance then? I don’t agree with you at all. A variable amount of data that can change at runtime is universal across all programs. This isn’t something specific to a certain coding style
- fmakunbound 5y agoIf you’ve seen one Forth, you’ve seen one Forth.
- adastra22 5y agoIt is the community that surrounds forth, and the type of hobbyists that are attracted to forth, as well as what they are attracted to. 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.
- bowsamic 4y ago> Part of the appeal of forth is making your own forth environment. That is the whole answer I think. Then what? Or is that the whole hobby?
- adastra22 4y agoWell there's an active community of people writing their own operating systems. Why do that when Linux is available? I don't think a further reason is required for the hobbyist. 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 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.
- mostlylurks 5y agoIt is not the only thing, but rather the first thing that people often write. There is nothing particularly wrong with that, as forth is the kind of language where intimate knowledge of its internals is quite useful, perhaps even necessary, while simultaneously being easy to obtain (e.g. by writing your own forth). And of course, the number of people who complete one project is necessarily greater than or equal to the number of people who do more than one project. 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.
- quazar 5y agoAbsolutely not true. Sometimes you implement a lisp in it and from there whatever you want, but usually the next step is some OS.
- astrobe_ 4y agoI've made a Forth dialect and uses it for somewhat specific stuff. I have a program that works for me 24/7 and that I have tweaked and adapted to the evolution of my needs for a decade. 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.
- jonjacky 4y agoHere is some interesting Forth software, including a Space Invaders game and an IP networking stack including IP, ARP, UDP, DNS and DHCP [1]. It runs on the J1 custom Forth CPU built on an FPGA [2]. The author says it was originally designed to run an array of Ethernet cameras on a robot. 1. https://www.excamera.com/files/j1demo/docforth/ https://www.excamera.com/files/j1demo/docforth/ 2. https://www.excamera.com/sphinx/fpga-j1.html https://www.excamera.com/sphinx/fpga-j1.html Edit - also mentioned here by adastra22, I see.