Hacker News new | ask | show | jobs
by kronos29296 3277 days ago
Is that why nobody uses it anymore? Only thing I know about it is that it used stack like expressions. (kinda like RPN but for everything)
2 comments

My understanding is fourth is still alive and well in the embedded world. A fourth compiler can be written in very few instructions, which is very important when you don't have a lot of memory to work with.

http://demin.ws/blog/english/2012/09/27/fcode/

I think nowadays more interpreters/compilers are being written for FORTH than stuff in the language itself.
Kinda like BrainF* I see. Turing complete but a readability nightmare. Maybe I should try to write one for FORTH like for BrainF*. Was an interesting exercise especially the loops.
No, the parent is wrong. Maybe on Github Forth interpreters dominate as people's pet projects but there's a good chunk or niche of the embedded industry writing real Forth code every day for new things, not just legacy support. But their code usually isn't on Github. It's a great language for bare metal programming and quite readable, unlike BF which is intentionally unreadable. Forth was designed for low level really (edit: though I remembered there's this if you want an idea of the philosophy http://thinking-forth.sourceforge.net/), I think it's less suitable for higher level general purpose programming just for its untyped nature alone.

https://www.forth.com/embedded/#Annotated_example_source_cod... contains a version of the canonical washing machine program.

    \ Top-level control
    : WASHER ( -- ) WASH SPIN RINSE SPIN ;
You can then look at the definitions for 'WASH' and 'SPIN' and 'RINSE' and so on until you get down to what IO bits you're turning on or reading when and for how long.