Hacker News new | past | comments | ask | show | jobs | submit login

Is it Forth week on HN :-? I like this but only allowing single letter identifiers is an unfortunate choice - although I'm sure it made parsing much simpler.



How strange, I just picked up a book from my bookshelf, my old copy of Starting Forth by Leo Brodie. I was trying to remember if Forth was created by Charles Moore or Calvin Moores. Charles Moore invented Forth.

I really enjoyed reading Starting Forth when it came out. I've used Starting Forth together with Threaded Interpretive Languages: Their Design and Implementation by R. G. Loeliger to create my own Forth system. This second book is not about "threads" as we know them today; threading is a way to very efficiently dispatch the execution of Forth primitives.

Calvin Moores is a language inventor too. I've also implemented a version of his language TRAC. TRAC is mentioned prominently in a book that I really enjoyed while in grad school in the 70's, Computer Lib by Ted Nelson. Described by Wikipedia as the first book on personal computers.

The appeal of Forth, and even more so of TRAC, is that they are very simple languages to implement. It is completely possible to implement either language in assembly language, but C would be a bit easier. As a project to learn Perl, back when it was new, I wrote a TRAC interpreter over a couple of days.

TRAC, like the roughly contemporaneous language GPM invented by Christopher Strachey, is a macro processor. GPM and TRAC are "Turing complete" macro processors. So they can be used to write arbitrary programs and are in fact designed for this purpose.

Some links/references:

Leo Brodie, Starting FORTH : an introduction to the FORTH language and operating system for beginners and professionals, Prentice-Hall, 1987. https://www.forth.com/starting-forth/

Martin Campbell-Kelly, Christopher Strachey, 1916-1975: A Biographical Note, IEEE Annals of the History of Computing, 1985, https://www.computer.org/csdl/magazine/an/1985/01/man1985010...

R. G. Loeliger, Threaded Interpretive Languages: Their Design and Implementation, BYTE Books, 1979, https://www.abebooks.com/servlet/BookDetailsPL?bi=2253615473...

Calvin Moores, TRAC, A Procedure-Describing Language for the Reactive Typewriter, CACM Vol 9, Num 3, March 1966, https://dl.acm.org/doi/10.1145/365230.365270

Ted Nelson, Computer Lib/Dream Machines, self-published, 1974, https://en.wikipedia.org/wiki/Computer_Lib/Dream_Machines


> It is completely possible to implement [FORTH] in assembly language

I know because I did :-) https://news.ycombinator.com/item?id=10187248


Me Too - For OS/2, and it was direct threaded code

https://sourceforge.net/p/forth2/wiki/Home/


I also wanted to say thank you for Jonesforth. Using it as a guide while implementing a Forth in 6502 assembly is the most fun I've had programming.


Thanks for that by the away. It's an amazing educational resource.


Speaking as somebody who submitted a couple of Forth links (but not this one) - I saw there were two Forth related links on the front-page at one point yesterday, was reminded of the famous "Erlang Day" incident in HN history and thought "wouldn't it be cool if HN were flooded with Forth links for a little while?" and submitted a couple. Can't speak for anybody else, but I'm guessing other people had a similar reaction.


These things tend to happen on HN - someone discovers something new or new to them and posts something and triggers others to read up on the subject and/or reminds people of related projects, and suddenly you have a slew of submissions about similar things.


Hey, I'm glad you like it! I liked Jonesforth a lot, and SKF's predecessor tokthr was derived from Jonesforth: https://github.com/kragen/tokthr/blob/master/tokthr.S

IIRC the reason I only allowed single-byte identifiers was to simplify the symbol table, which is implemented by these four lines of code:

    : Type Four* header 6144 + + ; ( Table of definition Types: 1=code, 2=data )
    : Addr Type 1024 + ;     ( table of definition Addresses )
    ( register a colon definition )
    : Colon %flush dup Type 1 xchg !  HERE @ xchg Addr ! ;
    ( register a variable definition )
    : Var   %flush dup Type 2 xchg !  HERE @ xchg Addr ! ;
