Dan 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 displays the responses for the first question; Table 2 displays the responses to the second. (I couldn't locate the data for 2003, so that year is missing from both tables.) The tables list only the most popular languages. I left out languages, such as Forth, Fortran, Modula 2, and Pascal, that less than 3% of the surveyed programmers selected each year.
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.
Table 2 shows what programmers reported they were planning to use. What's interesting is how the entries in Table 2 compare with those in Table 1. Table 3 displays the differences between the corresponding entries in Tables 1 and 2. Positive values in Table 3 indicate expected increases in language use; negative values (in red) indicate expected decreases.
For example, Table 3 shows that, on average, the number of programmers who expected to use C the next year was 2.6% less than the number currently using C. Even more programmers aspired to get the assembly language monkey off their backs–the number of programmers who expected to use assembly language the next year averaged 4.7% less than the current year.
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 contains a plot of the values in Table 1 for the four most commonly-used languages: C, assembly language, C++, and Java. For each language, Figure 1 shows a solid line that plots the reported language use (from Table 1) along with a dashed line depicting the linear trend. Editor's note: Article corrected on 5/4/12. Figures 1 and 2 are now the original charts Dan Saks submitted. Note that colors he assigned the languages are inconsistent between the two figures but are correct within each figure. (In other words, C++ is green in Figure 1 but red in Figure 2.) The key in Figure 1 in print version is incorrect.
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.
Table 4 displays the responses for the first question for every year starting in 2005. Table 5 displays the responses to the second question. Table 6 displays the differences between the corresponding entries in Tables 4 and 6. As in Table 3, positive values in Table 6 indicate expected increases in language use; negative values (in red) indicate expected decreases.
Most of the percentages in Tables 4 and 5 are rounded to the nearest tenth of a percent. However, the values for 2005 through 2007 are rounded only to the nearest percent.
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.
Figure 2 contains a plot of the values for the four languages with the highest average percentages in Table 1, along with their linear trends. The contrasts between the actual usage shown in Figure 2 and the expectations depicted in Table 6 are rather striking.
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.