
In four years’ time, C will reach its 50th birthday, an anniversary also shared with PL/M and Prolog. Unlike those two, C remains immensely popular, it’s in the top ten of virtually every programming language popularity survey. Linux is mostly written in C. Python's CPython implementation, Perl, Matz's Ruby, about half of R, the MyISAM code for MySQL and even the first Java compiler were all written in C. The kernels of most operating systems (including Windows, Mac, Linux, iOS and Android) all feature C. Now we have a new C standard, C18, that was ratified a few months ago. A mere 198 Swiss Francs will buy the ISO/IEC 9899:2018 standard, all 520 pages of it; you can view the final draft of it for free, though, on openStd.org (PDF) to get a sense of the document. It's only really of use if you are a compiler writer who wants to be 100 percent conformant, or just curious. There's nothing new in C18, just more fixes, so it’s very much a continuation of C17. The last major changes to C were in C11, and those included variable length arrays, multi-threading support, better Unicode support, anonymous structures and unions, and a lot more.
C Holds Its Own Against C++
C++ has made some inroads into C's arena, especially since the C++ move semantics were added in C++11. When used in the right way, particularly with pointers to large objects, this results in better performance, fewer temporary copies, and lets C++ be used in places that were traditionally C territory (e.g., embedded). However, C++ compiled code is still generally a bit larger than that of C, because exception handling adds bulk and the number of inline template classes whose members get included. Out of curiosity, I compiled this in release mode in Visual C++ 2017:#include int main() { std::cout << "Hello world" << std::endl; return 0; }That compiled to a 10,752 bytes exe. The equivalent C program is:
#include int main() { printf("hello world\n"); return 0; }That was 9,216 bytes long, or 85 percent of the size. Not a great deal of difference, but I could project this difference growing once you add in other classes. Code size is important because of the increasing number of Internet of Things (IoT) devices and the use of microcontrollers, which typically have RAM and ROM (Flash) measured in kilobytes. In the embedded field, C has actually gained market share between 2005 and 2018.