8 ms·
Right. And once again, you’ll also notice that no one is actually coding anything useful in Forth.
by s-macke 1y ago
Right. And once again, you’ll also notice that no one is actually coding anything useful in Forth.
- pjmlp 1y agoUnfortunately we aren't in the 1980's glory days of Forth in 8 bit home computers, and many students don't know what HP-48GX stands for.
- PaulHoule 1y agoBASIC, especially the Microsoft dialect, became the dominant language for microcomputers because it would fit in a tiny space, e.g. 4k. For that matter it was big in the minicomputer age because it was used in multitasking systems that weren't that big. Circa 1980 my high school had a PDP-8 which had three terminals and could run a three user BASIC with just 32k 12 bit words. There weren't a lot of languages which would fit in a tiny space, but FORTH was one of them. Like LISP it's a language where you can (1) implement the language without any kind of recursive parser and (2) write control structures in the language itself because each "word" in forth has both a run-time and compile-time interpretation.
- pjmlp 1y agoOriginal BASIC did not fit into tiny space, that is why while Dartmouth BASIC always compiled into machine code before execution, everyone that learnt BASIC in 8 bit systems thinks it was originally interpreted and compilers only came later, which was the compromise to make it fit into a few KB. Jupiter ACE had its followers, and it was common to see ads on Your Sinclair and similar magazines for ROM replacements using Forth instead of BASIC.
- PaulHoule 1y agoThat PDP-8 BASIC was a miracle of shoehorning as was everything else on the PDP-8. My favorite minicomputer BASIC that I got to use was on RSTS/E on the PDP-11 which had split 64k address spaces for code and data and used fairly advanced compilation techniques. Roughly the RSTS/E experience was like having your own Apple ][ but with a hard drive and a little more oomph. I grew up in New Hampshire right next door to DEC's headquarters in Massachusetts and there were DEC minicomputers everywhere. Microsoft had a compiled BASIC (like run a compiler, not compile interactively like Microware's BASIC09) on CP/M for the Z-80 which was a much better compiler target than the popular 6502. I wrote a FORTH for the TRS-80 Color Computer using the OS-9 operating system which had maybe 2000-3000 lines of assembly code. FORTHs at the time often did block I/O directly to the disk but OS-9 had an API to access files that was pretty similar to Unix and my FORTH exposed that.
- kragen 1y agoRPL isn't Forth.
- pjmlp 1y agoTechnically you are right, in practice they are close enough in concepts, exploring stack based languages.
- kragen 1y agoI don't agree at all. They do have something in common: they're stack-based. But what they don't have in common is everything else. RPL is a dynamically-typed, bounds-checked, memory-safe, garbage-collected language similar to PostScript or Python. Forth is an untyped, unsafe language with arbitrary compile-time compilation and without even a heap, traditionally. It's the minimal veneer on top of assembly language to give it arbitrary compile-time metaprogramming and nested expressions and control structures. RPL doesn't even have compile-time metaprogramming at all. These two languages represent diametrically opposed approaches to programming language design.
- johnisgood 1y agoIn Factor though, they do. https://factorcode.org/ https://factorcode.org/
- 7thaccount 1y agoIt looks like it's still being developed, but I feel like the 0.1 version number hasn't changed in 10 years. What cool projects are people making?
- jinwoo68 1y agoIts version seems to be 0.100, not 0.1. And it was released last year: https://downloads.factorcode.org/releases/ https://downloads.factorcode.org/releases/
- johnisgood 1y agoCheck out the website (I linked it) for examples. Additionally, check basis/ and extra/ on https://github.com/factor/factor https://github.com/factor/factor. You will find A LOT of goodies there. They even have a framework for Discord bots using latest Discord API version, if you are into that. In any case, you really ought to check, there are too many things to list here. As someone else pointed out, it is 0.100 which was released not that long ago, and if you compile now, it is 0.101 anyways, but regardless of their versioning, it has been actively maintained ever since, they just did not bump the version for a long time.
- kibwen 1y agoEh, that's sort of like saying that nobody's coding anything useful in assembly language. Both the JVM and WASM are stack machines akin to Forth.
- kragen 1y agoThey're akin to Forth, but they're not Forth, and they're not implemented in Forth. By contrast, assembly language underpins most software people run today: perhaps it's written in Python, which is interpreted by CPython (using a bytecode which is considerably more Forthlike than Wasm, incidentally), which is written in C, which is usually compiled by GCC or LLVM to textual assembly language in order to generate the executable.
- kragen 1y agoWell, I don't know if this qualifies as useful, but I wrote a minimal roguelike in one page of Forth last year: https://asciinema.org/a/672405 https://asciinema.org/a/672405 vdupras is here in the comments today. He's written a self-hosting interactive operating system in Forth, including a FAT16 filesystem and everything, and a compiler for a useful subset of C: https://duskos.org/ https://duskos.org/
- bell-cot 1y agoIt's a cool little niche language. If you're neither interested in the coolness, nor its little niche - there's no need to be dismissive.
- s-macke 1y agoYes, my comment came across a bit harsh, and it’s fine to pick up a few negative karma points. But I keep seeing Forth posts every two weeks where everyone has just built yet another interpreter. Actually I did a few projects with Forth and I find it very cool: [0] https://github.com/s-macke/Forthly https://github.com/s-macke/Forthly [1] https://github.com/s-macke/starflight-reverse https://github.com/s-macke/starflight-reverse [2] https://s-macke.github.io/concepts-of-programming-languages/docs/04-Forth.html https://s-macke.github.io/concepts-of-programming-languages/...
- hobs 1y agoI like that way of thinking about it - now I want my negative karma points separated into their own bucket even if the final summary is presented out, I think its an interesting signal.
- bell-cot 1y agoDang & Co. doubtless see such things - but I'd bet it'll never be shown to regular users. Too little utility, vs. too tempting for a small minority to game in unhealthy ways.
- kragen 1y agoHeh, I see you linked StoneKnifeForth there!
- bxparks 1y agoAs I like to say: "C is a language that solves a million problems. Forth is a million languages that solve almost nothing." :-P I've been reading about Forth for 30-40 years. The dual stack is easy to understand. My problem is that I cannot see how control flow works in Forth, e.g. a simple if-then-else. I think that something as fundamental as an if-then-else should be obvious in a useful language. Heck, it's obvious in assembly language. But not in Forth.
- alexisread 1y agoHave you tried looking at Sectorforth? In most languages branching is a fundamental construct, it's created here (with comments) https://github.com/cesarblum/sectorforth/blob/master/examples/01-helloworld.f https://github.com/cesarblum/sectorforth/blob/master/example... Effectively IF compiles a 0= ie. If false and then a dummy target address. THEN (aka ENDIF) compiles the real target address over the dummy one, which is the address after THEN.
- kamaal 1y ago>>Forth is a million languages that solve almost nothing." :-P That brings us to the question, when it was invented and people did use it. What kind of problems were they solving with it?
- jonjacky 1y agoForth was invented around 1970 for controlling equipment in an astronomical observatory, running on a PDP-11, a 16-bit computer with up to 64 Kbytes of memory. Its heyday was the 1970s and 80s, when it was mostly used for small embedded systems on 8- or 16- bit processors with 8 kb -- 64 kb of memory. It was possible to run an entire Forth development system along with the application on these small targets without resorting to a bigger computer for cross-development. The usual alternative to Forth on those systems was assembly language.
- EasyMark 1y agoI was dropped into one such system after it failed after like 20 years and learned forth on the fly while managers breathed down my neck lol. Not a fun experience, and it took about 3X as long as I thought it would take, so Forth is not my favorite language, but I do see why it was useful at the time, and as an exercise in a way of thinking about languages rather than the mode I usually operate in c/c++/rust/little javascript
- soapdog 1y agoWhat about openfirmware?
- idatum 1y agoIf I can find a Forth for a new chip I'm learning, I use it as a way to explore the chip with a REPL. Micropython can be similar this way, but it's more constrictive.
- nmz 1y agoEvery single coder that uses chaining operators is using concatenative programming concepts. Shell piping is also a form of concatenative programming. Just because you don't specifically use forth does not mean forth is dead.
- kragen 1y agoShell piping isn't Forth.
- nmz 1y agoI didn't say it was forth, I said it was concatenative. Forth itself is hard to categorize since it refuses to standardize but we all know what it looks like, I'd say its a low level language/VM that manages everything through stacks (usually 2) there's forthlike languages and also concatenative languages. concatenative languages can be far removed from forth, I don't mean that the shell itself is concatenative, but only the shell pipelining aspect, which you can imitate in any forth. take an object and keep passing it to subsequent functions without popping that know s how to handle that object, that's a shell pipeline to me, all of unix can be passed the /dev/std* objects and they can all modify it and pass it along to the next function/program. https://concatenative.org/ https://concatenative.org/
- kragen 1y agoWell, I agree that Forth is concatenative (like stack languages in general), and so are shell pipelines. But you said, "Just because you don't specifically use forth does not mean forth is dead," and unless I misread your intent, you included your shell-scripting point on the theory that it was relevant to that question: whether or not Forth was dead. The implication seemed to be that, as long as people were using shell pipelines, Forth wouldn't be dead. But that's wrong; Forth could be totally dead while other forms of concatenative programming were alive and well.
- fallat 1y agoI've done: - Accounting system used for real life taxation in my self-employment: https://gist.github.com/lf94/fcdf41776e14fcc289bac652ea8cb4f8 https://gist.github.com/lf94/fcdf41776e14fcc289bac652ea8cb4f... - Software shader rasterizer for image generation: https://gist.github.com/lf94/f74c927e59b4010d9de001fa2ba87910 https://gist.github.com/lf94/f74c927e59b4010d9de001fa2ba8791... - PS4 controller macro system via an RP2040 & ZeptoForth: https://youtu.be/exayMSQfyqk https://youtu.be/exayMSQfyqk, https://gist.github.com/lf94/2d64917728594516dee6caf7667d2e47 https://gist.github.com/lf94/2d64917728594516dee6caf7667d2e4... - Iambic paddle tap interpreter for morse code practice (once again running RP2040 & ZeptoForth): https://gist.github.com/lf94/95516fa39c3339b685e0fde10f17c97a https://gist.github.com/lf94/95516fa39c3339b685e0fde10f17c97... - Fixed-point number library to run computations on pretty much any CPU in existence: https://gist.github.com/lf94/ca622ebac14d48915ea976f665f832cf https://gist.github.com/lf94/ca622ebac14d48915ea976f665f832c... - 1-bit music synthesis experiments to learn how to make music with a beeper (useful in products, such as Tile): https://www.youtube.com/watch?v=IjTihhFG03o https://www.youtube.com/watch?v=IjTihhFG03o, https://www.youtube.com/watch?v=_6f8PURcPEE https://www.youtube.com/watch?v=_6f8PURcPEE And that's all in my rare spare time. Forth really shines in microcontroller or esoteric computation machines, but further more, people don't realize their C compilers are billions of dollars of development, and they'd never be able to do it in the first place. A Forth on the other hand can be developed in a month (I'm being honest-to-god realistic here. A lot of people would say "a weekend", but let's be real, anything useful will be more than a weekend. I'm trying to convince you this isn't bullshit :)). If you have any more questions let me know. I was bit by Forth about 2 years ago but had read about it long ago when I was like 16 and passed it off as too hard. It's the same shit as when FP took off: it's a different mental model, so it will take time to morph your mind. Edit: read the larger comment below, and they are totally correct: > most Forth tutorials today are written by people who don't really know Forth One day I might write a small Forth novella teaching how to actually think about Forth programs. In these 2 years I've had to just practice and write programs to see common patterns or idioms - kind of exactly like when I was learning Haskell years ago.
- kragen 1y agoThis is pretty impressive! I don't think it takes billions of dollars in development to write a C compiler, but it does seem like everyone's first C compiler does take at least a year, so US$100k is a good ballpark. I agree that Forth is about an order of magnitude easier. You probably shouldn't consider https://github.com/kragen/stoneknifeforth https://github.com/kragen/stoneknifeforth to actually be a Forth (it's not interactive and doesn't have immediate words) but it did compile itself into a working ELF executable and it did take me almost exactly a month to write (October 02008, specifically). I could probably write a real Forth now in a month. I would be very excited to read your small Forth novella. Or your small Haskell novella.
- adastra22 1y agoBitcoin’s scripting / smart contracting language is Forth. Were there anything in the crypto space is actually solving a problem is up to your own biases and prejudices. But if you pick one thing as actually trying to solve a real problem, payments over lightning is probably that. Lightning, at its core, is a state machine composed of Forth spend scripts.
- tromp 1y agoWhile bitcoin script is a stack language, it doesn't really qualify as Forth as it doesn't allow you to define any new words.
- kragen 1y agoNo, Bitcoin Script is not Forth. Bitcoin Script is designed to guarantee termination, so no Turing-complete programming language was permitted. Like BPF, Bitcoin Script doesn't have subroutine definitions or backward jumps, so each opcode executes at most once. This is like saying JSON is C++.
- deleted 1y ago[deleted]