Unexpected trendsDan Saks crunches over 12 years of data on programming-language preferences from reader studies and finds some surprises about C/C++.
I started writing for computer trade publications almost 23 years ago, publishing my first article in The C Users Journal in the summer of 1989. Within a year, I became secretary of the ANSI C++ standards committee and landed my first column writing about the emerging standard for The C++ Report. Just a few months later, I started writing a column on programming style for a curiously named magazine called Tech Specialist, which soon morphed into The DOS Developers Journal and eventually into The Windows/DOS Developers Journal. Over the next several years, I wrote columns for a handful of other magazines, including The C User Journal (later the The C/C++ Users Journal), Software Development, and an obscure little publication called The Journal of C Language Translation. None of these publications is with us anymore.
I wrote my first Programming Pointers column in 1998, when this publication was still Embedded Systems Programming. Now that Embedded System Design is going out of print, this could well be my last column for a print publication.
However, I expect to continue writing for Embedded.com.
Back in 1998, the consensus was that C had overtaken assembly languages as the most commonly-used language for programming embedded systems. By then, C had been around for a quarter century and had been standardized for almost a decade. However, object-oriented programming was going mainstream and newer languages with native support for objects, notably C++ and Java, were encroaching on C's turf. At that time, I thought C++ or Java would eventually displace C as the language of choice for embedded systems. I was hardly alone.
So in my final column for Embedded Systems Design, I'd like to look back and see if what we thought would happen actually did happen. This seems like as good a time as any.
Early language usage data
Starting in 1993, the publisher of Embedded Systems Programming conducted annual reader surveys to assess the purchasing habits of embedded systems designers and their managers. Each year, the survey included at least one question on programming language usage. The total number of responses varied from slightly less than 400 in one year to a little over 2,000 in another.
From 1998 through 2004 the survey asked two questions:
- "Which of the following programming languages have you used for embedded development in the last 12 months?"
- "Which of the following programming languages are you planning to use for embedded designs in the next 12 months?"
Table 1 shows that, on average, nearly 80% of the surveyed programmers reported using C, nearly 60% used assembly language, and roughly 45% used at least some C++. Java was a distant fourth, with Basic just behind it. On average, less than 5% of programmers reported using Ada.
In contrast, many more programmers who hadn't been using C++ or Java expected to start using those languages. On average, 9.7% more respondents expected to use C++ in the coming year than were using C++ in the current year. The percentage for Java was only slightly less. At that rate, you might expect C++ to overtake assembly language in just a few years and bypass C several years later. You might expect Java to follow a similar trajectory, lagging a bit behind C++. However, reality played out a little differently.
Figure 1 shows that, from 1998 to 2004, both C++ and Java usage indeed trended upward at about the same rate, although nowhere close to the 9 to 10% per year predicated by the surveys. It also shows that assembly language usage trended downward. However, I think the trendline for assembly language is less meaningful because half the data points are so far off the trend.
The real surprise in Figure 1 is that it shows C usage actually trending upward, rather than downward as the surveys projected. It's only slightly upward, but upward nonetheless.
A few more years of data might tell us if assembly language usage is really diminishing and C language usage really is increasing.
More recent data
Starting in 2005, the Embedded Systems Design reader surveys changed the wording of the questions to:
- "My current embedded project is programmed mostly in which language?"
- "My next embedded project will likely be programmed mostly in which language?"
Whereas the earlier surveys asked each programmer to list all languages used, the latter surveys asked each programmer to name only the one language used most. Not surprisingly, the survey data changed dramatically starting in 2005. If you ask a different question, you usually get a different answer.
The columns in Tables 1 and 2 add up to well over 100% because each programmer could select more than one language, and apparently many did. In contrast, the columns in Tables 4 and 5 add up pretty close to 100% because each programmer could select only one language. (Some columns don't add up to 100% because of rounding errors.)
Table 4 shows that, on average, slightly more than half of the surveyed programmers worked on projects written mostly in C, whereas slightly less than a quarter of them worked on projects written mostly in C++.
Table 1 showed that roughly 60% of developers used assembly language, but Table 4 shows that assembly language is the primary language on only around 6% of projects. This suggests that, while many developers use some assembly language, only a few unfortunate ones have to use it a lot.
Table 6 shows that, as a group, programmers expected that C, assembly language, and Basic would to be primary language on fewer projects as the years went by. They expected C++, Java, and other languages would become the primary language on more projects. However, more so than in the earlier years of the survey, reality didn't go along with these expectations.
Although year after year, the surveyed developers expected C to be the primary language on fewer projects, C's dominance actually grew. Over the seven-year survey period, C as the primary project language grew from slightly more than half to nearly two-thirds of all projects. Most of that growth seems to have come at the expense of C++. Although developers expected C++ to become the primary language on more projects, it actually diminished from nearly 30% of projects to only about 20%.
Java's trendline in Figure 2 is essentially flat. Only assembly language trended downward as expected.
Let the speculating begin
I think these results are very interesting. The recent trends for assembly language and Java are much as I expected, but I'm rather surprised at the apparent trends for C and C++.
Those of you who read my column regularly know that I think C++ is a decidedly superior programming language compared with C. My columns have addressed, and will continue to address, the needs of both C and C++ programmers, but I make no bones about my preference for C++. It's rather puzzling to see the industry moving the other way.
Why might this be happening? I don't know. Maybe I'll have more to say about this in a future online column, but for now, I'll leave it to you to speculate. I'll just go back to my business of helping programmers write better embedded systems. See you on the web.
Dan Saks is president of Saks & Associates, a C/C++ training and consulting company. E-mail him at firstname.lastname@example.org.
Special thanks to my brother, Joel Saks, who has helped me improve almost every column I've written for Embedded Systems Programming/Design.
This content is provided courtesy of Embedded.com and Embedded Systems Design magazine.
See more content from Embedded Systems Design and Embedded Systems Programming magazines in the magazine archive.
This material was first printed in May 2012 Embedded Systems Design magazine.
Sign up for subscriptions and newsletters.
Copyright © 2012
UBM--All rights reserved.