6 ms·
Easy Forth: Learn forth with REPL in the browser
- Munksgaard 6y agoThis is great! Forth is such an interesting language. Does anyone know of uses in industry?
- rwmj 6y agoNot sure if it counts as "industry" but FORTH-based Open Firmware is still used as a bootloader for some PowerPC machines. You can try this out under qemu: $ qemu-system-ppc64 VNC server running on ::1:5900 $ vncviewer :0 Ready! 0 > 1 2 3 * + . 7 ok 0 > WORDS (gigantic list of built-in words ...)
- exikyut 6y agoAnd FWIW Open Firmware runs on x86 too.
- jonsen 6y agoThird line of the introduction: “...is still used today for certain applications.” and is clickable.
- guerrilla 6y agoAccording to Wikipedia[1] it's used in astronomy and aerospace. It's also used in OpenFirmware like in old PowerPC Mac and IBM computers. 1. https://en.m.wikipedia.org/wiki/Forth_(programming_language) https://en.m.wikipedia.org/wiki/Forth_(programming_language)
- s-macke 6y agoIn the gaming industry. The game Starflight was written in Forth. https://en.wikipedia.org/wiki/Starflight https://en.wikipedia.org/wiki/Starflight Ok, this is an ancient example. But still :-) The source code is partially available. Here one example. https://web.archive.org/web/20030906110447/http://www.sonic.net/~sage/sf/src/SOURCE-11-05-85/BANK_CMP.pdf https://web.archive.org/web/20030906110447/http://www.sonic....
- MaxBarraclough 6y agoSee: • https://www.forth.com/resources/who-uses-forth/ https://www.forth.com/resources/who-uses-forth/ • https://vfxforth.com/#customers https://vfxforth.com/#customers (Curiously this also turned up on another thread, https://news.ycombinator.com/item?id=26165804 https://news.ycombinator.com/item?id=26165804 )
- dastain 6y agoYou can install it on MCUs and use it to debug code pretty easily and makes it really nice to use reflection[1]. This use is not necessarily limited to enthusiasts, since nowadays even Arduino ends up in commercial products. While the language itself it's considered difficult to read by some, it's a great way to access MCUs features in a stack-based way and at a level higher than assembly. 1. https://www.youtube.com/watch?v=dvTI3KmcZ7I https://www.youtube.com/watch?v=dvTI3KmcZ7I
- lebuffon 6y agoThe Fedex handheld terminal was re-written in Forth... twice. :) First time all the features wouldn't fit. Forth re-write fit with room to spare. (factoring is easy in Forth) New Hardware! Everything fit but batteries didn't last a full shift. :( Forth with a proprietary tasker put the device to sleep at every opportunity. Problem solved.
- Jtsummers 6y ago> factoring is easy in Forth Even more than working in functional languages like SML, Forth (and RPL, my first stack language) taught me how to factor out code and remove/minimize duplication. It's just so obvious when using it where the duplication is, the hard part is coming up with decent names. But if a sequence of words can be given a good name, give it that name and define it.
- joubert 6y agoSpace.
- JadeNB 6y agoHere's an HN post on Forth in space! https://news.ycombinator.com/item?id=26164942 https://news.ycombinator.com/item?id=26164942
- bmitc 6y agoForth is just fun.
- MaxBarraclough 6y agoYou're still thinking in infix notation! FUN FORTH IS
- joubert 6y agoMissing the tone. :-)
- jonsen 6y agoHow do you press “the Enter key” on an iPad? My operators are just stacked with Return.
- exikyut 6y agoFor reference, what does the iOS keyboard you're seeing look like? Selecting the text field in Android just pops up my selected keyboard (Gboard), which includes an Enter key.
- jonsen 6y agoI use the standard keyboard. Don’t know what I can compare the look of it with. I’ve never seen or used an Android device. Maybe I can find a keyboard app with an Enter key.
- ilaksh 6y agoCheck out ColorForth. Or RaonbowForth online http://rainbowforth.appspot.com/ http://rainbowforth.appspot.com/ https://youtu.be/N1FUY6g5crA https://youtu.be/N1FUY6g5crA
- mikewarot 6y agoI'm amazed that it worked so well, it did confuse me that each repl didn't know the previously defined functions, is that just me? Forth is almost the postfix inverse of lisp. Instead of arity errors, you have stack over and underflow. And it only has one list, instead of lists of lists. Oh, and it's not garbage collected Oh, it it's not homoiconic {edit]I guess it's really not the same thing at all Amazing how a day's exposure to Racket shifted my opinion
- mumblemumble 6y ago> Oh, it it's not homoiconic Is it as homoiconic as it needs to be? It's been a while since I've played with it in any real way, but, as I recall, Forth represents both data and code in exactly the same way: Blobs of data with no associated type information, that you're allowed to fiddle in any way you want, with no guard rails. So it seems like there's no reason you couldn't write some words for manipulating code every bit as easily as you could write some words for manipulating any other data. Lisp gives you a lot more out of the box, of course. But Lisp gives you a lot more of everything out of the box.
- astrobe_ 6y agoIt depends on the implementation. With Indirect Threaded Code (ITC), "functions" are represented more or less as a list of other functions or primitives to call. But there are also classic bytecode-based Forth implementations, subroutine threaded code implementation (which is a simple form of native code generation), etc. In my experience, Forth's "immediate" words, which let you execute code at compile time, combined with the availability of some (or most) of the compiler's part, let you do quite a lot of things. In other words, you don't manipulate code, you directly generate code. For instance, if your implementation does not have 1+ (silly example), you can make a word "1+" that compiles "1 +" inline (or increment the top of stack if you interpret stuff from the REPL). To answer your question, I use a dialect of Forth that has, I think, less capabilities than standard Forth in this area and rarely felt the need to implement them. At the risk of showing I am a blub programmer, I think homoiconicity is overrated - for the user (for language implementers maybe it's another story).
- 6y ago
- dastain 6y agoLovely, as other tools by Skilldrick. I've used Easy6502[1] before and forked it to customize it for a project of mine. I was just about to install Forth on an STM32 (blue pill) MCU, which is pretty nice![2] 1. https://skilldrick.github.io/easy6502/ https://skilldrick.github.io/easy6502/ 2. https://www.youtube.com/watch?v=dvTI3KmcZ7I https://www.youtube.com/watch?v=dvTI3KmcZ7I
- fifilura 6y agoIt feels like I am running an emulator for my high-school HP-11 RPN calculator!
- zabzonk 6y agoI've written a couple of FORTH-like implementations - one way back when on a Z80 system, when I was learning Z80 assembler, running CP/M, and one on an IBM PC (the original kind, with clicky keyboard) when I was learning 8086 assembler and a bit of C++, as part of an adventure-writing system. Unfortunately, the code for both has got lost (no git back then), but I can strongly recommend writing a FORTH as a way of learning a new (non-FORTH) language.