Abbreviating this as follows would clearly be highly immoral, so I would never do that:

    : T F h 6144 + + ; : A T 1024 + ; : C % d T 1 x ! H @ x A ! ; : V % d T 2 x ! H @ A ! ;
"Parsing" is kind of the same as it would be if more bytes in the name were significant, because the other bytes in the name are still there in the source and the compiler still has to skip them:

    : word getchar dup Isdigit [ ; ] dup '' = [ ; ] dup 0 1 - = [ ; ]
      { Getchar dup '  = [ pop ; ] dup 10 = [ pop ; ] 0 1 - = [ ; ]  1 } 
What's simpler is that it doesn't have to store them anywhere, or implement any kind of string compare operation, and consequently doesn't use C@, and consequently doesn't have to implement C@ either. It implements @ and ! and C! (which it calls "store"; I should have called it "c!" since capital "C" was already taken for "colon"). It needs C! ("store") for emitting sub-word-length instructions and at any rate for backpatching jumps.

It's definitely a questionable choice, though! I think it might be worth using two significant letters instead of one for a "tiny boot FORTH".

Traditional FORTHs, you probably recall, used a fixed-size four-byte "name" in their dictionaries: a length byte and the first three letters of the name. Chuck Moore received some criticism for this choice, in response to which he wrote a letter to a popular FORTH magazine arguing, effectively, that thr-- let---- was ade----- to tel- wor-- apa--; col------- bet---- wor-- wer- suf--------- rar- wit- the fir-- thr-- let---- bei-- sig--------, and of cou--- it was mor- eff------. FTP and SMTP commands are all four letters long for the same reason.


Yeah I wonder what propped this flood of Forth threads. Not that I'm against it.. just a bit odd.


Well, not all the hackers have yet been driven from "Hacker News" yet, I guess. Where there are hackers, there will be FORTH — as Devine Lu Linvega said, "Lisp is a slippery slope that leads inevitably to FORTH." DSSP was an independent Soviet invention (on a balanced-ternary machine!) but its differences from ANS FORTH are smaller than the differences between Moore's early text interpreters and polyForth or ANS FORTH.

FORTH's a bit of an occupational hazard of hacking, you might say. Like suicide, or being burned at the stake. (It's been two days since the anniversary of Giordano Bruno being burned at the stake for being a hacker, though he was too early to write a FORTH himself.)


Are you still stuck in a basement ?


No! I remodeled the basement, picked the lock, hopped a freight train, and married into the gentry years ago. Since then, I've founded a company, been betrayed by my closest friends, written a book (which turned out to be unreadable), set myself on fire repeatedly, violently subdued villainous bandits, fallen in love with beautiful women, broken their hearts, had my heart broken by them, and digitized the Oxford English Dictionary.

I've read through ancient, forgotten books in faraway lands; I've learned strange tongues and seen fortunes won and lost; I've comforted the grieving, and I've restrained deadly robots as they wriggled to escape my grasp.

I've comforted the suicidal, and I've broken the trust of those who placed their hopes in me.

After midnight, I danced in the moonlight with a beautiful Brazilian as we stood guard outside her now-demolished ecovillage; she told me she'd thought she'd lost the ability to fall in love. We didn't need any music.

I've studied at the knee of wise elders, meditated in monasteries, translated poetry, and embraced madmen who predicted my demise in their psychotic ravings.

I've made foolish mistakes whose consequences maimed those I loved, and I've averted catastrophe innumerable times.

And most of that is even true.

Thanks for asking! I hope you're doing well too :)


Too much? I've been posting things I think other people might find interesting while researching implementing a Forth compiler after having just done a Scheme.


Take it easy, I'm not complaining at all. It is interesting. It's just odd (nothing more), like 5 articles on Forth the same day.

Think running into 5 kangaroos in a row in NYC.


Don't worry, can't have too much Forth (or Scheme for that matter).


or scheme in forth


That'd be my next project if I complete this one to my satisfaction.




Consider applying for YC's Spring batch! Applications are open till Feb 11.

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: