Stephen Hara

Sometimes I Read: Effective C

Published on 11/21/2024

  • post
  • book-review
  • product

Effective C by Robert Seacord

Ask someone how to learn the C programming language, and they'll probably point you to either a several-hundred page book on C programming for Unix, or a several-hundred page book written in 1988 by the creators.

Those books are both excellent, but they're either one or more decades old, extremely comprehensive, and not everyone has that kind of time. Effective C is practical, still very thorough, and the 2nd edition coming soon includes C23! Plus, I used to work with Mr. Seacord, and he's pretty cool.

(Full disclosure: This post includes an affiliate link which, if you click through and purchase the product, will earn me a small commission. This helps support my writing so I can keep writing helpful posts like this!)

Find the book here on Amazon!

Who Should Read It

I think Effective C is a must-read for anyone who:

  • wants to learn the C language as a professional would use it - security and portability standards, debugging, testing, compiler flags...it's all here!
  • wants to learn what can go wrong, why it goes wrong, and how to avoid them from a C perspective
  • wants a cross-platform learning resource of the above

On the other hand, I might not suggest it for anyone who:

  • specifically wants to learn how C is written for Unix, or how Unix works
  • wants to learn how to write something domain-specific like drivers or game programming

Not that it's a bad book for those cases, but you can probably find something more tailored to those topics.

Why To Add It To Your Bookshelf

It's Efficient

The C language is, relatively speaking, simple. This has its ups and downs, but one consequence is that the building blocks and fundamentals of the language don't take a lot of text to cover.

For comparison, Effective C clocks in at 272 pages, the same count as the one-and-only The C Programming Language, but significantly less than another popular C book, C Programming: A Modern Approach with 832 pages!

This mostly comes down to each book's intent. A Modern Approach is very much an instructional book for use in classrooms, with a wealth of exercises and projects to really hammer the concepts. It includes lengthy code examples as well, so it naturally ends up quite thick.

The C Programming Language is basically a reference manual, more like the Python language docs than a textbook. It is a lot more than a bland specification of the grammar, but it doesn't include much discussion of anything beyond the language itself. Actually, a good chunk of it is the two appendices, one of which is a specification, and the other of which is some reference of the standard library.

Effective C ends up covering similar ground to The C Programming Language, but it also adds context to all of it in regards to use in real world applications, common pitfalls to look out for (and how to avoid them), deprecations, platform specifics, and how you can use C constructs to structure a larger C program. The last chapter even covers debugging, testing, and static/dynamic code analysis!

All that to say: it may be a light read among programming books, but you won't have many questions about the language itself, or how to do any of the stuff expected in a professional environment when you're done reading it.

It's Thorough

This is a bit of an extension of the previous point. Another benefit of the language being simple is that filling 272 pages gives a lot of room to be really thorough.

For one example, in the first chapter that demonstrates the classic "Hello, world" program, Seacord goes over IDEs/editors and compilers, and explains how your choices may be affected by your operating system.

For the char and char* (aka string) data types, there is a distinction between ASCII 8-bit (1 byte) characters and 16-/32-bit (multi-byte) characters, where multi-byte characters are called wide characters. In C, this ends up complicating a lot of things: wide characters have a distinct type wchar_t, functions relating to strings of wide characters are in the header <wchar.h> instead of narrow character strings' <string.h>, and even int main has alternative forms as int wmain. All of this is explained very practically in the book, including the fact that Windows has its own layer of stuff on top of all that.

As I said in the last section, once you've read this book, you'll have a really good idea of these little tidbits and details to give you an idea of what to look for if you encounter them in the wild.

It's Really Good

If you've ever tried explaining something you know very well to someone who doesn't know that thing at all, you probably know how hard it is to keep things simple, concise, understandable, and accurate. Seacord does a great job of hitting all of those boxes by keeping things straightforward, including practical and bite-sized examples, and never going far on tangents.

I said C is a simple language. It's a little funny, but I think that extends to the tangents and pitfalls as well. It's not as if the common best practices are unintuitive or a serious subversion of principles. Most of the time, it's just something like "if you're working with macros, make sure to account for these behaviors." Adjustments, really.

Anyway, that's a bit of a tangent itself. It's not a Hugo Award-caliber book, but it isn't dry or bland, and it doesn't get in the way. The contents are as the cover promises: an introduction to professional C programming.

Closing Thoughts

As you may have noticed, I enjoyed Effective C a lot. I personally had never sat down with a C resource before this book, and it helped align my scattered knowledge on a central axis as well as teaching a lot of stuff I didn't know before!

If you want a practical modern resource for C, this book is great. Simple as that.

This page brought to you by Stephen Hara.