Personal computing discussed
Moderators: renee, SecretSquirrel, just brew it!
just brew it! wrote:IIRC I tried it very briefly back in the early '80s. It was moderately popular back then, since it is lightweight and can be used interactively from the command line like BASIC. I don't know anyone who uses it for real projects any more; unless you come across a legacy device that happens to use it, I'd say it is more of an academic curiosity these days.
If you've ever used an RPN calculator you'll feel right at home. It is stack-based, so the statement syntax is of the form <operands> <operation>.
whm1974 wrote:Doesn't NASA still use Forth for some things? I thought it still had a niche in space and related projects.
srg86 wrote:I think the biggest user of Forth was OpenFirmware. That was used as the "BIOS" on various RISC based machines, including New World PowerPC Macs. I'm not sure who still uses it though, especially since Apple switched to Intel and EFI.
I'm also not sure how much of it was written in Forth, maybe just the Shell?
whm1974 wrote:I was checking the RISC-V guys again and notice that gForth and several kernels written in Forth are available. gForth is also available for x86 Linux and Windows, as well as ARM platforms such as the Raspberry Pi.
It would be nice to write portable code that can at least be compiled to common platforms without modification.
just brew it! wrote:whm1974 wrote:I was checking the RISC-V guys again and notice that gForth and several kernels written in Forth are available. gForth is also available for x86 Linux and Windows, as well as ARM platforms such as the Raspberry Pi.
It would be nice to write portable code that can at least be compiled to common platforms without modification.
The issue isn't so much the portability of the code; C/C++, Python, Java, and many other current languages are portable, in the sense that properly written code will run on many different platforms and architectures (the ones you listed above and many more) without source code modifications. The problem for real-world use is the portability of the APIs and libraries that allow you to talk to the underlying OS to get actual work done.
I have not looked at recent Forth implementations, but I would be willing to bet that it is no better (and probably worse) than other more popular languages in terms of the APIs it exposes and portability of the interfaces.
Just to give one example... is there a portable way to write multi-threaded code in Forth? (Not sure, I'm leaving this as an exercise for the reader.)
notfred wrote:Only Forth I've done was Sun SPARC OpenBoot. I really don't like RPN.
just brew it! wrote:Not sure why you think you'd need to learn assembly. In any case, that definitely would not be portable!
whm1974 wrote:just brew it! wrote:Not sure why you think you'd need to learn assembly. In any case, that definitely would not be portable!
Wouldn't I need to write some part of the kernel in assembly for each platform if I was trying to write a portable OS?
just brew it! wrote:whm1974 wrote:just brew it! wrote:Not sure why you think you'd need to learn assembly. In any case, that definitely would not be portable!
Wouldn't I need to write some part of the kernel in assembly for each platform if I was trying to write a portable OS?
Ahh, thought you were replying to my multithread comment.
Yes you would need to know some assembly to write an OS kernel. You might be surprised how little assembly is in the Linux kernel though! It is nearly all C.
whm1974 wrote:I think the hardest part of learning Forth is having to learn RPN at the same time as well.
Vhalidictes wrote:Wow, Forth. On that note I'm pretty sure I still have a working Commodore 128. I didn't find that the compact code / keystroke savings was worth the additional mental effort, but my coding days are long done.
Pancake wrote:Vhalidictes wrote:Wow, Forth. On that note I'm pretty sure I still have a working Commodore 128. I didn't find that the compact code / keystroke savings was worth the additional mental effort, but my coding days are long done.
Sweet. I have a probably working frame grabber for a C128 but no longer a C128 to plug it into.
whm1974 wrote:Well it looks like quite a few games were written in Forth such as Starflight:
https://en.wikipedia.org/wiki/Starflight
Now I'm wondering if we could do modern game development in Forth and use the SDL and Vulkan APIs?
just brew it! wrote:whm1974 wrote:Well it looks like quite a few games were written in Forth such as Starflight:
https://en.wikipedia.org/wiki/Starflight
Now I'm wondering if we could do modern game development in Forth and use the SDL and Vulkan APIs?
Probably not without a lot of additional effort to write wrapper APIs that are compatible with Forth. And in the end performance would probably suffer relative to a native C++ implementation, since I imagine there would be some computational cost to convert the data structures back and forth in the wrapper layer.
whm1974 wrote:just brew it! wrote:whm1974 wrote:Well it looks like quite a few games were written in Forth such as Starflight:
https://en.wikipedia.org/wiki/Starflight
Now I'm wondering if we could do modern game development in Forth and use the SDL and Vulkan APIs?
Probably not without a lot of additional effort to write wrapper APIs that are compatible with Forth. And in the end performance would probably suffer relative to a native C++ implementation, since I imagine there would be some computational cost to convert the data structures back and forth in the wrapper layer.
Yeah unfortunately you are probably right. I wonder if someone(s) who mastered Forth very well could implement SDL and Vulkan in native ANS Forth?
just brew it! wrote:whm1974 wrote:just brew it! wrote:Probably not without a lot of additional effort to write wrapper APIs that are compatible with Forth. And in the end performance would probably suffer relative to a native C++ implementation, since I imagine there would be some computational cost to convert the data structures back and forth in the wrapper layer.
Yeah unfortunately you are probably right. I wonder if someone(s) who mastered Forth very well could implement SDL and Vulkan in native ANS Forth?
I can't imagine there's any commercial demand for that, so it would have to be someone as crazy as you are, who also understands Forth, SDL, and Vulkan, and has enough time on their hands to be willing to tackle it as a hobby project.
whm1974 wrote:Oh well I do have plenty of time on my hands, at least I would pick up some useful skills along the way.
just brew it! wrote:whm1974 wrote:Oh well I do have plenty of time on my hands, at least I would pick up some useful skills along the way.
They'd be even more useful if they didn't involve Forth.
Interviewee: ...and I wrote a wrapper library for the entire Vulkan API...
Interviewer: <looks at interviewee intently>
Interviewee: ...to support games written in Forth.
Interviewer: Forth? Isn't that one of those obsolete languages like Fortran? OK, this interview is over... we'll let you know. The receptionist will see you out.