Live data from Hacker News

What the hell is Forth? (2019)

blog.information-superhighway.net

111–120 of 138 posts

Re: What the hell is Forth? (2019)

#111
What a great read! I have to admit that I’m biased towards FORTH, I’m not a programar, more of a maker, so when I need to build an embedded project, Forth is my go to solution form my application. One of the benefits I have found in Forth “in my opinion” for embedded is factoring your code so that you only leave on the stack what you need, this makes for very compact machine code, great memory economics, and a relative fast system, even compared to C native code.

Working interactively with the HW is on of the most rewording parts of FORTH for me, to see the actual value of the bitfield you are using is great to trouble shoot new HW, and figure out just what you are doing.

One of the things I wish the FORTH community would do a better job of is, while keeping the interactiveness of Forth for development on the HW, it would be great to have a portable “true Forth VM” that you can take to a new platform and deploy a precompiled virtual Firmware or ROM. This IMO is beneficial for two reasons, you gain portability as the combined Froth adheres to the VM, and you can just take what you needed to the platform you are targeting, no need to have all the parts of a FORTH REPL or compiler. Just burn the App FW (VM + App) and you are done.

This would also allow for a single instance of FORTH, in the sense that your code will be portable across all systems, as the core compiler and interpreter are all targeting the VM and not the HW. Rather than build “ A Forth “ for each systems, you add the “HAL” that allows you to compile the VM for the HW. I use mostly ARM with Mecrisp, so I kind of have that now. Hint, it’s what make “arduino” so popular…

I highly recommend FORTH for Embedded applications, as I have build even a very BASI PID with little efforts… but it is a low level effort, and if you enjoy Bare-Metal development, you will be right a home in FORTH, if you are dependent on upstream libraries and HAL, you will, IMO struggle in FORTH regardless.

Re: What the hell is Forth? (2019)

#112

I've been wanting to evaluate forth as a personal computing language, does anyone know any games written in pure forth?

Blog author here, in 2020 I released a DOS game built completely in my own Forth system. Fully open source and hackable. https://spindleyq.itch.io/neut-tower

The coolest application of the Forth philosophy in that project was actually building tools that integrate directly with the engine, imo. I built a map and tile editor directly into the game for quickly iterating on art and level design, and at one point even added a slide presentation engine for giving talks with that had live demos integrated directly into slides. The eureka moment was when I added map editing and realized that I didn't need to write a fancy GUI just for saving and loading maps, because I had a live Forth console running over the serial port. As soon as I'd written the save/load routines they were immediately, directly usable.

Death Road to Canada is another game I'm aware of that is written in Forth, for more modern platforms.

Re: What the hell is Forth? (2019)

#113
post #44

The author complains about not having local variables, but most decent Forth environments have them. It is not difficult to have local variables in Forth, just use a library or compiler that provides them.

The language has, perhaps, a bit too much Chuck Moore: Don't reuse code, don't make code reusable, and don't try to anticipate anything. The knob is turned all the way over to the "simplicity of implementation" end of things, and all else be damned. http://www.cs.uni.edu/~wallingf/blog/archives/monthly/2017-1...

With regard to local variables, although standard Forth has them or considers them as an extension, Moore is correct in the sense that they are a crutch for when you did something wrong - often they allow to sweep under the carpet a "stack juggling" issue, which is usually a sign that you should reconsider your approach to the problem.

FYI Moore also designed processors; one of his designs was apparently viable enough to be part of the Rosetta mission. At some point he wrote his own CAD program to design his processors, which are at the very least functional.

It's not "simplicity of implementation" for the sake of it. It's about finding the simplest solution to a problem. But people too often confuse "simple" with "easy" if not "lazy" or "simplistic" - like your depiction of his approach.

Re: What the hell is Forth? (2019)

#114

What a great read! I have to admit that I’m biased towards FORTH, I’m not a programar, more of a maker, so when I need to build an embedded project, Forth is my go to solution form my application. One of the benefits I have found in Forth “in my opinion” for embedded is factoring your code so that you only leave on the stack what you need, this makes for very compact machine code, great memory economics, and a relati…

Not sure if this is useful for hardware, but there's UF [0] for Uxn [1], a tiny VM that can you can get to run on lots and lots of (old and new) devices.

[0]: http://www.call-with-current-continuation.org/uf/README (git repo link at the bottom of that page)

[1]: https://100r.co/site/uxn.html

Re: What the hell is Forth? (2019)

#115

Earlier quoted context omitted.

Decades counts as lately. Are there any other programming religions?

Haskell, Julia, Rust, Lisp, and Forth are 'esoteric' enough to create an in-crowd, who are quite often deluded by imagined miraculous solutions to people's problems. Please repeat after Fred Brooks: there ain't no silver bullet. To a certain extent this goes on outside programming languages per se: OOP, Gang of Four, Agile match the pattern as well.

Feel APL similar in-crowd member too, though perhaps even more niche

Re: What the hell is Forth? (2019)

#116

I've been wanting to evaluate forth as a personal computing language, does anyone know any games written in pure forth?

Blog author here, in 2020 I released a DOS game built completely in my own Forth system. Fully open source and hackable. https://spindleyq.itch.io/neut-tower The coolest application of the Forth philosophy in that project was actually building tools that integrate directly with the engine, imo. I built a map and tile editor directly into the game for quickly iterating on art and level design, and at one point even ad…

I really enjoyed reading your Forth related blog posts, that's why I shared this one on HN. Thanks for writing them!

I also liked these:

- https://blog.information-superhighway.net/data-is-code

- https://blog.information-superhighway.net/retrocomputing

Re: What the hell is Forth? (2019)

#117

Earlier quoted context omitted.

Decades counts as lately. Are there any other programming religions?

Haskell, Julia, Rust, Lisp, and Forth are 'esoteric' enough to create an in-crowd, who are quite often deluded by imagined miraculous solutions to people's problems. Please repeat after Fred Brooks: there ain't no silver bullet. To a certain extent this goes on outside programming languages per se: OOP, Gang of Four, Agile match the pattern as well.

The "in-crowd" vibe is very different from religion. We admire a language for its strengths, but worship it for its faults. APL is beginning to shade into theological territory.

Re: What the hell is Forth? (2019)

#118

Earlier quoted context omitted.

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-…

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”…

Re: What the hell is Forth? (2019)

#119
post #95

Earlier quoted context omitted.

bc is built on dc and uses infix notation. bc -l supports arbitrary-precision arithmetic, IIRC.

`k` in dc sets the fractional digits after the dot. I am not sure there is a limit but 99 works ...

Good to know, can be useful.

Re: What the hell is Forth? (2019)

#120
post #5

Earlier quoted context omitted.

Agree with the parent, it's a language worth knowing like LISP is worth knowing, but (unlike LISP) it is not a good language choice for almost all use cases in 2023 (almost all use cases are not that memory constrained any more, even embedded systems), for the same reason you shouldn't use Perl (it is very hard to read code). I was going to say "its main disadvantage is that the only way to find out what a piece of c…

Perl doesn't seem like it should necessarily be hard to read (I'm not a perl programmer) but agree that most perl that I've seen is pretty opaque. I guess if you really get to know the idioms maybe it's easier.

I guess if you really get to know the idioms maybe it's easier.

It is, as long as you stay away from things like selfgol* or memowe's keywords only JAPH** (which is technically very readable, it's just very hard to comprehend).

* https://libarynth.org/selfgol ** https://www.perlmonks.org/?node_id=594266

Post reply on HN