I stumbled upon an interesting article from Embedded.com today called "Real Men Program in C" . It highlights one of the biggest paradoxes occurring in the embedded space, which is that the embedded field is growing, C is becoming the dominant language, and the amount of programmers that can program in C is shrinking. The reason for this is that C is rarely taught in universities anymore, most likely due to the fact that C requires understanding of both the hardware and memory architecture as well as computer science constructs such as data structures and algorithms. In short, C has become the new Pascal in university education.

The interesting thing is that I can actually see this problem in real life now since I've become part of Tokyo Hackerspace. The majority of the techies involved in hackerspace program in languages like Python and PHP and want to get more involved in programming embedded projects. While there isn't anything wrong with those languages, a lot of the low level details are abstracted away, which is great for learning the computer science part of things, but horrible if you every want to program embedded systems. 

I've recently set up the hackerspace webshop and had to do some PHP hacking to get things working like modifying the shipping cost tables for the Japanese postal system. Since it has a C-like syntax, it wasn't a real problem writing the simple PHP functions required to implement the cost tables. However I was a bit shocked to see that the language doesn't require strong typing. You don't even need to declare a local variable. You can just instantiate one anywhere in the function and it will hold strings, integers, floats, or anything else. There's also not a strong concept of scope that I could see (ha ha ha...get it?). The variables were either local to the function or global, and by global, I mean visible to all files in the project. Any C programmer would cringe at the use of global variables because they lead to problems like non-reentrancy, random errors, and really weird behavior in general.

My first thought was..."wow, this language is pretty simple and easy to use". But in thinking about it, it's a big handicap if a PHP programmer goes in the opposite direction and wants to move to a language like C. C requires a lot of discipline about data types, scope, and memory usage. That's not to disrespect PHP programmers since they have to deal with all sorts of nastiness like tracking down bugs from a PHP file included in some random file located within the 500 or so files that come with whatever content management system they're using. And I don't seem to see a good debug infrastructure for PHP other than logging error messages (although I could be wrong).

I think this is one of the reasons why the Arduino has become quite popular. It's a good way to introduce people to embedded systems and projects without having to deal with a lot of the dirty details like chasing wild pointers and memory leaks. And of course, you can say you program with Arduinos and still maintain a certain amount of dignity. It's more difficult if you're using a language like PICBASIC. 

But the eventual barrier that I see a lot of Arduino users running into is that projects are limited to the AVR processor. Normally, I like AVRs but in terms of the embedded space, you lose a lot of the richness and variety of the different flavors of MCUs if you stick with just one processor.There's the integrated signal chain and low power of the MSP430s, the infinite amount of variations in the Microchip PICs, the configurability of the Cypress PSOCs, and let's not forget playing around with the ARM-based SOCs that are dotting the chip world these days. In order to harness the rich variety of all these different chips, you would need to learn how to program in C. Otherwise, you'll end up with Arduino shields piled on top of each other like the Leaning Tower Of Pisa and still be limited to the Arduino API. 

Anyways, this post isn't really to rail against the Arduino, which I think did a great job of introducing an entirely new generation to the embedded world. Nor am I trying to complain about PHP, Python, or any other scripting language which is doing a great job of powering content-driven websites and even making this site's creation and maintenance possible by a complete web n00b. The main issue is that the embedded field is expanding and there's a huge interest in combining embedded technologies and web technologies. This can be seen by the growing popularity of publications like Make Magazine, numerous hackerspaces popping all over the world, and of course my involvement in Tokyo Hackerspace. However there isn't a whole lot being done about the paradox that C is a dying language in the academic world, but very alive and kickin' in the real world.

Hmmm...I guess this counts towards my quota of one rant on the lack of C education per year...

Add comment

Security code