Live data from Hacker News

Forth: The Hacker’s Language

hackaday.com

101–110 of 111 posts

Re: Forth: The Hacker’s Language

#101
post #93

Earlier quoted context omitted.

When I used Scratch 1.4, I don't recall the UI being too bad, and it ran pretty fast: Smalltalk is pretty good at that. But I'm generally pretty good at picking up these sorts of things, and my computer wasn't particularly slow. If you want a Real Language presented the same way, Snap! (descended from BYOB) is essentially a Scheme in Scratch's clothing. But the two real draws of Scratch were its hackability and its c…

Ah, I encountered Scatch 2.0. I'll definitely check 1.4 out, it looks a lot more accessible and reasonable. I would have loved to have encountered something like this at 14 or 15. I suspect the reason Scratch felt slow to me is that 2.0 is some kind of HTML5 and/or Flash mess now - you're right, Smalltalk is really fast. I spun up Squeak to check something on this T43 yesterday, and everything was really snappy. I ha…

>Also, I wouldn't be surprised if a reasonable bit of the exploration everyone did was motivated by the fact that they were "hacking" the platform :P

Nor would I. Even at the age of 8, before I was really able to understand the code, there was a thrill to it, in a cracking-open-the-toy kind of way.

And it helps that Smalltalk does exploration better than just about any other language/environment. You can just open up any Smalltalk app and extend/take it apart using the same tools the developers did to build it.

>There seems to be a sad lack of excellent online communities nowadays; I've long looked for sites to complement HN, but without success.

Lainchan (a sort-of cyberpunk/whatever chan) is quite popular with some of the people who are here on HN. It's a very different atmosphere, but it does emphasize actual good discussion. And it's got a containment board for politics, which always helps.

