Forth was developed by Charles Moore to control radio telescopes, and to aid programmer productivity generally. Moore wanted a high level language, when all around him programmed in languages that were either assembler or flawed third generation languages. He wanted a swift software development cycle that an interpreted language would provide, but he wanted code to execute at machine code speeds. He wanted his applications to run on the most modest of hardware, with the most meagre of storage, with the smallest of files. The end result was Forth.
In an era of .net, Java, python, quad core Intel processors, and terabyte hard drives, you might think that Forth, a programming language that runs happily on the type of tiny processor that is embedded in a £5 smoke detector is outdated, but you would be wrong.
Forth is extensively used in the space industry, for satelite control, for mission critical systems and any application where minimal resource provision, and tiny power consumption is mandatory.
There will always be Forth, to serve most recently the Internet of Things (I.o.T) market, and any market that demands miniturisation. But does even that sum up the extent of Forths abilities?
There is much talk amongst software developers of abstraction and patterns. In short when software is written there are many snippets of code, functions and words that repeat frequently. Abstraction is the process of extracting these repetitions and creating functions or words to replace them. This results in smaller files, as repitition is reduced. It may also result in more robust software if these newly created functions are extensively tested. Forth lends itself particularly well to this type of abstraction.
To replace such repeated code with a function, or shall we say a Forth word, incurs an overhead, as the running code has to be interrupted, the function parameters have to be stored on the stack, and the return address stored. In Forth however, the stack is accessible to the programmer, and it is used by default to store these values. No extra work needs to be done by the executable, the data is already on the stack and ready for use. Writing functions or words in Forth to replace this repetitive code has a particularly low overhead, unlike more conventional languages.
There are many implementations of Forth, and the best introduce some very efficient optimisation, that compares well with the best C compilers. There are so many different versions of Forth for so many CPU's it is inevitable that some, by virtue of their design are slow.
Forth can be ported easily to new processors, and may be the first development environment on the CPU for that reason. A skilled Forth developer might take two weeks to complete this task, but then has a very powerful development environment at their disposal. It is quite likely that for a new chip, Forth is the first high level language that will run on that chip.
Forth development, in my limited experience is an unbridled joy. It frees the developer from the constraints of typical c based languages with their limited set of reserved words, and lack of an interpreter. Forth's compiled/interpreted duality allows software to be developed quickly and tested just as quickly and this can lead to a higher quality output.
It is sometimes difficult to establish where Forth is being used successfully. I have heard that some industries play down their use of the language in order to maintain the commercial advantage that it provides them. Some say skilled Forth programmers are ten times as productive as equivalent c programmers.
Fedex the famous parcel delivery company use a system written in Forth to track their parcels around the world. This is a phenomenal undertaking in any programming language, and demonstrates the power of the language.
There are a many examples of forth systems listed at the bottom of this page.
The Cassini project which used forth software to control the Cassini Asteroid lander is an example of a Forth being used in the most demanding, yet most resource constrained of applications. The following is a list of forth applications in the space sector.
Meadowlark have used Forth to produce project/budget tracking applications.
Forth may have declined in popularity as a consequence of its efficiency, the Wintel alliance and the greed of the computer industry. That bold statement may take some explanation. This is how I justify my comment.
Forth systems, when well written can execute on the most underpowered, or (old, cheap) hardware, but the prevalent trend in hardware has been in the opposite direction, toward higher power architecture. Computer processors in your typical PC double in processing speed every eighteen months and can now out-perform the supercomputers of the nineties, and so who needs efficiency? And of course computer vendors want to sell you the most powerful systems, upon which there are the largest margins.
Of course it is not that simple. How many of us have used a powerful computer that runs so slowly that it is unusable? How many of us have upgraded our computers so we can run more modern software? Modern software so often makes such inefficient use of the computers hardware resources, but is does not matter because the hardware can cope, or can it?
Has anyone spotted the vicious circle? If a software developer knows the system that his product is targeting is powerful, there will be little effort to make his application efficient. Hence the need for yet more powerful hardware and the constant need to upgrade.
Of course there is another reason for Forths "failure". Software developers are not rewarded for efficiency. There is no commercial benefit from writing a program quickly and cheaply. The more days a developer spends at the clients site writing a system, the more the client can be charged.
Charles Moore developed multi-user, multitasking systems in Forth on puny computer systems in the seventies, but the real money in IT has been made by vendors selling vast systems with prettier user interfaces, faster processors, and software that is inefficient. The implications of this trend have been dire.
Inefficient computers require big power supplies. Big power supplies consume large quantities of electricity. We live on a planet that is being gently cooked by inefficiency and greed.
There will be Internet Of Things (I.O.T) devices everywhere, perhaps progammed in Forth, that will be recording and transmitting information about our environment. Some of these devices may monitor us, our own bodies, looking for pathologies and these will report directly to our GP's. They will be the watchdogs of our health. As a consequence we just might live longer lives, as health issues will be diagnosed earlier.
Applications of Artificial intelligence will change our lives for better and for worse. They will decide how we drive our cars, advise us on what we should eat, and suggest life-style changes on the basis of statistics. Privacy will be harder to maintain.