Live data from Hacker News

Forth: The Hacker’s Language

hackaday.com

71–80 of 111 posts

Re: Forth: The Hacker’s Language

#71

I quite like Forth. It feels like a blend of lisp and apl. And even ml if you squint a bit at it as an applicative as composition system. People on reddit seems to hint at the fact that Forth people stay under the radar because it allow them to design and solve problems in better ways. I wonder how true it is ..

The more likely culprit is this: > But Forth is also like a high-wire act; if C gives you enough rope to hang yourself, Forth is a flamethrower crawling with cobras. There is no type checking, no scope, and no separation of data and code. You can do horrible things like redefine 2 as a function that will return seven, and forever after your math won’t work. (But why would you?) You can easily jump off into bad sectio…

> When it comes to working on a large project in a team, I suspect Forth doesn't scale. [...] It's too flexible

If, in any language, flexibility is a problem for a larger team, fire the lead developer. The article does a good joint pointing out that using that flexibility is usually a sign of code smell.

Re: Forth: The Hacker’s Language

#72
post #59

Earlier quoted context omitted.

That's true. And APL and its children is still quite popular in finance. By the way, I found a rather neat page about building a Jupiter ACE: http://searle.hostei.com/grant/JupiterAce/JupiterAce.html

Mentioning APL in this context makes me picture an 8 bit home computer with an APL interpreter. I mean, the C64 had all kinds of weird symbols on its keyboard, too. And the magazines would save quite some pages for their source code listing compared to BASIC...

According to Wikipedia, the first implementation of APL on a micro was on the 8008, in '73. It wasn't very good, but it did run...

Later ('77), TIS APL ran on Z80 systems, and was aparently quite a bit better, although it wasn't a full implementation.

But I'm just quoting Wikipedia at this point, so look it up yourself.

Re: Forth: The Hacker’s Language

#73

Earlier quoted context omitted.

Yeah, but Rust is much more complex than Forth, and really hates baremetal: you can do baremetal in Rust, but it's idiomatic to minimize contact. That works really well in some cases: OS work, for example. But if you're working in a raw microconroller, you're going to be touching metal constantly, and you won't want anything you don't use slowing you down. In short, Rust is great, but it doesn't beat Forth in Forth's…

Not to mention that Rust is not interactive and doesn't allow for dynamic, incremental development. Forth brings the rapid, extremely tight feedback loop one sees in Lisp or Smalltalk to hardware. Comparing it to Rust is missing this point entirely. Finally, let's not forget that Forth has been empirically validated multiple times in this domain (e.g. NASA has used Forth on board satellites and spacecraft). Rust is e…

Good point: I was going to bring this up, but I already had in another post, and I didn't think anybody who wanted rust on their hardware wouldn't care, as they quite clearly liked compiled languages.

But this is a huge draw for Forth, speaking as a Lisp user.

Re: Forth: The Hacker’s Language

#74
post #24

Earlier quoted context omitted.

Never heard of TIS-100 (you mean http://www.zachtronics.com/tis-100/ ?)

Worth playing; if you enjoy programming challenges within limited environments, you would be hard pressed to find better games than the Zachtronics set of games.

If I had time to spare, I'd actually order the development board. The architecture is unique and fascinating.

Re: Forth: The Hacker’s Language

#75
post #9

This is a how-to-write-a-FORTH tutorial that I wrote a few years ago. It's particularly nice that you get to see how various control structures are implemented, like IF, CASE and even comments! Part 1: http://git.annexia.org/?p=jonesforth.git;a=blob;f=jonesforth... Part 2: http://git.annexia.org/?p=jonesforth.git;a=blob;f=jonesforth... (github mirror: https://github.com/AlexandreAbreu/jonesforth/blob/master/jon... ht…

I've used jonesforth in the past few weeks as a basis for implementing my own Forth, but for RISC-V (and soon, maybe Xtensa).

It's an excellent codebase; thank you very much! I've changed the design a slight bit so far -- but the vague signature of jonesforth is really still there, I think!

Re: Forth: The Hacker’s Language

#76
post #68

Amen. And it is dead simple to implement. I did it in common lisp 3 years ago for an IRC-bot - a lazy Sunday afternoon and 50 lines of code later I was done. I would not want to write code in Forth on a regular basis, but reading (and making an effort to really understand it) definitely made me a better programmer.

Given, there are a lot of languages that you can implement reasonably easily in CL...

Re: Forth: The Hacker’s Language

#78
post #75
post #9

This is a how-to-write-a-FORTH tutorial that I wrote a few years ago. It's particularly nice that you get to see how various control structures are implemented, like IF, CASE and even comments! Part 1: http://git.annexia.org/?p=jonesforth.git;a=blob;f=jonesforth... Part 2: http://git.annexia.org/?p=jonesforth.git;a=blob;f=jonesforth... (github mirror: https://github.com/AlexandreAbreu/jonesforth/blob/master/jon... ht…

I've used jonesforth in the past few weeks as a basis for implementing my own Forth, but for RISC-V (and soon, maybe Xtensa). It's an excellent codebase; thank you very much! I've changed the design a slight bit so far -- but the vague signature of jonesforth is really still there, I think!

It's donated into the public domain -- please change it, redesign it, and otherwise do whatever you want with it!

Re: Forth: The Hacker’s Language

#79
post #9

This is a how-to-write-a-FORTH tutorial that I wrote a few years ago. It's particularly nice that you get to see how various control structures are implemented, like IF, CASE and even comments! Part 1: http://git.annexia.org/?p=jonesforth.git;a=blob;f=jonesforth... Part 2: http://git.annexia.org/?p=jonesforth.git;a=blob;f=jonesforth... (github mirror: https://github.com/AlexandreAbreu/jonesforth/blob/master/jon... ht…

Working through Jones Forth got me up to speed on both understanding how Forth works and getting my hands dirty with some practical assembly coding.

Once I got a better idea of Forth, I also realized that Jones stays in assembly for rather long. He builds up the entire interpreter from raw assembly words, because you need the interpreter to start parsing textual Forth source. But you if you could somehow write Forth before the interpreter is put together, it would be quite natural to switch to Forth much earlier. And it turns out you can do that. Jones even defines the `defword` macro. But for some reason he makes very little use of it. Rewriting most of the code leading up to INTERPRET using defword was a fun exercise.

The next step would've been making the whole system bootstrapping by rewriting the assembler in Forth, but x86 machine code generation is hairy enough that I bailed out at this point.

Re: Forth: The Hacker’s Language

#80
post #9

This is a how-to-write-a-FORTH tutorial that I wrote a few years ago. It's particularly nice that you get to see how various control structures are implemented, like IF, CASE and even comments! Part 1: http://git.annexia.org/?p=jonesforth.git;a=blob;f=jonesforth... Part 2: http://git.annexia.org/?p=jonesforth.git;a=blob;f=jonesforth... (github mirror: https://github.com/AlexandreAbreu/jonesforth/blob/master/jon... ht…

Working through Jones Forth got me up to speed on both understanding how Forth works and getting my hands dirty with some practical assembly coding. Once I got a better idea of Forth, I also realized that Jones stays in assembly for rather long. He builds up the entire interpreter from raw assembly words, because you need the interpreter to start parsing textual Forth source. But you if you could somehow write Forth…

All fair points. I was reading over it again today thinking that it would have been better to write more of it in FORTH. At the time I was prematurely optimizing I think.
Post reply on HN