"C Primer Plus" by Stephen Prata

One of the best beginner programming books I’ve ever read. I wish this would have been the first book I read when I started programming!

"C Primer Plus" by Stephen Prata

This post is part of my Book reviews series, where I share thoughts and impressions on the books I read.

"C Primer Plus" is written by Stephen Prata and published in 2013 as the 6th edition by Addison-Wesley.

💡Topic

Learning to code C as a beginner to the world of programming.

📖Content

Over 17 Chapters and 1'000 pages (it's a biggie, expect to take several weeks to go through it) the book guides you through all the core C primitives that a developer needs to be aware of, at an introductory level. You’ll be presented with everything from memory handling to bit fiddling and advanced data types. 

The author doesn’t assume any pre-existing programming language knowledge, so it is a fantastic resource for those looking to learn programming “the hard way”. 

👩‍💻🧑‍💻 Who is this book for?

Beginning programmers, who want to learn C as their first language. The book assumes no prior knowledge of programming, and thoroughly explains all core concepts needed for someone to learn from the first principles. 

I would argue this is by far one of the best programming books for beginners I’ve ever read. I wish this would have been the first book I read when I started programming. 

👍Likes

There is no pre-assumed knowledge of programming, and the explanations gradually build up from very simple to quite complex ones. The pacing is fantastic, and even though the book takes its time to explain, I believe it's for the better.

The explanations are very, VERY, well phrased. You can see that this book has been used as a university course material, and that it also had 5 past editions already.

Each code example, “listing” as the author calls it, goes through the code and thoroughly explains it, line by line, in simple and easy to understand language.

At the end of each chapter there is a list of "Review Questions" as well as multiple exercises which you can do, with answers provided at the end of the book.

I have found maybe 3 mistakes in over 800 pages, which is a very impressive feat.

The font, typesetting and formatting is just right, allowing for a condensed delivery of content which makes the best out of every page. 

I really liked the size format of this book, which makes it easier to hold and read, considering how heavy it is.

👎Dislikes

The last version of this book is 2013, and it is already showing its age. A new edition would be very much welcomed, with a more simplified approach and less mentions about compiler and standard-specific C implementations.

Several terms used in the book are not really current anymore, e.g the author used “hiding a variable” as a term for what is now referred broadly as “shadowing” - using a variable name inside an inner block scope which is the same as that of a variable outside of the scope

The page thickness is subpar, as they’ve used a recycled paper which is definitely thinner than normal, so you can see through the page the printed writing on the other side; this is quite a disturbing experience, especially in place with lots of blank space on the page where the printing on the other side is shown through.

The author constantly references the differences between the C standards, like ANSI C, C99 and C11. This becomes quite tiring after some point, and doesn’t really align with the objective of the book in my view: teaching first time programmers to code in C. I know that in the arcane world of low level C nerds these details matter a lot, but this book is not really for them, so I see no need to always confuse the reader and make them remember what I think are useless details at the end. 

The code examples could definitely use line numbers, and reference them in the explanations, especially for code listings that stretch over 3 pages.

At the end of each chapter, there are two summary-like sections: “Key Concepts” and “Summary”; I’ve found that their content is so similar that it would be much simpler for the author - and the reader - to concatenate them into a single one. 

🚧 Improvements I would suggest

I have serious doubts that this book will see another edition, even though I think it should!

Here's what I would recommend though, should this ever be the case:

Leave out all the references to different implementation details between C Standard versions; just go for something like C11 and assume readers will only use and care about this one.

Add an entire chapter dedicated to known “watchouts” of memory dangers and other known issues that C programmers should be aware of.

Add more explanation in the "Bit Fiddling" chapter for endianness, network endianness and "standard" ways to handle this in C when writing portable code.

Remove some of the more nitty gritty content (e.g comparing 8 different string manipulation functions in the standard library and their implementations) and replace it with more mid/top-level “best practice” advice and examples on program architecture and management, applied particularly to the C language. There are so many wonderful examples out there currently on gifted programmers using C to create great code (e.g TsodingDaily’ channel) to take inspiration from for such content

Recommended some FOSS C-focused repositories as “Further Reading”, to deepen some of the key concepts highlighted in each section of the book

Add an entire chapter on Security and Defensive coding in C, based on the lessons learned in the industry over the last 10-15 years 

🤔Final Thoughts

This book is clearly aimed at people who are just learning to program in C. Having said that, it's definitely one of the very best at teaching C (I would know because I've read most the top-rated C learning books, more reviews coming soon), and I highly recommend it.

On a more personal note, I wish I would have had the foresight - knowing what I know now - to have learned C as my first programming language, using this book. I believe it would have served me long term much more than having learned Python first. 

If you are at the beginning of your career as a software engineer, this is a fantastic introduction to the world of programming in C. It will give you fundamental notions in how low-level code works, as well as solid context and intuition that will serve you well throughout your career as a software engineer, irrespective whether you go into AI, game development or backend engineering.