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.
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
by throwaway7645 on Thursday June 08, 2017 @06:54PM
(#14517801)
This is why Chuck Moore designed his own chips like GreenArrays I believe. There is no impedance mismatch between software and hardware and the entire thing is optimized for the problem domain and massively parallel. I'm sure you can get more speed out of C, but it no other language (even Lisp or Smalltalk) can the user understand the entirety of the system. Lisp machines and Smalltalk machines probably are about as close as possible, but I have zero experience with them personally. Perhaps the project to put PicoLisp on bare-metal qualifies if one uses a simple enough microcontroller as the language itself is about as simple as you can get a practical lisp.
Over the last twenty years or so, I have written serious Forth code generators for six CPU architectures. There's only one code generation algorithm that's not regularly present in most Pasgol family compilers. The results are the VFX Forth systems at http://www.mpeforth.com.
Re:Writing a Forth in Haskell
by Karrot_Kream on Friday June 09, 2017 @01:28PM
(#14522858)
I've looked over your products over the years and been super impressed by your results. Thanks for all your hard work!
Re:Writing a Forth in Haskell
by Karrot_Kream on Thursday June 08, 2017 @05:31PM
(#14517345)
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.
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.