C, the Programming Language: Still On Top After All These Years

by Joey deVilla on August 16, 2012

Dennis Ritchie, creator of C, with Ken Thompson, creator of B, C’s precursor.

If you’ve ever been with me at a gathering of programmers, chances are that you’ve heard me play The Beatles’ Let It Be on my accordion while singing these lyrics:

When I find myself in hacking trouble
Dennis Ritchie comes to me
Speaking words of wisdom:
“Code in C.”

And right there on my hard drive
gcc is there for me
Speaking words of wisdom:
“Code in C.”

Code in C, code in C,
Code in C, oh, code in C
[insert high-level scripting language here] is for lightweights
Code in C.

C’s got staying power: even though it first appeared in 1972, it’s still popular today, sitting pretty at the very top of the August 2012 TIOBE Programming Community Index:

TIOBE Programming Community Index
“Top 11″ for August 2012
Position Programming Language Appeared in
1 C 1972
2 Java 1995
3 Objective-C 1983
4 C++ 1983
5 C# 2001
6 PHP 1995
7 Visual Basic 1991
8 Python 1991
9 Perl 1987
10 Ruby 1995
11 JavaScript 1995

Note the top five languages immediately after C: they all have C’s syntax, as do Perl and JavaScript. Java, C#, PHP, Perl and JavaScript programmers should be able to look at some C code and get the general idea, at least until it gets into more complex work with pointers. C++ is almost a superset of C; a C++ programmer should not only comprehend C code as easily as C++, s/he should also say “Not confusing enough”.

Objective-C is a strict superset of C, which means that any C code that compiles will also compile if fed to an Objective-C compiler. If you’re developing for iOS or MacOS, you’re pretty much a C programmer, albeit a very souped-up one.

C and Me

When I was a computer science student at Crazy Go Nuts University, I chose to do my programming assignments in C (the other language option was Turing, which made the choice rather simple). Since graduating, I’ve only used C for little hobby projects; I’ve never been paid to do any C coding. Still, it’s paid off in many important ways, from having a better understanding of the underlying machinery to being very comfortable with the syntaxes of languages like Java, JavaScript and C# to being of great help as I’m teach myself iOS programming.

Being comfortable with C paid off quite recently when I was interviewing at a startup in the San Francisco Bay area. They asked me to download and install an Ubuntu virtual environment and write a quick little program for the inPulse smartwatch emulator in order to demonstrate my programming chops. Their API documentation was barely that: a straight-up copy of the .h files for their API function library. Because I had the C practice, those header files and a quick look at some of their example code was all I needed to cobble together a quick app. The app became the basis for my inPulse programming tutorial.

Head First C

It’s unusual to see a new C book these days. Take a look at the C programming book listings on Amazon; most of them are at least five years old, and a good number of them have publishing dates in the ’90s. C’s old enough and small enough — even in the latest version, C11, approved only last December, it’s still under four dozen keywords — that most authors haven’t seen fit to write a new C book in some time.

Head First C is one of those rare new C books. Published in April 2012, it’s one of the newest in O’Reilly’s fun-to-read “Head First” series of books, which uses humour and whimsical graphic design to engage the reader. O’Reilly Radar recently conducted an interview with one of its authors, David Griffiths, about the book, the continued popularity of C and what it offers to readers.

When asked “Why write Head First C?”, especially when people still point to Kernighan and Ritchie’s classic book, The C Programming Language, as the go-to book, he Griffiths answered:

Kernighan and Richie’s The C Programming Language is one of most popular, if not the most popular, programming books, and it defined the ANSI standard. That book is still the standard, but through the language hasn’t changed, the audience has, and many learners are coming to the language from a different perspective and set of knowledge.

The C Programming Language was written in a time when it was very unusual to see a computer in someone’s home, well before the era of easily-accessible internet, never mind smartphones and tablets. Back then, C might likely be the reader’s first programming language, while these days, readers are likely to have had some experience with JavaScript, PHP, Ruby, Python or some other programming language, and they’re most likely not doing systems programming. Head First C has some interesting examples and even more interesting labs, featuring an Arduino-powered plant-watering alarm, a webcam-powered computer vision system and an “Asteroids”-like videogame.

Head First C is a pretty good book, and it’s worthwhile read. To find out more about it, check out the interview in the video above.

Learn C the Hard Way

Yours Truly and Zed Shaw

Also worthwhile is Learn C the Hard Way, a book written by the notoriously opinionated Zed Shaw. Based on his earlier book, Learn Python the Hard Way, a book written out of anger and frustration with Mark Pilgrim’s Dive Into Python (a book I rather liked, but hey, Zed’s got a right to his opinion). It’s also a worthwhile read, and unlike Head First C, it’s free-as-in-beer and online!

{ 1 comment… read it below or add one }

Leave a Comment

{ 1 trackback }

Previous post:

Next post: