5 ms·
I regularly see Forth related material appear on HN. I love a lot of the concepts that get brought up in these article’s comments, particularly those that discu
by throwaway17_17 4y ago
I regularly see Forth related material appear on HN. I love a lot of the concepts that get brought up in these article’s comments, particularly those that discuss the often small and personalized implementations of Forth that appear ubiquitous among those interested in Forth. However there doesn’t seem to be anyone who considers it a viable language for actual programming and a large portion of that seems to come from the personal implementations coupled with the proliferation of custom DSL’s that are reputed to spring up in any Forth program.
As a person working on a programming language design that is a little forth-like in presentation (it’s not stack-based), is it just the anecdotal experience of Forth that leads to the seeming incompatibility with producing complex software? Or does this seem to be inherent in Forth’s minimal syntax design (similar discussions also happen in Lisp discussions)?
- csande17 4y agoI haven't done much with Forth, so take this with a grain of salt. Most corporate software development uses languages like Java, C#, Ruby, and Python that are all very similar to one another. Sure, some of them use different punctuation, but the basic tools you use to solve problems all involve putting pretty much the same words in pretty much the same order. It's easy for someone with one language to quickly pick up another. Forth's syntax immediately pushes it into the "weird languages" category because almost all of the words are in a different order. "1 + 1" is now "1 1 +". That sets it far enough apart from Python/Ruby/Java/etc that a tech company isn't going to use it unless they feel really strongly about it. (AFAIK there isn't any big corporate push for Forth like there is for Go and Rust and stuff.) The main audience for Forth is therefore hobbyists. I think the main reason why you see lots of handmade Forth implementations is because Forth is really easy to implement. It's a fun hobby project. And because Forth is simple, its community biases towards people who like writing simple software. If you want to write complex software in a weird language, you'll probably gravitate towards a complex language like Haskell or something.
- shagie 4y agoThat 1 1 + isn't too different (to me) from (+ 1 1) which has a different sort of beauty to it. Incidentally, the oldest surviving language on a unix system uses this syntax (and predates C): https://en.wikipedia.org/wiki/Dc_(computer_program) https://en.wikipedia.org/wiki/Dc_(computer_program) http://webarchive.loc.gov/all/20100506231949/http://cm.bell-labs.com/cm/cs/who/dmr/hist.html http://webarchive.loc.gov/all/20100506231949/http://cm.bell-... > When the PDP-11 arrived, B was moved to it almost immediately. In fact, a version of the multi-precision `desk calculator' program dc was one of the earliest programs to run on the PDP-11, well before the disk arrived. However, B did not take over instantly. Only passing thought was given to rewriting the operating system in B rather than assembler, and the same was true of most of the utilities. Even the assembler was rewritten in assembler. This approach was taken mainly because of the slowness of the interpretive code. Of smaller but still real importance was the mismatch of the word-oriented B language with the byte-addressed PDP-11. The main advantage of Forth is that it can be put in some very small places and run impressively fast. http://www.ultratechnology.com/chips.htm http://www.ultratechnology.com/chips.htm https://en.wikichip.org/wiki/novix/nc4016 https://en.wikichip.org/wiki/novix/nc4016 > NC4016 (formerly NC4000) was a 16-bit stack machine microprocessor designed by Novix in 1985 primarily for the Forth programming language. The NC4016 directly executes the primitives of the high-level Forth programming language. The NC4016 was capable of executing typical Forth programs as much as 20 times faster than the Motorola 68000. Novix also offered the NC4000 Small C Compiler which was compatible with the NC4016 microprocessor. > In 1988, the NC4016 design was licensed and improved by Harris Semiconductor which later rebranded the chip as the RTX2000, a radiation hardened version suitable for spacecrafts use. https://en.wikipedia.org/wiki/RTX2010 https://en.wikipedia.org/wiki/RTX2010 ( https://news.ycombinator.com/item?id=8611274 https://news.ycombinator.com/item?id=8611274 ) > The RTX2010, manufactured by Intersil, is a radiation hardened stack machine microprocessor which has been used in numerous spacecraft.
- stevekemp 4y agoAnother reason why there are so many handmade Forth implementations is because it is almost more educational and rewarding to write a forth than it is to use one. (For the reasons explored already upthread.) I like forth, I've implemented two, and yet the most I've done with it is write toy programs, and use it to script a host program a few times.
- eatonphil 4y agoThe point of discussing these languages isn't always that you should plan to adopt it at your place of work tomorrow. Research into programming languages helps push the boundaries, and advances in PL research get adopted by mainstream languages eventually. Like how most high-level languages today support value assignment + destructuring, which came (as far as I'm aware) from more research-y ML languages. And not all research is done by university researchers. And not all of HN is solely industry practitioners. You just can't make huge assumptions about tech based on what you see on HN, basically. :) With that said, PostScript is a stack language, x86 can be treated pretty similarly to a stack language, FreeBSD's bootloader used to be in Forth (may not be anymore, I don't know). And I hear it's used in constrained/embedded environments. So I don't mean to suggest it's not a practical language either.
- throwaway17_17 4y agoI agree in full, and my comment was quite an over-generalization. As a side note, you tweeted sometime this summer about how there were a load of hobbyist compilers and a lack of hobbyist databases, then in a response mentioned the largeness of the research/conceptual space for databases. Those tweets got me to put database design and implementation onto the top of my ‘read up on’ pile. So, thanks.
- eatonphil 4y agoAwesome! Happy databasing!
- whartung 4y agoHonestly I think that for many, Forth may be a bit too much of a green field to build upon. Out of the box, out of the standard, there no real structured data type ala records, there's no strings, there's no modular coding construct. All of those can be added, but that's the trick. They have to be added. You also start getting into implementation specific stuff that, potentially, makes that kind of infrastructure not portable across implementations. Not that portability is a huge concern, but it's a factor if you want to import someone else's implementation. All of that can be overcome, but that they have to be overcome is part of the problem. Original scheme suffered from this as well, but look how far it's come over time. To the point that all "usable" schemes aren't really the 50 page R5RS versions anymore. It also doesn't help that Forth niched its way into controllers and smaller systems. Forth had all of the availability advantages early on, perhaps even more so, than C, Pascal, etc. But, organically, Forth never caught on. It's fair to say that Lisp suffered "not enough computer" issues early on to hinder adoption, but that's long past. But Lisp still suffers adoption, when pretty much every complaint about it is long buried -- save its syntax. And I just think folks, again, organically, "wisdom of the crowds" don't like S-Exprs for code. They just don't like it. It's off-putting enough that folks look elsewhere. Forth, in the end, suffers similarly. All of these demos and mini DSL examples look great. But they're contrived. Take a look at any Forth code you can find and see if you can make sense of it. Especially "modern" code, where we "know better" and aren't constrained by file size, or line size, or "screens" or "blocks". Take a look at that Zen's github. And try to make sense of it. This is all barrier to entry, and most aren't willing to climb over it.
- throwaway17_17 4y agoI hate that I think you are probably correct. I especially think you hit a strong line of thought with the portions of Forth’s aesthetic and idioms that are very much a product of hyper constrained resources from the time period of its release. The issue of lack of standard library is a part of that time period effect as well, I think any new language has to come with some basics in 2022 which would have been extravagant prior to 1975 (maybe even later if C is any guide). I really am drawn to a Forth—esque syntax, but i think that has more to do with the type theoretical and categorical semantics of my language and it’s projectional properties than simple appearance. Fortunately I don’t think I am ever going to release it, so I don’t have to worry about general acceptance.
- coliveira 4y agoThe reason Forth is not used in production is that its philosophy goes against that of commercial software. The goal of commercial software is to create complex and over-engineered solutions that will force people to pay in one way or another. Languages like C++, Java, Python, and Go are ideal for this. Forth is about creating very simple solutions in as little code as possible. It is better suited for embedded systems and prototype projects.
- golem14 4y agoI disagree with the anti-commercial philosophy that Forth is supposed to have. E.g., there are no oss network stacks I could find written natively in Forth, but there might be a few commercial ones. I believe there are a few very good Forth coders out there that have been working as consultants and much of the code is very proprietary and not available as open source. Otoh, there are tons of free Forth implementations, but they are really meant as a learning tool - it's fun and instructive to write a Forth.
- golem14 4y agoI also believe that this commercial bent Forth has is contributing to it's decline
- smackeyacky 4y agoI would disagree with this statement. The (earlier) history of Forth was that the original inventor would be contracted to implement it on new machines. That it took forever to spawn any kind of interest outside of his commercial activity speaks to Forths practical limitations i.e. every installation becomes a new, extremely opinionated language and we all know the aphorism about opinions.
- golem14 4y agoI think this is also true, but authors could have open sourced application code. Some of it has, esp with Forth standardization . However, even so, there is just very little Forth application code available as open source.
- User23 4y agoOpen Firmware was Forth based and got relatively wide industry adoption. I’d say that counts as viable actual programming.
- dreamcompiler 4y agoI've written both Forth and Lisp for production systems. Both are very intolerant of lax software engineering practices. Because both are "language construction kits," you have to come to agreement with other members of your team about how you will create and document your DSLs, which is a step beyond the agreements you need with "ordinary" languages. The big difference for me was that I couldn't even read my own Forth code after I had been away from it for a year; I had to first re-teach my brain to think like a stack machine. That was never a problem with Lisp. I can look at 10-year-old code I wrote in Lisp and re-understand it quickly (especially with the tools built in to Emacs that are quite helpful for Lisp code exploration).
- milsorgen 4y agoI feel like it's one of the rarer.. esoteric? niche? or for me, aspirational languages on HN. A while back I stumbled across it, got interested, and have kept gforth and some rather aged ebooks on my pixel for those particularly aspirational moments of downtime. The philosophy of it really appeals to me.
- blippage 4y agoSome guy once said that Forth's fragility is its strength. It forces you to think in very simple terms. "Zen" is a good way of describing Forth. Charles Moore often says things that seem like zen riddles in themselves, like Operating Systems are obsolete, you don't need local variables, you don't need structures, and a whole host of other things. It's very difficult to know what he's talking about without context, or why he thinks what he says. I've toyed around with his colorforth, and given up. I doubt I'm the only one. It has cool stuff like you being able to change the fonts on the fly. It has a keyboard consisting of 25 keys (because 25 keys should be enough for anyone, apparently), which don't map onto a Qwerty keyboard (maybe Dvorak?) and has different modes based on colour. So I'm like "how the living fuck am I supposed to use this thing"? It's like trying to figure out the controls of some alien spacecraft. It clearly works perfectly for Charles. He's clearly on some whole different level than the rest of us. Forth is really fun to play with; before going back to using something that is a bit more practical. It has macro-like facilities. I find them very difficult to reason about. Forth seems like Lisp in terms of power, but at the opposite end of the spectrum in terms of size. Lisp is a complete language. Forth gives you a boxful of atoms that you assemble yourself. I wrote a barebones Forth. Little plug: https://gitlab.com/mcturra2000/cerbo/-/tree/master/forth/v3 https://gitlab.com/mcturra2000/cerbo/-/tree/master/forth/v3 I haven't touched it for a year or two, though. It incorporates the notion of a token type. The idea is that you could write a recursive-descent compiler using it, although I hadn't pursued the idea much. To give you an idea of the malleability of Forth: I got bored with creating variables one-by-one, so I defined a word called "vars:". Now I can create several variables at once, e.g.: vars: foo bar baz Here's an implementation (that works in my forth): : VARS: begin parse-word dup while $create 0 , repeat drop ; I simplified the implementation and made the idea more composable: : VARS: line( $create 0 , )line ; Done right, Forth looks like haikus. I'm not at that level, though.
- mncharity 4y ago> seeming incompatibility with producing complex software [...] inherent in [...] minimal syntax design [...] ? Perhaps they are culturally associated? Imagine a Forth bootstrap moving quickly on to C ABI and dynamic linking, to libpython and python ast vocabulary, and to numpy etc. Or a "parse all the languages" GLR/mixfix-expr/regex-token sandwich parser and some LLVM vocabulary. But ... that's not "doing Forth". Culturally. Lisps could read `a[i] = 3` as sugar for `(setf (aref a i) 3)`, but don't. And for overlapping reasons, an organization for weeks struggles to even build its big CommonLisp thing (reader symbol conflict hell). When a community doesn't much go somewhere, the path is unlikely to be smooth. And so a non-technical cultural challenge becomes something more. Minimal syntax has value and power. Non-minimal syntax has value. So if there's one, but not the other, that seems notable, and perhaps a symptom of other issues around tooling up for complexity?
- blippage 4y agoMoore often talks about being a "1X" programmer, as opposed to a "10X" programmer. By which he means that he writes only a fraction of the code that others do. I think it all boils down to specificity vs generality. Moore is specific. He solves one problem, not many. If he has a different problem, then he uses a different solution. By being tightly focussed on his one specific problem, there's many things he doesn't need. Like, he doesn't need a file system. He just stores data and code in blocks in the disk. You end up with a system that is small, tight, minimalist, does what it needs, and then stops. That approach doesn't work if you want to make something more general-purpose, like a Linux kernel. It's not like Linus Torvalds is a nincompoop that somehow didn't realise that 90% of the code was unnecessary. Linux is popular because it solves a broad range of problems to a broad range of people. Forth systems are unpopular because they solve the problem of one man. Not only that, that one man must have a mental model of how his whole system works. The upside is that the system is much simpler than a general-purpose one. One could say that Forth is not just a language, but a whole philosophy as to how and what programs should be constructed.