Forth has been a recognized programming language since the 1970’s. ColorForth is a redesign of this classic language for the 21st century. It also draws upon a 20-year evolution of minimal instruction-set microprocessors. Now implemented on modern PCs, it runs stand-alone without an operating system. Applications are recompiled from source with a simple optimizing compiler.
If Forth is such a simple (low-level) language, why not just use a simple (low-level) language like assembler? And what’s the deal with it self being an operating system? Why do I want an operating system with zero hardware support?
Am I missing something here?
The two main questions are:
What?
WHY???????!!!!!!
Why not? Developers are always like to experiment and do things and discover new things or train themselves in such low level coding. This is obviously of developer interest, and not of a user interest. If you are not a developer, better not reply at all at this story, as this is not intended for plain users who “don’t get it”.
As you might have seen, 68% of the OSNews readers are C/C++ and other advanced-language developers who might find this of interest.
From what I can recall…
Forth is big in the embedded market so if it defines it’s own OS then more power to it for the embedded market. Granted it might not be such a big draw for the personal or business computers but it’s there for a reason.
Also forth is a language that is independant of hardware. So all that really, theoretically, needs to be done is to recompile the forth programs for a different target and it should work. This was you don’t have to recode your program if you did it in assembly for one particular target to another assembly for another target. The main reason for using an computer language really.
I’ve only seen some samples of forth and I must say, I’m glad ‘C’ is more widely chosen on the PC’s. That’s not saying it isn’t capable.
well, Forth is very old and not that popular
The motivation for minimalistic Forth are:
o minimal hardware requirements
o interactive development
o low level language with facilities to perform some really nice abstractions
With a smart terminal, serial I/O, and a block read/write interface to your disk drive, yuo get a higher level interactive environment to hack away at your hardware with.
On 8-bit architectures, you can get the language, editor, and assembler in a system with a footprint of 8K RAM.
It’s got a standard behind it, the environment ports easily, and its a fine system for work on smaller systems.
Chuck Moore works in his own little world, designing chips, designing software to design chips, designing software to design software to design chips. He creates a lot interesting designs, and is always willing to defy convention.
Forth is a mindset that takes a bit to get into, and it’s really not something that you can dabble in casually. Casual looks at it tend to drive people away, but in depth its a pretty neet system that can be built into something very powerful.
I don’t see it quite as some have, esp. the first couple!
Forth isn’t actually that portable. It is no more or less portable than C or C++. In other words it has portability issues to do with the size of an integer for example.
Forth is also NOT an OS. If it is similar to anything it is more like those wonderful BASICs of old where you could simply write and execute code (rather than the source->compile->app->run/debug cycle). In Forth (and indeed old BASICs esp. BBC and QL SuperBASIC as they both had advanced structure constructs such as functions) you write some code and then run it right there and then. The process of designing/writing/testing code is interleaved.
Instead of putting together an enormous app. framework as one huge monolithic structure and then running it you start from the components the system is made of and build up from an efficient library of code that you have constructed and tested as part of the act of programming. Test as you go. ALWAYS test as you go. Modern IDE environments actually make it fairly difficult to test out chunks of code such as a class or individual function.
Forth is also not an OS because (being “low level”*) it exposes the actual structure of the machine to you. You are encourage to build a computer in Forth. You are encouraged to know and decide what the inputs and outputs are.
Chuck has spent a great deal of time unifying the hardware and the software. This happens to be because stack machines are highly efficient compute engines.
Matthew.
*”low level” and “high level” are the 2 most ridiculous concepts EVER invented. There is no such thing. Just different levels of complexity!
“If Forth is such a simple (low-level) language, why not just use a simple (low-level) language like assembler?
Forth is interactive, assembly (Asm) is not. To write in assembly, you must first type and save a source code file, and then start an assembler and run the source code through the assembler to generate object code, as another file. Then you must run the object file to test it. This is slow and tedious, especially when debugging. But to use Forth, you type your source code and then run it immediately in a fast interpreted environment. Using forth is very fluid and quick, far more so than assembly. Research shows that writing in Forth is three to five times more productive than in assembly. Forth can be characterized as an interpreted, stack-based, postfix notation, macro assembly language
“And what’s the deal with it self being an operating system? ”
Compactness, terseness, clarity, coherence, fast learning, mastery, flexibility. Take your pick, or enjoy all of these benefits at once. Imagine if all that you needed to do to modify your current OS on any level was to pop open an editor and start editing, with changes taking effect as fast as you wanted. Think of how much you would learn, how quickly you could improve your system, how you could sculpt it to exactly what you want, the precise configuration down to every character and pixel.
“Why do I want an operating system with zero hardware support?
Forth will run on any hardware, if it is refactored a bit in its hardware specific words. It would be more correct to say that it it has total hardware support.
See: http://dmoz.org/Computers/Programming/Languages/Forth/
I do find other languages like this interesting. I know that Forth is still taught at some Universities ( well, since a year or two ago). I have an HP 48SX pocket calculator that uses a very Forth-like programming language.
First, I’d like to say I very much like the concept of threaded things (words, subroutines etc.). It kind of remind me of those fractal concepts (and it brings a similar power).
Now, I’ve come to think that there are certain classes of problems:
– vector problems, for which the traditional (scalar?) processors are well suited; C is perfect here with its autoincrementing operators, assigments amidst expressions etc.
– complex structure problems, in which you have to deal with parameter passing, context switching etc. Stack machines excell here and stack-based languages (like Forth) simply rule.
Well, life is not perfect and one cannot deal with arrays all the time… so:
1) most processors gained POP/PUSH and even “exchange register with top-of-stack” opcodes, so that they can be more general purpose;
2) Charles Moore et al. also noticed the need for efficient array processing, so they incorporated an index register and XLAT-like (I think!) instructions. His last design (FP21, I believe) is truly impressive, as well as its design process — OKAD. One of the most beautiful projects I’ve seen.
BTW, just to save y’all some time, read the excellent online book “Stack Computers”, by Phillip Koopman.
If I may suggest, despite being just a curious guy, to Chuck Moore, Jeff and all the nice folks at http://www.ultratechnology.com :
1) why not make an FP21 card, just like that old CP/M card by Microsoft? Is it possible at all?
2) I’d like to play with ColorForth, and maybe I do so by getting an old computer to run it… for learning purposes, though, one running on DOS, or emulated DOS in Linux — or even better, natively in Linux — that would be nice! 😉
I’ve always loved forth, it was one of the first languages I ever implemented on my own.
The only niggle I have is why choose red and green – for color blind people like myself, that combination is un-readable.
anywho, love the news about Forth.
bear
If Forth is such a simple (low-level) language, why not just use a simple (low-level) language like assembler? And what’s the deal with it self being an operating system? Why do I want an operating system with zero hardware support?
Am I missing something here?
1) Programmmer effeciency in Forth is close to what you get in much higher level languages like C
2) Computer effeciency is close to assembly
3) Linker / Compiler effeciency is better than modern assembly
The effect of these 3 things is that you can quickly write code (1) that executes quickly and thus can be a core part of the system (2) without many assumptions about a large OS already running (3).
Since forth tends to be higher level forth code is mostly portable unlike assembly.
As for Forth issues on hardware:
1) Microcode tends to be forthish so it often very easy (much easier than in procedural languages) to plug driver support right into the environment
2) Forth work well with virtual environments so you can use virtual hardware (of course then you are back to needing a large OS).
Just when you think it’s dying out, you get a reminder.
Maybe this is the tool Eugenia needs for her modular OS
Wasn’t it Forth that was used to boot the old Macs? What do they use now?
Depending on your definition of an OS determines whether Forth qualifies or not. It offers the most basic of services “out of the box”, whatever that means, especially since it tends to get customized to the application.
That said, it is pretty common for Forth to be the “only thing” running on pieces of equipment, save for perhaps a minimum of BIOS firmware.
jerryobject is correct in talking about the interactivity. Being able to interactively “peek” and “poke” into hardware ports, or setup your interrupt handlers, or whatever can be very powerful. You don’t need to have the entire complexity of your system up and running (necessarily) to develop and debug your routines.
Moore has a snippet of code that he calls his “IDE Driver”, it’s REAL short, mostly because simple IDE is, well, real short. The point is, though, that he could have easily written and unit tested his IDE driver from the Forth command prompt.
Gsc mentions the HP48, probably the penulitmate in horribly powerful calculators. (Well, there’s the 49 now, but anyway).
The RPL language that it uses is very similar to Forth at a glance, it’s a stack based language. And, in truth, the 48 is a remarkable machine to write code on. It’s dev environment is really powerful and you can be really productive with it.
There are dramatic differences between common Forth and RPL, however. RPL is closer to Scheme in many ways than it is to Forth. RPL stands for, FYI, Reverse Polish Lisp.
Also, don’t forget to look at, what is it? OpenBoot? Something like that? Forth kernels for ROM monitors? Sun and Apple both use it (or something like it) in their system firmware.
A new slogan: “Forth! It’s everywhere!”
AFAIK Chuck’s company was called “computercowboys” and he was working on FP32 last time I saw news about him.
FP21 was very impressive design too – 21 bit registers was a real shock for unprepared. Does anyone know what happened ?
To datako:
Forth is used to boot Suns. It’s called OpenBoot. If you drop to “ok” prompt you can play with it there.
Forth is a tool, just as any programing language or OS is. While most of my production coding is done with C, C++, JAVA or task specific tools, I maintain a library of Forth kernels for just about every microprocessor ever shipped – back to to 8008 and TI9900. Why? Simply because it is the best tool for some jobs. I design a lot of instrumentation where the basic Forth kernel occupies maybe 4k of ROM. In that 4k I have all the processor-specific code necessary to interface with a rudimentary BIOS for console io, a compiler to allow me to develop test routines to quantify the instrument as development procedes as well as defining performance parameters to pass on to developers for further programming. Some instrumentation goes out the door with this same Forth kernel, others with a replacement based on information gained from the test bed.
Again, why? Because I can not find a better tool for initial testing and development of custom hardware. Even the minimalist assembler user requires a separate machine to develop code which is then transfered to a new device. With Forth, I can tweek the device in the field with no outside support. Given a reasonable amount of flash memory I can include an assembler, a text editor, performance recording code, and most of the common utilities I need repeatedly. Any or all of this code can be re-written on the fly and new procedures inserted as needed, including bare metal level hardware interfaces.
Do I like Forth? Not especially as I find RPN a roysl psin to work with. I would certainly not want to develop major user interface systems in Forth, although some years back a company I worked with did ship a precursor to today’s laptops with a full manufacturing quality control app in Forth. I still ship it when the system is likely to need extensive field customization. Like any other tool, I find it to simply be the best solution for some situations. As for functionality, I’ve seen muli-user, multi-process systems built with it that rival any current OS – all on a lowly 8085 clone with 64k of RAM. That alone should demonstrate its potential.
Thanks Vlad.
Will re: “…As for functionality, I’ve seen muli-user, multi-process systems built with it that rival any current OS – all on a lowly 8085 clone with 64k of RAM…”
This stuff is fascinating – is there anywhere we can download such stuff to play with? (or is it expensive proprietary code)
Yes, OpenFirmware uses a Forth-ish language. It boots Suns, PowerMacs (before and after iMac) and I think some RS/6000.
ficl (Forth Inspired Command Language) also used to boot FreeBSD, GForth also available for download to play with, here: http://www.gnu.org/software/gforth/gforth.html
and another implementation here: http://pfe.sourceforge.net/
I have not enjoyed the current operating systems at all… I find that I enjoy the older ones ALOT more… considering the programming course I am taking at my school is BASIC(I enjoy programming in BASIC more so than in C/C++ but am capable of both) and I have read some people comparing it to BASIC I may try it out…. seams like it could be a great learning tool for those interested in low-level things…
http://forth.org has many Forth resources.
For Windows, Win32For is quite full featured. If you prefer a DOS based Forth environment, Tom Zimmers FPC is *excellent*.
re: This stuff is fascinating – is there anywhere we can download such stuff to play with? (or is it expensive proprietary code)
I suppose some of it is proprietary. A lot was based on concepts from taken from PolyForth circa 1980 and I’m sure I still use some of their code in the assemblers, etc. although I switched most of it over to fig-Forth over the years as it remained alive (still is). The multiuser/multitasking code was developed for a company long since buried by time but given the number of lawyers around today I am loath to openly distribute the sources.
To play cheaply, just look for any of the freely distributed versions and start with the most elementary versions. I have seen several that run as applications under Windows or OS/2 and I’m sure there must be a Linux port somewhere. You might also contact the Forth Intrest Group (FIG) if you can locate an address. Also check your news server under comp.lang.forth although they tend to be pretty much beyond a beginner.
..and quite fun. I remember getting bored one week at my day job a few years ago so I wrote my own little forth interpreter for DOS. Sadly I lost it in transit when I left that job. It would be fun to tinker with it again, but I would have to start yet again
Peter
“…As for functionality, I’ve seen muli-user, multi-process systems built with it that rival any current OS – all on a lowly 8085 clone with 64k of RAM…”
I don’t think this is comparable to modern Unix functionality.
The philosophy of Forth is not to develop pluggable, do-all-modules (like the c++-religion mandates), which require massive development effort themselves, but rather to do only one job well and easily.
This is similar to XP, which AFAIK states you should refactor your code every now and again. In Forth this rewriting is possible, because it’s (a) simple syntax (b) interactive.
Probably these old multi-user systems had only limited functionality, but that’s all you need anyway!
Instead of, say, several abstraction layers/libraries you get to do what want _directly_, which means, though, you have to plan a lot initially. That why any idiot can write (sucking bad) Java, but to write Forth you need to think _before_ coding.
You should try BigForth http://www.jwdt.com/~paysan/bigforth.html
it runs under linux, windows and I remenber an old version was running under Atari’s OS (GEM, Mint and so on)
have a look to the OpenGL dragon Demo, it’s really impressive, especially if you have GL hardware compliant.
By the way, I tried to learn forth and it’s not so hard once you understand that every diacritics caracteres is a WORD in forth.
For those who were wondering a lot of arcade games were developped in Forth (all from Atari such as gauntlet for instance, the same from sega) and I’ve been told forth was the primary langage for the 3D0 system.
Have fun.
Djamé
ps : there’s a good link about a french crew who is building a fonctional 16/32 bit system based on forth (http://forth.free.fr I think)
For getting one’s feet wet, I recommend pforth http://www.softsynth.com/pforth/
Simple and works in Windows and *nix.
I’ve been following FORTH and Chuck Moore’s stuff for awhile now and I’ve found the internet has a lot of good resources. It is definitely a different mindset than most current OS thinking and that is why I find it interesting.
I must say that I don’t understand colorforth as much as I understand more traditional forths, but Chuck is a very smart man who’s ideas are worth trying to get one’s head around.
Thanks for all the links. (I know all one has to do is search, but links that come with a recommendation helps cut the excessive amount of reading one would otherwise have to do).
Let’s assume basic requirements of correspondence (printed & email), calculation (spreadsheet), and data collecting (database)
Is there an example where Forth has been used to create a functionning desktop?
I’m keen to go Forth and multiply…