New school C

Why C is a more practical and enticing programming language than you might think.

Choosing a programming language for that project you’re working on is a fairly straightforward decision: it needs to be fast, easy to use, and it must come with enough bells and whistles to keep you from re-inventing the wheel every time you want to do something.

Looking at this criteria, aside from the fast bit, the C language may not be the first one that pops into your head. After sitting down with Ben Klemens, the author of 21st Century C, I am now looking at C as a more practical and enticing alternative than I would have thought possible.

21st Century C sets a precedent in presenting C as a language that is a lot easier to use, and has more library support than many people think. If you are not up to date on the latest that C has to offer you may not be aware of the simplicity and elegance of the language. These strengths are backed by the C99 and C11 standards, but mainly they are built up on the development of libraries and modern tools for building and multi-threading in C.

In my interview with Ben he talks about the inclusion of libraries and what that means to modern C programming at the 9:53 mark. There is quite simply a vast array of libraries out there that every developer has access to. As Ben points out at the 10:50 mark, looking at GitHub we can find something on the order of 150,000 C projects. It is important to note that packing up many of these projects as libraries can involve a bit more work than just building the project, but just having all those projects as resources can save a lot of time and minimize redundant efforts.

Of course what is new in modern C programming is only half the picture. The other half involves all the parts of C programming that can be largely ignored or at least downplayed. As Ben points out at the 8:03 mark in our discussion, today’s programmer can even go so far as to question the usage of malloc and other time tested memory management techniques.

The full interview with Ben is available in the following video.

Related:

Related

Sign up for the O'Reilly Programming Newsletter to get weekly insight from industry insiders.
topic: Programming
  • drhowarddrfine

    I gots ta tell ya’

    I started my web dev company 9 years ago and coded everything in C cause that was the only language I knew. I’ve gotten so busy, I haven’t had the time to learn anything else. While I read about everyone else creating and using libraries that solve this and that problem, I/we solved all those same things years ago and we still use C for everything on the back end. It’s smaller, lighter, faster than anything else and it interfaces with everything.

    • Aldo Martinez

      @drhowardrfine,
      Could you explain a little bit more about the technology you’re using and the interactions? For example, I user visual studio with asp .net and c#.

      Thanks :)

      • drhowarddrfine

        Just the standard BSD and Linux tools. We develop everything on FreeBSD using vim, git, gimp, inkscape and apache. For our Linux servers we cross compile on CentOS cause that’s what our host uses.

        • Aldo Martinez

          So, that means that you use sockets to handle all the web requests, right? Kind of nodejs but in C?

  • Sonia Hamilton

    I read the book in beta (on Safari books), it’s really changed my mind about C. And all those libraries to link to…!

  • tomasz brymora

    I was going to buy this one, but read the 1 star reviews on Amazon. Unfortunately, they carried too much weight for me, so it became a non-starter.

    • leeeoooooo

      Disregard those 1-star reviews… most of them are nonsense. “reads like a blog” Yes, he says up front that this is mostly a collection of tips from his blog. “too many forward and back references” Yes, see previous re:blog. “first half of the book has no code” Yes he says right up front that in the first part he is making his case and describing the tools you should set up to make your life easier.

      I’ve read and reread this book many times, and besides being a delightfully fresh look at the language, it has many, many tips that have already simplified and streamlined my coding.

      I don’t know why those 1-star reviews would carry any weight with you, they didn’t with me. I don’t even think most of them read the book.

  • Δημήτριος Μενούνος

    I make my living coding in java web applications, and I like it.

    However my love is C (and C++)!

    Cheers

  • faisal

    Recently I started learning Vala which is a lot closer to C#/Java syntactically but generates pure C language source code which gets compiled to native binaries. I find that approach pretty interesting.