Live data from Hacker News

What the hell is Forth? (2019)

blog.information-superhighway.net

121–130 of 138 posts

Re: What the hell is Forth? (2019)

#121

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…

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)?

Re: What the hell is Forth? (2019)

#122
post #79

Here we go again :) I've written a ton of Forths over the years in different languages, and every time I run into an article about it I get the itch to do another one.

> get the itch to do another one.

If you really want to satisfy that itch you should try building a Forth computer from scratch. Back in the 80s a friend showed me how to build a Forth CPU from PLAs (might have been some earlier cheaper form of programmable logic, heheh) and SRAM plus a little random logic. By the end of the weekend we were running floppy drives and a crt with it.

Re: What the hell is Forth? (2019)

#123
post #34

Earlier quoted context omitted.

> it is not a good language choice for almost all use cases in 2023 I think I agree with this. But it’s fun to think about wild scenarios where it would make sense. Like some dystopian future where people are trying to cobble found hardware together to make something.

> Like some dystopian future where people are trying to cobble found hardware together to make something. https://git.sr.ht/~vdupras/duskos http://collapseos.org/

Thank you!

Re: What the hell is Forth? (2019)

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

If a Forthlike language was to be made today, what features would it require to not be a hard-to-read mess? I can see some type of typesystem being useful, I dont know what else can make it better.

Typing would make things more verbose, but not any more readable than just writing words for each type of data you're dealing with, which accomplishes the same thing. Forth can dictionary mask and forget words, so typed-lang-style overloading is trivial, but unnecessary.

Many short word names could be expanded from symbols and abbreviations suited for 4-character names into more verbose versions, but the underlying RPN stackiness would still prove an impediment to broad understanding.

Native vectorization like APL or Lisp would increase the base complexity of the language machinery and make implementation more complex, but would allow the language to be simpler by getting rid of the need for most stack reordering.

Re: What the hell is Forth? (2019)

#125

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

There was a bit of discussion over on Reddit of a game called "Cosmic Conquest", printed in an edition of Byte magazine, that is supposed to be the first space RTS. That was entirely written in Forth on the Apple II.

A few of us managed to resurrect the code, and I've managed to get it more-or-less working as intended. Once I get time I'll tidy up the bits I wrote so they're fit to show in public.

Here's a video of it:

https://gjcp.net/conquest.mp4

Re: What the hell is Forth? (2019)

#126

Wait! Is core Forth smaller than core Scheme?

You can write a Forth-like in a few lines of a modern language and then keep expanding it. There are Forths for the smallest systems and challenges of minimal instruction set Forth, like [0]. The article [0] explains what people (and myself) are really happy about having this around: > Let's pretend I've wired the 68HC11 so that port A pin 01 controls an LED. I can't remember whether a 0 or a 1 turns it on and I'm no…

Forth semantics work nicely as unstructured glue, I've found. As you start getting into the weeds of algorithm design it becomes more of a puzzle. But that also makes sense, in a Forther context. The most Forth-like thing to do is not to start abstracting and imposing structure so that you can have a configurable algorithm, but to define down the problem to a table of static results, and thus complete the circle of "code is data". I believe Chuck Moore said something to the effect of Forth being in the workflow and mindset: once you have a problem defined to need that much complexity of automation, it's not a problem solved by Forth-the-language.

Of course, Moore also has done some algorithmically complex things with Forth-the-language, so I might be off-base in that assessment.

Re: What the hell is Forth? (2019)

#128
post #77

Earlier quoted context omitted.

Reminds me a bit of dc: https://en.wikipedia.org/wiki/Dc_%28computer_program%29

People who are interested in low-level language implementation might wish to learn a little dc , because its ability to easily produce arbitrary binary output may come in handy when boostrapping.

There was that old RSA in a sig file...

    #!/bin/perl -sp0777i
You'll note on that last line a |dc` as all of that stuff after the `echo` gets packed into something for dc to run.

http://www.cypherspace.org/adam/rsa/rsa-details.html

Re: What the hell is Forth? (2019)

#129
post #77

I started using Forth because I wanted a Reverse Polish Notation calculator at the command line. It turned out to be very practical and extensible. For example, I created many words to perform unit conversion, such as temperature: : 2fahrenheit 9 * 5 / 32 + ; : 2celsius 32 - 5 * 9 / ; Furthermore, I can even pull in live currency conversion rates from Yahoo Finance to go between USD and CAD. Since my underlying Forth…

Reminds me a bit of dc: https://en.wikipedia.org/wiki/Dc_%28computer_program%29

Thank you for linking this! Went down a 2-hour rabbit hole and it's really scratching some sort of itch.

Re: What the hell is Forth? (2019)

#130
post #77

I started using Forth because I wanted a Reverse Polish Notation calculator at the command line. It turned out to be very practical and extensible. For example, I created many words to perform unit conversion, such as temperature: : 2fahrenheit 9 * 5 / 32 + ; : 2celsius 32 - 5 * 9 / ; Furthermore, I can even pull in live currency conversion rates from Yahoo Finance to go between USD and CAD. Since my underlying Forth…

Reminds me a bit of dc: https://en.wikipedia.org/wiki/Dc_%28computer_program%29

It is exceedingly terse. Every command is a single character and the only required formatting is a single space to separate numbers. Just this side of line noise...
Post reply on HN