As always if one doesn't know the programming language, nothing is obvious.
Why is this a surprise to anyone ?
I'm curious to hear your take on why C became the industry standard programming language for embedded systems and Forth did not.
Not that I have any special access to the embedded systems industry or the hearts and minds of embedded systems writers any more than anyone else but I do have my pet theories.
Firstly there is no such thing as a "industry standard programming language for embedded systems".
I'm happy to concede that The 'C' programming language is probably the most common programming language in use today. However let's not overlook other languages designed specifically for embedded development and use such as Assembly Language and Forth etc
Some reasons why Forth will never be popular, and why C is very common in my opinion. Not in order of significance:
Standardization:
C has a standard syntax that doesn't change much which many (but not all) users and all software sales organizations prefer. C was always perfect for pretty colored shrink wrapped boxes in retail stores and a plethora of books such as SAM's learn C in 24 hours. Forth is the darling of the software sales industry, but other recent languages such as Python are also becoming very popular, especially in embedded where tons of memory resources are available.
C easily wins the standardization category.
Sidenote: I'm waiting for someone to create a 'Tethered Python', I think that may give C and Arduino a run for it's money at least in the hobby market.
Marketing:
C is easy to market as mentioned above but Forth is not, and never will be.
C easily wins the marketing category.
Arduino:
Arduino brought thousands of hobbyists to C.
Until the advent of Arduino, embedded was not trivial, a designer had to do the hard yards before they could even get a MCU to boot. Arduino brought artists and hobbyists flocking to their easy to use system, complete with 'libraries'. Want to run a stepper motor, no problem, grab a ULN2003, a 'sketch' and step away!
Arduino hid all the hard stuff, and unfortunately is still recommended by users on this forum as a way to learn Microprocessors, but I disagree. Arduino was designed for artists with little technical knowledge.
If you really want to learn the basics of Embedded design, grab a Intel 8085 chip, a Parallel Flash EPROM and make something that works using Assembly Language. Report back when you have actually built something (pics required) and figured it all out.
I put together a 'Learning Microprocessors' page at
https://sourceforge.net/projects/learning-microprocessors/ based on the 8085 and a handy Java simulator which represents the state of the technology about 10 years after I started in the embedded area in 1975.
LIbraries:
Like Cargo Cultists, C users eagerly await the latest libraries to drop from the sky, "please God bring me a library that allows me to use Timer3 and Timer6 synchronized together and using interrupts on Timer 1 and DMA on Timer 3 in a easy to use, non technical way so I don't have to read that terrible 2000 page technical manual with all those registers, ... anything but that!".
C users sing praises of the availability of embedded libraries' while decrying the complexity of library systems which struggle to somehow to bring a unified library into being across dozens of MCU peripherals, hundreds of registers and thousands of register bitfields.
What C users call a library, Forth users call 'configuration' and we write them as required for each project. It's no biggie, it requires a intimate understanding of the hardware as *it always has* since the first 4004 micro rolled of the production line.
Nevertheless the promise of 'C Libraries' lives on, it's the holy grail that attracts people by the thousands who think that C will make them into a hardware engineer.
All they need is a C, some libraries and a MCU in some cheap Chinese 'development board' along with 'shields'.
C easily wins the library category.
Interactivity:
Only Forth is interactive, C is not. So Forth is the clear winner in the interactivity category.
Why Forth will never be be mainstream or popular, but will forever be a niche programming language in my opinion:
1) Forth is like the TAO, it is a way and is only understood when practiced.
2) Forth is easy to learn, but hard to master, it requires a different mindset.
3) Forth is a Chameleon, it is like a stealth aircraft which looks different from every angle. Even the creator of Forth said, when asked "what is Forth" ... " I can't really say, but I know it when I see it"
These are all valid forth Words (subroutines, functions etc):
: + - ;
: foo ." bar" cr ;
CC4OE %1 12 lshift TIM1_CCER bis!
: 2arshift ( d u -- d* )
[
$CF03 h,
$2E20 h,
$D304 h,
$F1B6 h,
$0320 h,
$FA50 h,
$F203 h,
$E006 h,
$FA31 h,
$F206 h,
$F1D6 h,
$0320 h,
$FA10 h,
$F303 h,
$431A h,
$F847 h,
$2D04 h,
$FA50 h,
$F606 h,
]
3-foldable ;
10 constant sieve-size \ Reject variations of less than 10
0 variable oldinput
: sieve ( newinput -- output only if newinput = oldinput +- sieve-size )
dup oldinput @ sieve-size - <= if 0 >r else 1 >r then
dup oldinput @ sieve-size + >= if 0 >r else 1 >r then
r> r> and if drop oldinput @ else dup oldinput ! then
;
power-on fill wash drain empty fill wash drain spin power-off
Summary:
I'm not pushing Forth here, I don't care who uses Forth and who doesn't. My motto regarding embedded is "if it works for you then its probably what you need"
I'm here because I'm a Forth user, I recommend it to new users who ask, "what embedded language would be good for me?".
I debate 'C' Language pushers who have no real clue about Forth and attack it in order to justify their mistaken belief that 'common' also means 'best'.