3 ms·
Forth must be lightning fast albeit single-threaded... has there been any work on a multithreaded Forth? Compiling to BEAM VM might be an option for (not fast)
by pmarreck 8y ago
Forth must be lightning fast albeit single-threaded... has there been any work on a multithreaded Forth? Compiling to BEAM VM might be an option for (not fast) implementation...
- madhadron 8y agoConsidering that some Forth implementations were custom hardware that directly implemented the language semantics, it was often quite fast, yes. Most of the bigger Forth systems (gForth, WinForth, BigForth) have some form of threading/task management. The smaller ones, which are often the ones expecting to run natively on microcontrollers with no operating system, expect you to write your own if you need it.
- tdeck 8y agoIt seems it's supported in some FORTHs: https://stackoverflow.com/questions/32736552/does-forth-support-multithreading https://stackoverflow.com/questions/32736552/does-forth-supp... Also of interest - Chuck Moore's* current work is on such a parallel architecture ASIC that uses FORTH: http://www.greenarraychips.com/ http://www.greenarraychips.com/ *Chuck Moore is the creator of FORTH
- rwmj 8y agoA naive (ie. threaded[1]) Forth implementation will be slow because the jump between each instruction is a very effective way to defeat branch prediction. Of course this doesn't apply to "real Forth" which is compiled into machine code or even less naive Forths which can do inlining, but there are many hobbyist Forth implementations (because they're so easy to write) where this will still be true. If you're interested I wrote a naive literate Forth implementation which can do inlining: http://git.annexia.org/?p=jonesforth.git;a=blob;f=jonesforth.S http://git.annexia.org/?p=jonesforth.git;a=blob;f=jonesforth... http://git.annexia.org/?p=jonesforth.git;a=blob;f=jonesforth.f http://git.annexia.org/?p=jonesforth.git;a=blob;f=jonesforth... [1] "Threaded" in this sense means https://en.wikipedia.org/wiki/Threaded_code https://en.wikipedia.org/wiki/Threaded_code not multithreading.
- gmfawcett 8y agoI've always meant to thank you for publishing jonesforth. I learned so much from it. (I can't believe it's been nearly ten years now!) It's a beautiful example of literate programming. Knuth would be proud, I think!
- arethuza 8y agoNever used Forth much, but did use NeWS which had a multi-threaded PostScript environment - which was fun.
- yiyus 8y agoSome years ago, I ported ngaro (the retroForth vm) to Go, and made it possible to launch goroutines and use channels. It was very cool. However, it was Go pre-1.0, so it won't work now. For a while, it was maintained by Charles Childers - the original retroForth author - but I do not think the Go version is still available. If you want to give it a try (making it work with the latest Go version shouldn't be difficult), have a look at: https://bitbucket.org/yiyus/ngaro/src https://bitbucket.org/yiyus/ngaro/src
- johnisgood 8y agoHmm, sadly Factor is single-threaded I think (so you are stuck with coroutines), but you can make use of multiple cores using channels.