Live data from Hacker News

Writing a Forth in Haskell

reinvanderwoerd.nl

31–40 of 55 posts

Re: Writing a Forth in Haskell

#31
post #24

Earlier quoted context omitted.

Thank you as JonesForth keeps getting hard to find. Any chance you will ever do an even more in-depth tutorial? Put it on lulu and I will buy. I'd like to write my own Forth, but need a bit more handholding.

If the tutorial is hard to find, please feel free to clone it on the git sites of your choice. In depth: Likely not. I've actually been working on another literate language tutorial (completely unrelated to FORTH), so ... watch this space (or my blog).

Good advice...yea I remember you saying you weren't using Forth anymore a year ago. What new language are you looking at?

Re: Writing a Forth in Haskell

#32

Earlier quoted context omitted.

"It will also be the most fun you've had with a computer in a long time and it will likely make you look at the rest of what we do with computers as clunky in the extreme." Double true if one looks at the hardware and software Chuck Moore makes with it.

Can you tell me the link?

http://www.ultratechnology.com/cowboys.html

Re: Writing a Forth in Haskell

#33
post #20

https://github.com/anse1/firmforth has not been mentioned on hn afaik.

The very neat part about firmForth is that if you compile the firmForth JIT with cparser (libfirm compiler), it can inline C functions into the JITted code.

Re: Writing a Forth in Haskell

#34

Earlier quoted context omitted.

"It will also be the most fun you've had with a computer in a long time and it will likely make you look at the rest of what we do with computers as clunky in the extreme." Double true if one looks at the hardware and software Chuck Moore makes with it.

Can you tell me the link?

http://www.greenarraychips.com/ is his current company, mostly notable for extremely low-power chips using asynchronous circuits (i.e. there's no central clock). IIRC he develops the CAD software he uses to design chips on his own chips.

Re: Writing a Forth in Haskell

#35
post #3

Doesn't really give Forth the credit it deserves. Totally misses the point of Forth: the simplicity of the environment and it's relationship to the underlying hardware, defining primitives like : and VARIABLE with CREATE and DOES>, threaded code, , (COMMA) , ... Nice promotion of Haskell though

You're right of course, this is an ongoing exploration. I hope to learn the deeper truths in the process.

If you can get DOES> working, you really understand how Forth works. I have a toy Forth implementation where I got DOES> working, and I still have a hard time understanding how I got it working.

Re: Writing a Forth in Haskell

#36

Earlier quoted context omitted.

Modern CPUs are optimized for C code. This is not the fault of FORTH, but it certainly is a problem for its adoption.

Not really, modern Lisps have done a fine job optimizing performance. FORTH suffers from treating the hardware too granularly, and thus not being able to take advantage of any of the advances in hardware in the last 2 decades.

There is no a priori reason FORTH can't take advantage of modern hardware, since in the extreme case the compiler can be completely replaced by redefining the meaning of ':' and ';'.

Re: Writing a Forth in Haskell

#37
post #2

Surely you just take an existing LISP implementation and call "reverse" at the correct location in the code? :p

Forth uses a stack machine. In this way, since calls to functions are really simple and easy, higher performance can be achieved.

I love Lisp, but what you suggest is not really Forth and will also not give you the performance benefits and simplicity of implementation that Forth has.

Re: Writing a Forth in Haskell

#38
post #7

Earlier quoted context omitted.

I would suggest re-doing the exercise on an 8 bit cpu with < 8 K of RAM. That will open your eyes to what is so special about Forth.

I'm curious about Forth, as it's probably the most important language I've never learned. I've done a fair bit of low-level, micro-optimised coding in C and assembly, but don't get much time for that kind of thing these days. How would you describe Forth in relation to those? What makes it stand out and what are its weaknesses?

Last time i did some coding in forth, it was Fig-Forth on the 8-bit Atari 800XL. It was really fun and I was amazing on how fast it could run despite being in such limited hardware.

I would say Forth is easier to use than assembly, and perhaps much more flexible/extensible than C, although in some senses lower level since C gives you a very nice, ordered way of specifying what are the arguments to your functions/etc.

Re: Writing a Forth in Haskell

#39
post #24

Earlier quoted context omitted.

If the tutorial is hard to find, please feel free to clone it on the git sites of your choice. In depth: Likely not. I've actually been working on another literate language tutorial (completely unrelated to FORTH), so ... watch this space (or my blog).

Good advice...yea I remember you saying you weren't using Forth anymore a year ago. What new language are you looking at?

The new language is also a toy, but it's based on SML, Lisp and others.

Re: Writing a Forth in Haskell

#40
Can anyone point me to a Forth implementation where the absolute bare minimum is written in (C/assembly/whatever) and everything possible is then bootstrapped in Forth itself?

I recall reading what the minimal word set needed to be able to write the rest of standard Forth (Fig Forth if I recall) but I seem to remember that most implementations don't push the purity quite that far for performance reasons.

Post reply on HN