At the very least, their magazine (https://lainzine.neocities.org) is worth looking at, if not for the generally interesting articles, than for the outright strangeness of a lot of it.

Re: Forth: The Hacker’s Language

#102
post #21

Things you can do with forth, from the forth author: http://www.greenarraychips.com/ which is actually a truly message-passing based arch with 144 clockless "cpus". Each cpu is actually so limited that forth is one of the few languages that makes programming this tricky platform viable.

I'd love to think of something to do with GreenArrays, although AFAICT they're kinda dead. The idea is fascinating, but I honestly don't know what I would use it for.

Re: Forth: The Hacker’s Language

#103
My first program was written in FORTRAN IV and it compiled and ran in the summer of 1967. After that, I learned APL, Z80 assembly, and BASIC.

The August 1980 issue of BYTE magazine was all about FORTH. I read it cover to cover, then sent to the Forth Interest Group for a copy of the implementation guide and the 8080A listing of Forth.

I typed it all in, including comments but changed the 8080A mnemonics to Z80 mnemonics. After the typos were corrected and the I/O routines modified to run under TRSDOS it ran as advertised. Then I optimized the code for Z80 which made it both smaller and faster.

My job then took me from Tandy's manufacturing plant to the R&D department where I wrote assembly code for another product but continued to work on Forth as a side project. Management said that they would be willing to release it as a product if I could get a signed statement declaring Fig-Forth to be in the public domain. I tried repeatedly to get people at the Forth Interest Group to sign but was never successful. This is the reason Radio Shack never released Forth, though many people in R&D used my code internally. They especially liked the ease of number base conversion.

From Tandy, I went to an industrial equipment manufacturer where I wrote a lot of assembly for embedded applications. I ported CP/M to run on TRS-80 model 12. The need arose to read input from a graphics tablet via serial, process the input and output a bitmap. My estimate on the length of time it would take to write this for the CP/M machine extended past the deadline.

I combined my Forth code with the drivers for the Model 12. The boot procedure for Model 12's consists of reading 26 128-Byte sectors from Track 0, Side 0 into memory and jumping to the loaded code. I changed to format of the remaining tracks (both sides) to 9 1K sectors and a 256 byte sector (double density). My boot code prompted to press the F1 or F2 key, then read all the 256 byte sectors on side 0 or side 1 (depending on F1/F2) into memory. I added a FSAVE word which wrote memory to the 256 byte sectors. I had a Forth operating system. I wrote the code for the application in Forth, performed the necessary scanning and conversion and output the desired bitmap with time to spare.

I highly recommend learning assembly for at least one processor. Without it, you can only know about Forth, you don't really know Forth. I understand how directly threaded code (DTC) works but I prefer the indirectly threaded code (ITC) model of Fig-Forth as it seems more elegant to me.

I still have an x86 machine running Windows XP which will run the 16-bit code but it will not run on my Windows 7 system. I am looking at ciforth [1] which is a 32-bit implementation. I intend to get it running under Windows 7.

Forth is a really good system for a command line environment. As far as readability goes, the code itself has such high information content that it is difficult. It is up to the programmer to add abundant comments which make reading the code unnecessary in most cases.

I'll conclude with a Forth joke:

: Decompose ROT ROT ROT ;

Re: Forth: The Hacker’s Language

#104
post #93

Earlier quoted context omitted.

Ah, I encountered Scatch 2.0. I'll definitely check 1.4 out, it looks a lot more accessible and reasonable. I would have loved to have encountered something like this at 14 or 15. I suspect the reason Scratch felt slow to me is that 2.0 is some kind of HTML5 and/or Flash mess now - you're right, Smalltalk is really fast. I spun up Squeak to check something on this T43 yesterday, and everything was really snappy. I ha…

>Also, I wouldn't be surprised if a reasonable bit of the exploration everyone did was motivated by the fact that they were "hacking" the platform :P Nor would I. Even at the age of 8, before I was really able to understand the code, there was a thrill to it, in a cracking-open-the-toy kind of way. And it helps that Smalltalk does exploration better than just about any other language/environment. You can just open up…

Wow, nice! At 8 (1999) I was given a probably-6-or-7-year-old 286 running DOS 3.3 with nothing on it. That got swapped for an XT a couple years later, which I discovered Qbasic on and got tangled up in for way too many years :S. Smalltalk would have been awesome to discover at that age, moreso a toy with sekret doors and passages in it for me to discover :D

I was recommended Lainchain a couple months ago, actually, but nobody mentioned the magazine, which is really cool. I am not impressed that the ASCII art generation paper in Vol.1 has any associated source code!! The rest of the magazine content and design is really interesting too.

Re: Forth: The Hacker’s Language

#105
post #80

Earlier quoted context omitted.

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.

Have you ever considered a revisit?

Re: Forth: The Hacker’s Language

#106

I really, really wanted to like Forth. I love learning new languages and different paradigms from those I know already. The fact that Forth was really tiny and yet very powerful and could do meta-programming in a Lisp-like way (though I hadn't yet learned Lisp at the time to fully appreciate what this meant) was also very attractive. Unfortunately, learning Forth was a real let down. Forth turned out to be way too mu…

Have you looked at Clojure? It's a modern Lisp that feels designed to be simple, yet powerful. It works on the JVM/.NET/JavaScript platforms, so it's reach is almost universal.

https://clojure.org/

https://clojurescript.org/

Re: Forth: The Hacker’s Language

#107
post #26

Earlier quoted context omitted.

> Forth is the only one in which this is possible. Every other example I've seen always uses C for "low-level" access or a libraries. If you need to do that, then you won't win over embedded devs like me. Not really. https://www.mikroe.com/mikrobasic/ https://www.mikroe.com/mikropascal/ http://www.astrobe.com/default.htm http://www.adacore.com/gnatpro/embedded http://www.ptc.com/developer-tools/apexada http://www.ghs…

Is there any reason he would have heard of those? They're all pretty fringe, arguably moreso than Forth, for some of them. Some of these do look neat: I've had an interest in both Ada and Oberon, although I haven't been able to get over the verbosity and unpleasant syntax of either (it's not COBOL, or anything, but it's not nice). OTOH, I am immediately suspicious of any product that claims it's professional and also…

For decades the primary language used in the HP instrument world (everything from controlling power supplies to logic analyzers to medical instruments) has been HP Basic. Very professional stuff indeed.

Re: Forth: The Hacker’s Language

#108
post #99

Earlier quoted context omitted.

For what it's worth, after a bit of research [1], I discovered Commodore Basic 2.0 had simple FOR loops (which I think I used and forgot), and the ability to create functions which encode a single one-variable mathematical expression (which I don't think I ever knew about). [1] https://www.c64-wiki.com/wiki/DEF

I've heard the BBC BASIC was quite a lot better, but I've never worked in it myself...

I forget what the name was, but I used a Microsoft Basic on the IBM PC platform a few years later which was light years better than the C64 Basic. Still gave it up ASAP after learning C, mind you.

Re: Forth: The Hacker’s Language

#109
post #60

Just saw recently that the classic FORTH tutorial is available online: Starting FORTH — Online Edition: https://www.forth.com/starting-forth/ I had read it and played around with FORTH on a microcomputer some years ago. Fun language. Thinking FORTH, a more advanced book, also by Leo Brodie, is also linked to from the above URL.

Amazing book. This is what got me started in implementing my own FORTH in the early 1980s.

Cool.

Re: Forth: The Hacker’s Language

#110
post #70

Earlier quoted context omitted.

Ada isn't a dynamic language, so it doesn't really apply here; you don't get to use it in the ways like Forth; like having a boot ROM with an Ada REPL (laugh). Of course there are other systems programming "monolithic executable" programming languages that allow straightforward access to memory mapped hardware registers.

Static languages can have REPLs.

They can, but I'm not even sure you'd be able to fit all of Ada's reserved words in a typical boot ROM ;)
Post reply on HN