logo slogan

Forth Vs C Vs Ruby Vs Ada Vs.....

By Chris Hills and contributors

Someting for starting a discussion with the family over the Chritmans turkey


As you may probably not have noticed Phaedrus Systems can supply the MPE Forth compilers.  Forth is a, well niche market to say the least.   One of the Forth people sent me this paper “Forth Vs C” by Howerd Oakford. Read it….  (click here for PDF)   Howard is involved with Forth compilers.  

 

In the words of Mandy Rice Davis https://en.wikipedia.org/wiki/Mandy_Rice-Davies  “well, he would say that, wouldn’t he?” so I sent the paper to a small selection of people involved in language verification, static analysis etc. for comment.

 

The first thing I got from a FORTH guru was a set of links to useing FORHT "properly" as an Engineering Language

 

A Start With Forth https://wiki.forth-ev.de/doku.php/en:projects:a-start-with-forth:start0
The 35 word data https://wiki.forth-ev.de/doku.php/en:projects:a-start-with-forth:start
Forth LITE Tutorial

https://www.amazon.com/FORTH-LITE-TUTORIAL-compatible-SwiftForth-ebook/dp/B00L0F32Q8/ref=asap_bc

Stephen Pelc’s Book

https://www.amazon.com/Programming-Forth-Version-July-2016-ebook/dp/B01JIWVB5S/ref=asap_bc

The Forth Bookshelf

https://www.amazon.co.uk/s/ref=nb_sb_noss?url=search-alias%3Daps&field-keywords=juergen+pintaske&rh=i%3Aaps%2Ck%3Ajuergen+pintaske


A certain Les H https://en.wikipedia.org/wiki/Les_Hatton  said   “Oh dear, this is identical to every polemic about the 'best' language I have seen in the last 40 years.  No data is ever offered, simply a collection of vague opinions, finishing with some idiotic aphorism such as "If your only tool is a hammer, all programs become nails."

As far as I am concerned, you could swap in the names of any two other programming languages in place of C and Forth and somebody would have written it.

Just for reference, here is a similar piece Les was asked to review for IEEE Computer in 2006 about how "Ruby on Rails" was going to take over the planet from PHP or whatever in 2006.
http://ieeexplore.ieee.org/document/1597080/

Les Says “At the time, it was a little embarrassing to be the only one who was consistently negative - you might especially note the quotation from the Boeing guy at the end.  Meanwhile 11 years later, it has basically got absolutely nowhere, as predictedNew languages very rarely do because the only thing they have going for them is that they "... just, you know, feel so wonderful and right going forward, guys; oh hello nurse, is it time for my medicine again; so soon ?".

Hugh emailed to say : I doubt that Forth standard is possible for micro-controllers because the programs aren't going to be portable anyway, due to hardware dependencies. Portability is the purpose of a standard though, so if portability isn't possible anyway, what would be the goal of the standard?


Of course as some well-known advocates would say “Use ADA!”  Or of course SPARK.  The problem here is that when ADA started  in the late 1970’s “to replace 450 languages* in use by the US government” 
Where have all those other 450 languages in use in the 1980’s gone? Can anyone remember them? A Christmas game:  Make a list of all the programming languages you know and see how well you do.  https://en.wikipedia.org/wiki/List_of_programming_languages  Let me know chris@phaedsys.com if you have any not on the list.


ADA  https://en.wikipedia.org/wiki/Ada_%28programming_language%29   was aimed at large scale military projects and the tools were also aimed at that rather than the mass market.  So like many other languages it gained a niche, if large and well-funded, market.  Because of this , and along with it being taught and used on critical systems where Engineering and Discipline came before hacking and coding, it never gained the mass appeal and therefore the mass of less expensive tools never arrived.


The tighter version of Ada called SPARK  https://en.wikipedia.org/wiki/SPARK_(programming_language) was tighter still with a smaller following.  SPARK is seen as a specialist critical systems language. However its users typically have shorter development times with far fewer errors in the development. This is because it is very precise with lots of checks and formal syntax.


This is something C has struggled with; despite its popularity there is a C standard well… K&R-C, ANSI-C, ISO-C90, ISO-C95, ISO-C99, ISO-C11 There is another ISO-C on the way.  Of course GNU C/GCC follows its own path not always compatible with ISO-C . 

 

However whilst most C compilers were C90 and C95 compliant very few were fully or even mostly C99 compliant and are little better for C11.

 

Only a subset of C is portable because so much of C is unspecified, undefined (I am sure you all know the difference so I  don’t need to elaborate on it here) then there is the Implementation defined.   The undefined, unspecified and implementation defined list ran to over 20 pages in C99 (some 400 Items from memory). 


This is one of the reasons why rule 1 of MISRA-C is always “Your code must be ISO-C **** compliant”  not because the code should be ISO C compliant but the rule is there to make you investigate just what your compiler does and doesn’t claim to do.  Then you need to document the differences as part of MISRA-C compliance.


Many people still think they use “ANSI-C” with no real idea what “ANSI-C” is, or rather was:  it was superseded in 1990 by ISO C. 


This is also one of the reasons why Phaedrus Systems can supply a compiler test suite and does a compiler validation service.  Quite apart from what the C compiler, particularly embedded cross compilers, claim to do, usually describe by purists as a “C-like” language not C, for critical systems you need to check that what they claim to do is what they actually do!


Compilers are complex beasts and you need a discreet-maths Mathematician to design them, not a programmer.  There are several C compiler architectures in use. From generic ones like GCC to the highly specific ones used by the commercial compiler companies (and some non GCC/LLVM non-commercial compilers). The problem is with all compilers if you move one card in the house of cards it affects all the other cards.  One small change in one area can affect optimisations in another area in an unexpected way.  


NOTE you can’t turn optimisations off in any compiler. You can merely slightly adjust the optimisations the compiler (and linker) does within certain windows.  See our documents  on compiler validation, it’s not a simple as it sounds. http://phaedsys.com/standards/compilervalidation/index.html

 

Of course In an ideal world we would of course all be speaking in Esperanto and programming in Modula2 https://en.wikipedia.org/wiki/Modula-2   No, somehow I didn’t think so! 

 

So what is your favourite language and why should we all be using it?  Email chris@phaedsys.com and we will put up the list (with your arguments for using it) in the January 2019 newsletter. 

 

Happy Christmas.