Breaking Down the State of C Programming in 2018

Who could have imagined that, more than 46 years after its creation, the programming language C would not only be going strong, but still rank highly on various programming-language indexes such as RedMonk and TIOBE? On GitHub, the language places tenth with regard to pull requests—even beating newer languages such as Swift.

Here’s one secret to C’s longevity: its constant evolution. Since 1972, the language has iterated through multiple versions, with ANSI C (also known as ISO C) becoming the standard in 1989. Personally, I like C99, the version supported by Microsoft and Digital Mars, although it’s been supplanted by C11, published in 2011. (I like C99 because you can declare variables anywhere in the code, not just at the start of functions; it also has one-line comments that start with //.)

The C11 standard adds multi-threading and improved Unicode support, plus other features that help to write safer code (such as bounds checking functions and removing gets). Not all C compilers support it yet, but some that do include GCC 4.7 and higher, Clang, Intel C 16.0, and Pelles C, a free IDE and C Compiler for Windows 32/64.

C

Without a doubt, C is the programming language with the widest software ecosystem. Take Linux, for example: some 31 percent of Debian Linux is written in C, according OpenHub’s analysis. This is mostly the kernel with its 19.5 million lines of code (as of Linux 4.1 three years ago). When you consider Linux’s footprint (i.e., most of the internet’s infrastructure, not to mention its top-ranked supercomputers, and all of its best-known relational databases), you begin to grasp the full impact of C on the computing world.

To be fair, another reason why C remains ubiquitous is that it’s always been a go-to tool for developers. For example, the Oracle Database was originally written in Assembly back in ye olden days of 1977, before the company’s engineers rewrote it in C six years later. Key-value stores Redis and LMDB, memory caching system memcached, and Aerospike (a NoSQL database) are all written in C. If that wasn’t enough, there’s also Perl’s core interpreter, CPython (the reference implementation), 50 percent of R, Git, Subversion, Apache Webserver, NGinX web server, and Chrome OS (C/C++). If you’re a tech pro who wants to learn how to manipulate the very foundation of the web, learning C is a really good idea.

Why C?

Why did C become so popular in the decades following its inception? Before C, you had Assembly (also known as Assembler, if you want to risk a fight over tools, languages and terminology), Pl/I, Pl/360, PL/S, Pl-8, and even FORTRAN (there’s a big list here). But C was far more portable—and much simpler—than Assembly, which made it easier to develop C compilers, which in turn allowed developers to produce code on an expedited basis. Many packages have been recoded in C for ease of maintenance. (Some programming languages—for instance, IBM Informix 4GL, Eiffel, Nim, and Cython—compile to C; it saves having to develop a compiler backend, although LLVM has probably reduced that need by this point.)

I recently used the SDL2 open-source library, which is written in C and meant to provide an abstraction layer for computer multimedia hardware; in one program, a screen full of moving objects managed to achieve 5,000 frames per second, without syncing with the retrace. If you want to try out C GUI programming, be sure to experiment with the single-header open source ANSI C GUI library Nuklear.

Conclusion

C is firmly embedded in modern-day computing. C++ is an obvious candidate to replace it, but I suspect it never will; same with Go and Rust. Even if the perfect programming language to replace C ever emerged, the costs associated with substituting legacy code make C’s short-term demise unlikely. Ten years ago, for example, the Linux Foundation estimated the cost of building out the Fedora 9 Linux distribution at $10.8 billion; that’s a pretty good yardstick for judging the cost of a widespread code replacement. In short, C is lodged in our infrastructure like a deer tick.

For the time being, C should be considered “good enough,” and for tech professionals who are looking for a skill to add to their toolbox, you could do far, far worse.

Related

5 Responses to “Breaking Down the State of C Programming in 2018”

  1. There will be more C programmers than C++ programmers because at the very beginning of a programmers career, it is easier to think in terms of procedural rather than object oritented. Majority of programmers are stuck in the procedural mindset. And most of the people who jump to OOP (c++) writes code that needs lots of improvement (using lots of manual memory allocation as opposed to using smart pointers) and most of the time, they write sloppy object oriented code at the very beginning.

    I had been programming in C for 13 years, i learned C++ and had been using it for 6 years. I love the flexibility being offered by C++ using polymorphism and application of GOF design patterns. I never looked back to C eversince and im not planning to join any software shops that uses C only.

    • Jerry

      I disagree that at the beginning of their career programmers find procedural languages easier to understand than object oriented languages. I’ve taught both, and find roughly equal comprehension between the two groups. Most programmers think procedural languages are easier to learn because that’s what they learned first. But there is a huge change in mindset when going from procedural to object oriented programming – one that is very difficult for many programmers to grasp.
      Learning object oriented first means less has to be unlearned and grasping the concepts is much easier. But it also means switching to procedural programming is more difficult (although not as difficult since OO uses many procedural concepts).

    • Aciliketcap

      I agree that learning OOP or functional concepts when someone is just beginning to code is hard. It just doesn’t make sense, you can’t see the trade-offs. And usually you mix everything up together and invent your own poor tactics on the way. I developed C# for about a year and C# allows you to use many old and new concepts. When I looked at other people’s code (closed source projects or code on Codeplex and Codeproject) I saw that many people learned how to write poor procedural programs (some of which looked like pre-procedural even, like assembly) and just sticked to that.

      I think the answer to getting up to speed with the current programming concepts is about acknowledging the fact that we have been programming en-masse for about fifty years and trying to catch-up.

      I taught C to some beginners and I don’t think starting with C is a good idea. Because you can’t do interesting stuff to keep beginners interested with pure C and I would use another programming language if I’m going to do interesting enough GUI or web stuff.

  2. Aciliketcap

    Nice article.

    A much more comprehensive article about state of C was published last spring.

    tekhinnovation.blogspot.com.tr/2017/03/after-all-these-years-world-is-still.html

    And I wrote an article with counter arguments to that article.

    https://www.linkedin.com/pulse/c-must-retire-sinan-akpolat/

    I completely agree that it is extremely hard to replace current active C code base. I also think that it would take more than ten years even if there was a conscious effort to retire C. However you must note that some projects have moved away from C (one of the most notable examples is GCC) and there are others who are discussing rewriting their code in another language. Reasons to switch away from C exist.

    Also Debian Linux is one of the concentration points where C people dwell. You will see a different percentage if you look at other popular OS’s like Windows or Android. (I have no idea about Apple’s OSs.)

    C is a MUST if you are going to do embedded development. C is also critical if you are developing OS level software or software which interacts with OS too much (especially if that OS is Linux). It is good to know C because you are likely to encounter it when you dig deep; whether it is understanding how CPython works, changing some behaviour of the web server you love or debugging CUDA libs and Nvidia drivers for your state-of-the-art DL infrastructure.

    I have to note that I haven’t studied the changes in C11. New memory model, bounds checking, atomics and multi-threading aside from Pthreads are interesting. I might give it a try if big projects like Linux kernel or GTK+ start using it.

  3. Xavier

    You’ve forgotten to mention the embedded systems / devices. There are in the world 9 of such devices per 1 PC. Embedded systems are programed in C.

    A note for those that are argumenting in favor / against C++: one can write object oriented programs in plain C.