Hacker News new | ask | show | jobs
by tehologist 1252 days ago
I didn't really understand forth till I tried implementing eforth in c.

https://github.com/tehologist/forthkit

Managed to write a compiler/interpreter that could understand enough forth to implement the entire system. Less than 500 lines and only uses stdio.h and compiles using TCC

https://bellard.org/tcc/

That was so much fun I built a second one in under 300 lines of javascript for experimenting with canvas api in web browser. Single file doesn't require a server, you can drag and drop code onto text window.

https://github.com/tehologist/ecma6-forth

Runs standalone, I want to get back to it again.

2 comments

Along similar lines, i once watched this guy on YouTube implement a Python-based Forth _compiler_ (not interpreter) and optimize the crap out of it. It was a great video, if anyone’s interested it was called “Porth” and i think his GitHub page has a link to the video.
Found the video you referenced.

https://www.youtube.com/watch?v=8QP2fDBIxjM&list=PLpM-Dvs8t0...

I met the creator Charles Moore a few times. When I lived in the bay area and used to go to the svfig (silicon valley forth interest group) meeting. He would often talk about forth was like solving a puzzle, likened it to sudoku. It is a good exercise for the brain and I highly recommend it.

https://www.forth.com/starting-forth/

Back in the eighties I went to a presentation by Moore on VLSI design featuring a GUI design tool he wrote in Forth. The physical user interface was via contacts taped to his fingers and thumb, he would touch them together to navigate the UI. We were very impressed.

I still have a tshirt that reads “Be Moore Like Chuck”…

I know it's a lot of fun writing Forths and that's how most people tend to experience Forth, but I like to urge people to actually build applications on Forth. Understanding Forth by writing applications is probably the best way to get a feel for Forth.
Is there any "battery-included" ANS Forth (more or less like Python/Go) which provides access to concurrency, networking, database, GUI, etc?

Not an embedded device programmer, but mostly deals with frontend apps, and occasionally backend, so those are very relevant to me.

Or perhaps use "non-traditional" Forths like 8th (https://8th-dev.com) or Factor (https://factorcode.org)?

gForth is probably the closest you'll get to a batteries-included ANS Forth. It has a lot of libraries and does have some GUI libraries. It definitely has networking and some amount of db words, I'm not sure what it's concurrency situation is like.

8th is a great not-Forth. Highly recommended because of how practical is.