On Languages

Summary: What language would you choose for your firmware?

Some years ago compiler vendor Keil Software (now part of ARM) ran an ad in Embedded Systems Programming magazine (later known as Embedded Systems Design, and now embedded.com) for their new compiler: COBOL for the 8051:

It was a joke, and ran in the April (April Fools) issue. What a funny and absurd product idea! COBOL for embedded? And COBOL for an 8051! I called the company's president and congratulated him for his sense of humor.

He told me they received orders for the product!

That reflects a certain mindset we still see in selecting languages for embedded work. Aspirations seem to trump reality.

What whole world? In fact, in the embedded space, to a first approximation only two languages are used: C and C++. Embedded.com's data shows the primary language used by readers (the vertical axis is percent):

It's clear that, surprisingly, even C++ isn't gaining market share on C.

In language selection one must consider the availability of developers. If you can't hire engineers who are versed in a particular lingo, then count on long and expensive training or failure.

I was called in to help with a foundering project in Sweden, which was being written in C++. I thought the language was a natural match to the application. But why was that choice made? The VP told me that he had read, in Business Week, that C++ was going to make everything instantly reuseable so had dictated its use.

There were 40 developers involved, and only one, a new graduate, had any object-oriented experience. The other 39 were trying to learn it on the job. That's a recipe for disaster. They needed a practice, throw-away project to get experience. One where mistakes were fine since it wouldn't ship.

C has hung on in this space for 30 years and shows no sign of going away. There are better choices now; I wish we could transition to Ada or, even better, SPARK. But that won't happen unless there are trained engineers available.

What's your take? Are C and C++ here to stay?

Published October 12, 2015