Live data from Hacker News

Writing a Forth in Haskell

reinvanderwoerd.nl

11–20 of 55 posts

Re: Writing a Forth in Haskell

#11
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?

Forth is probably the smallest true high level language there is. It is entirely self-contained, needs just about nothing in terms of hardware support and can run in as little as 2K of memory.

It is well suited to things like real-time control, you'll probably have a hard time getting used to stack manipulation (especially in the beginning) and it tends to keep you up all night (not sure if that is a strength or a weakness ;) ).

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.

What Forth is not really suitable for is large projects and things built with a team. It is more of an artisanal thing, something closer to watchmaking or jewelery than major construction.

If you want to know more about why Forth is the way it is you could do worse than to start with studying the life of Chuck Moore for a bit, the language and its author are roughly equally interesting and for want of a better word peculiar.

One thing Forth is not: wasteful.

Re: Writing a Forth in Haskell

#13
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?

In addition to other comments:

Forth is a really cool language, but has the pitfall of trading time for space. It's a very lean language, and incredibly dynamic, but its heavy reliance on jumps makes it run slowly on modern hardware and thrashes most branch predictors.

Re: Writing a Forth in Haskell

#14

Earlier quoted context omitted.

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?

Forth is probably the smallest true high level language there is. It is entirely self-contained, needs just about nothing in terms of hardware support and can run in as little as 2K of memory. It is well suited to things like real-time control, you'll probably have a hard time getting used to stack manipulation (especially in the beginning) and it tends to keep you up all night (not sure if that is a strength or a we…

Read Chuck talk about OKad...when the hardware wasn't to his liking he built his own chips...after writing his own CAD software in only like 5k loc that runs waay faster than traditional CAD software and uses almost no resources.

Re: Writing a Forth in Haskell

#15

Earlier quoted context omitted.

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?

In addition to other comments: Forth is a really cool language, but has the pitfall of trading time for space. It's a very lean language, and incredibly dynamic, but its heavy reliance on jumps makes it run slowly on modern hardware and thrashes most branch predictors.

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

Re: Writing a Forth in Haskell

#16
post #10
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.

One good place to look for that is " rel="nofollow">http://git.annexia.org/?p=jonesforth.git;a=summary> , previously discussed at " rel="nofollow">https://news.ycombinator.com/item?id=942684> .

Thanks for the links, had not seen this before.

(though your links are slightly broken)

Re: Writing a Forth in Haskell

#17

Earlier quoted context omitted.

In addition to other comments: Forth is a really cool language, but has the pitfall of trading time for space. It's a very lean language, and incredibly dynamic, but its heavy reliance on jumps makes it run slowly on modern hardware and thrashes most branch predictors.

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.

Re: Writing a Forth in Haskell

#18

Earlier quoted context omitted.

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?

In addition to other comments: Forth is a really cool language, but has the pitfall of trading time for space. It's a very lean language, and incredibly dynamic, but its heavy reliance on jumps makes it run slowly on modern hardware and thrashes most branch predictors.

The branch prediction problem is true for every language that doesn't JIT (pronounced: "cheat"). Furthermore, Forth is not limited to threaded code. You can have some simple code generation (subroutine threaded code+some primitive inlining) if you really want to prioritize speed. Finally, Forth is a simple language with simple implementations so it's often easy to add the primitive(s) you need in order to deal with the bottlenecks.

Re: Writing a Forth in Haskell

#19

Earlier quoted context omitted.

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?

Forth is probably the smallest true high level language there is. It is entirely self-contained, needs just about nothing in terms of hardware support and can run in as little as 2K of memory. It is well suited to things like real-time control, you'll probably have a hard time getting used to stack manipulation (especially in the beginning) and it tends to keep you up all night (not sure if that is a strength or a we…

I remember writing a fairly trivial program in Forth on a ZX81 for a school open day. You needed the 16K RAM pack thing with the usual lump of Blu Tac to stop it wobbling.

When I "discovered" Forth, it seemed like science fiction (soo fast!) to me after BASIC juddering around the screen.

Post reply on HN