5 ms·
Today, what is the typical software one would build with Forth? What are the libraries like?
by nabeshima 11y ago
Today, what is the typical software one would build with Forth? What are the libraries like?
- laumars 11y agoI wouldn't say this was it's "typical" usage, but the only time I personally have written Forth was when editing FreeBSD bootloader: https://www.freebsd.org/cgi/man.cgi?query=loader%288%29 https://www.freebsd.org/cgi/man.cgi?query=loader%288%29
- pgeorgi 11y agofirmware, boot loader, 1980's text editors. As for libraries: Usually that boils to "No." To quote: "The conventional approach, enforced to a greater or lesser extent, is that you shall use a standard subroutine. I say that you should write your own subroutines." (http://www.forth.com/resources/evolution/evolve_1.html http://www.forth.com/resources/evolution/evolve_1.html)
- anon4 11y agoI've heard good things about Factor - another stack-based language, which is more high-level than Forth, but I've never used it.
- coliveira 11y agoYou can write pretty much anything you want. The problem is that the standard Forth has very few libraries, and most libraries around depend on a particular implementation. To see what is possible, check Win32Forth for example.
- bandrami 11y agoI wrote the OS for my Raspberry Pi in Forth (which necessarily meant writing the interpreter). I think that's an important thing: anybody who's seriously doing Forth work has written his or her own interpreter to do it with. Which may be as it should be.
- bucma 11y agoAny chance that you've put the code out there somewhere? I'd love to see it.
- jamesbowman 11y agoI write Forth code for tiny microcontrollers that are embedded in ASICs. They are ROM-based, and have to work first time. Size is a few hundred bytes, so C is out of question.
- muyuu 11y agoInterestingly, Bitcoin and similar systems use a Forth-like stack language as script. For instance, a typical transaction goes like this: [scriptSig] [scriptPubKey] Where scriptSig is: __signature__ __public_key__ and scriptPubkey is: OP_DUP OP_HASH160 __some_hash__ OP_EQUALVERIFY OP_CHECKSIG In rough terms: OP_DUP works like classic Forth DUP, duplicates the immediate stack element. OP_HASH160 replaces the stack element with its hash160. OP_EQUALVERIFY performs a "fail if not equal" and OP_CHECKSIG takes two elements from the stack and verifies they're a pubkey and its signature. So basically that's how the system verifies that a transaction is signed by the owner of the input address to go to the owner of the output address.
- RodgerTheGreat 11y agoYou could write videogames: https://github.com/JohnEarnest/Mako https://github.com/JohnEarnest/Mako
- fra 11y agoThe bootloader for Sparc systems @ Sun is still OpenBoot, written in Forth: https://en.wikipedia.org/wiki/Open_Firmware https://en.wikipedia.org/wiki/Open_Firmware I worked on it a bit, though it doesn't change much beyond bug fixes these days. Peripheral vendors still routinely provide FCode drivers in the server space.
- cartoonfoxes 11y agoEmbedded systems. Forth makes for a pretty sweet environment for interactive driver development.