Jump to ratings and reviews
Rate this book

The Practice of Programming

Rate this book
With the same insight and authority that made their book The Unix programming Environment a classic, Brian Kernighan and Rob Pike have written The Practice of Programming to help make individual programmers more effective and productive.

288 pages, Paperback

First published February 9, 1999

Loading interface...
Loading interface...

About the author

Brian W. Kernighan

31 books293 followers
Brian Wilson Kernighan is a computer scientist who worked at Bell Labs alongside Unix creators Ken Thompson and Dennis Ritchie and contributed greatly to Unix and its school of thought.

Ratings & Reviews

What do you think?
Rate this book

Friends & Following

Create a free account to discover what your friends think of this book!

Community Reviews

5 stars
835 (43%)
4 stars
624 (32%)
3 stars
353 (18%)
2 stars
71 (3%)
1 star
38 (1%)
Displaying 1 - 30 of 48 reviews
Profile Image for Yevgeniy Brikman.
Author 5 books678 followers
September 26, 2014
The book describes itself as a practical guide to general programming in the real world, but for the most part, doesn't deliver on that promise for a number of reasons.

First, the book should have been called The Practice of Programming in C and C++. The intro chapters say Java, Perl, and others would be discussed, but I'd estimate the C languages make up 90% of the examples and advice. The long discussions of memory management, pointers, and portability do not apply to any of the other languages, or most modern languages in general.

Second, the preface says the book will teach things not covered in school, but the second chapter is a quick, incomplete, and not very rigorous intro to data structures and algorithms straight out of cs 101.

Third, the discussion on coding style is handled much better in other books, such as Code Complete and Clean Code. In fact, I'm not a fan of some of the recommended coding conventions. For example, the book advocates the use of short, abbreviated, and/or single letter variable names in many cases, which made even their short example code hard to read. Also, many of the functions in the code examples were quite long and in need of refactoring.

Fourth, as is often the case with tech content, the book has not aged well. The interface, performance, and portability chapters feel out of date. The fact that functional programming principles (and languages) are missing means this is, at best, a practical guide to purely imperative programming.

Overall: only worth a read for C coders, though a more up to date book would be better.
Profile Image for thirtytwobirds.
105 reviews56 followers
January 2, 2014
Overall: a decent introduction to some of the lessons you'll learn after a few years in the trenches of real programming.

If you're fresh out of college and starting your first programming gig, read this book carefully. A lot of what it says may sound like common sense, but often people don't take it to heart. It will save you pain down the road. Kernighan and Pike know what you're talking about and you'd be wise to listen to them.

If you're already an experienced programmer there's probably not a whole lot here that will be new to you, but it's still worth reading to see how the authors talk about things. And who knows, there may be a lesson or two in it for you after all!

The book is *very* C and C++ focused, with occasional examples in Java, shell and Perl. A lot of the advice in it is specific to C, so if you're not a C programmer you can skim over some of the examples. But the lessons learned from the examples often translate to higher-level languages, so don't skip them entirely!

Oh, and if you're a Lisp programmer you'll want to skip the "Generating Code Using [C] Macros" section unless you have a strong stomach.
Profile Image for Will Semin.
17 reviews10 followers
November 5, 2019
If you are a programmer, you must read it! It is full of good EXAMPLES of how to write better code and design things right.
Profile Image for Dmitriy Shilin.
12 reviews3 followers
January 7, 2017
It's really important to have some expectation before reading this book.

Experienced developers may think that this book is useless for them, because of:
- outdated information
- a lot of C code
- obvious ideas

But I highly recommend them to reread the following chapters:
- Chapter 1 is about style
- Chapter 5 is about debugging that is really important as for experienced developers and newbies.
- Chapter 7 describes different approaches related to performance of your apps.

If you are newbie in a software world I would recommend to read this book and complete all exercises. This book will provide you short description about code style, algorithm and data structures, debugging, testing, etc.

I would like to note the epilogue. It has a UNIX spirit. This book is a core book of your "developer's education".

It's important to read such books because ideas from them will be relevant for a long time.
Profile Image for Nicholas Cotton.
16 reviews
March 14, 2023
This is one of those books that WILL be recommended to you by your computer science professor. I’d recommend chapters 1 and 5 (style and debugging) even to the absolute beginner.

The book mostly uses C and C++ in it’s code examples, which is no surprise given the author. The lessons taught can be applied to any language; however, being able to read C syntax is definitely a prerequisite to this book.
Profile Image for Victor Gaydov.
2 reviews4 followers
May 28, 2021
Pros:

* Gives some good, mostly well known, advice on programming. From somewhat very low-level, like "break up complex expressions", to higher-level, like "detect errors at a low level, handle them at a high level" and even organizational, like "think before typing when debugging".

* Gives a few bright and not so widely adopted ideas. The chapter on testing taught me something new (e.g. the comparison and probabilistic testing approaches). The chapters on portability and notation have made me rethinking of some of my usual practices.

Cons:

* For non-beginner, most of the book may be obvious and boring. It wasn't as inspiring as I expected from this book.

* The book is often way too low-level and focused on implementation and C gotchas. Even in chapter on designing interfaces, the major part of the chapter is devoted to the implementation of a CSV parser in C, in all details, leaving less space for actually discussing the interfaces.

* This book has some focus on C and is certainly UNIX-minded. This is perfectly okay, but makes examples in C++ and Java a bit strange, unless you remember who wrote this book. This may also make this book less useful for people with completely different background.

Summary:

* This book was a bit boring and a bit too low-level, but it was worth it because it gave some valuable insights, though they were only a few in number.

* I think this book can be a good companion to "The Art of the UNIX programming".
Profile Image for Artur.
229 reviews
April 27, 2020
An artifact of its time, the book was written when programming seriously mostly meant programming in C and sometimes some other languages. No wonder this book should have been better named 'The Practice of Programming in C, C++, sometimes Java and occasionally Awk and Perl'. Even though a big part of the text is highly irrelevant to any non-C programmer now(who are in plenty nowadays), there are a lot of great ideas in this book, many of which put start to the tendencies taken as granted in the modern programming practices. The use of testing, modularization, clear and concise programming, use of the right tools for the job and generation of special tiny languages to speak about certain business rules - a plenty of ideas honed in this book bloomed in the decade after.

Would I advise someone new to programming who is not interested in C that much to read this book firsthand? Not really, it did not age that well and a lot of the material is either outdated or can be found almost in the same form elsewhere.
Would I advise it to the battle-hardened programmers or people interested in historic outlook of programming practice who are not scared of abundant amounts of C and C++? Yes, the book was great when it came out and it still holds some of its value in modern context, even though it is not a timeless classic but rather an artifact of its own time.
Profile Image for Senthil Kumaran.
164 reviews19 followers
May 27, 2013
Wonderful book and extremely good advice on programming practice. I realized that this book is not be read in one sitting or in a month. This book is to be taken up for half-a-year to a year of dedicated study and requires solving the problems presented like technical book. So this fits in all the characteristic of a technical book with with problem given at the end of section for the student to attempt. But where the book differs from many of the technical books is, one one teaches style, design and aesthetics of the programming, leading the programmer to appreciate well written programs and encouraging them to practice good programming style. The value is immeasurable. I recommend this to any programmer friend who cares about this craft.
Profile Image for Dave.
53 reviews15 followers
September 5, 2014
Some interesting material, but overall more suited to people at the start of their careers, and very focused on low-level concerns that are relevant for C and C++. Actually, my overriding impression during the book was "look at all this effort to avoid dumb errors in low-level programming languages; I need to never use C again."
Author 1 book4 followers
October 25, 2018
Книжка у меня на полке лежала, по-моему, с первого курса. Я решил, что она уже достаточно вылежалась. Поэтому читал бумажную книгу на русском. В очередной раз убедился, что и бумажные книги читать неудобно, и на русском техническую литературу тоже лучше пропускать.

Сама книга относится к книгам с общими советами по программированию. И я не понимаю, на кого такие книги ориентированы. Опытные разрабочики всё это либо уже знают, либо про это читали где-то ещё. Новички вряд ли много поймут, потому что местами там за отдельными предложениями скрываются целые war stories. Видимо, максимальную пользу могут получить люди, которые какой-то практический опыт написания production-кода имеют, но ещё недостаточно большой (стажёры, джуниоры). Но даже и таким людям стоит поискать что-нибудь посовременнее. В книге немало советов типа "используйте редактор с подсветкой кода" или "автоматизируйте тесты с помощью языков типа Perl или awk".

С другой стороны, общие соображения про стиль, архитектуру, тестирование и отладку работают до сих пор. Пару забавных фактов я узнал, гештальт закрыл, так что о потраченном времени не жалею. Ещё поразило с какой лёгкостью авторы переходят от советов типа автоматизации тестов через скриптовые языки к DSL, интерпретаторам и компиляторам. Это тоже было довольно интересно.
Profile Image for Michael.
8 reviews
July 28, 2022
This style-first practitioners guide still stands up 23 years later. In the preface, the authors ask us to consider some questions related to the difficult, tedious, or annoying scenarios that programmers find themselves in when writing code (i.e., the "not fun" parts). Over the years, I have found these to be refreshing, powerful, and effective rhetorical devices in my ongoing efforts to motivate second-semester programming students to adopt a style-first approach to their, often hack-centered, programming practices. The first chapter focuses on programming style, and the authors practice what they preach throughout the remainder of the book. The code examples are written in C, but the ideas they illustrate can be applied to any programming language. If you teach others to write code, then please read The Practice of Programming by Brian W. Kernighan and Rob Pike.
39 reviews1 follower
November 13, 2022
A very good book with some excellent advice that has stood the test of time and other advice that seems to have largely fallen into the "solved problem" bucket in 2022.

This book had sat on my shelf (I read the physical copy) for a long time as one of those "foundational" books I knew I needed to read. Having finally picked it up and started reading it, I found that I struggled a little bit to get through this book however. A lot of the advice contained within has become "best practice" and repeated over time in numerous other books, articles etc...

While a lot of the rest of it dealt with issues with software development that have been "solved" to a large extent by people taking the advice in this book and building tools and frameworks based on it. In saying that, if you're building desktop applications in C/C++ targeting multiple platforms and architectures, there is still a lot of value that you can get from picking up this book

In that sense, it was a terrific reminder of where the industry came from and in particular was a terrific insight into the Go language and where a lot of the ideas came from for it.
66 reviews
September 8, 2019
Good read for novice programmers. The book introduces the reader to a range of important topics ranging from algorithms and data structures to debugging and performance. It contains numerous code examples and exercises to help students learn. The exercises are particularly useful.

The examples are unfortunately outdated. When the book was written, Java was brand new, as were the C++ STL and '//'-comments (wait, these have not always existed?). People that start learning programming today are more likely to pick up Python or JavaScript than the three languages used in this book. I would be interested to read an updated version, or a modern equivalent.
20 reviews2 followers
March 13, 2022
Old book with lots of good insights about how to become a better developer.
There is a part about testing, where told you stuff like where is more probable that a function will fail. Or another chapter that implements a regular expression parser.

This is a good book if you bought books that you never read, because at the end of the book there is a list with all the rules that builds a strategy to create good software.

The book is from the 90's, but it's content is still relevant.
April 29, 2023
There are a lot of ideas that are timeless and can be used by people who are involved in software development today. But for the most part the book is useful for someone with lots of programming experience in C and C++ just to understand what the authors are talking about. Most of the concepts the authors talk about are only relevant to these two languages and not even a concern in most modern languages. Given how old this book is, it is understandable.
May 2, 2024
I wouldn't recommend to people that don't have any programming experience, but it is still somewhat introdutory.

I didn't find the book reading tiring. It addresses data structures that every programmer should know, some algorithms and pratices that programmers should have, like profiling the code before optimizing.
July 17, 2017
This is a book that every programmer should read many times during their career. I wish I would have read this book many years before as many of the teachings here I learned them with the experience but nevertheless I found it super instructive and will definitely read it again a couple more times.
Profile Image for Wonkybadonk.
79 reviews7 followers
December 26, 2019
While some of the material is a bit dated most of the concepts are still applicable and helpful as a reference, the supplementary readings point you down the rabbit hole for most of the topics that they cover or talk about.
Profile Image for Idir Yacine.
51 reviews2 followers
December 8, 2021
Sadly the book didn't age well if it's your first book on the craft or as a beginner it's still worth it otherwise you are better off skipping it.
Author 7 books
March 21, 2017
I enjoyed this book very much. From time to time it could be a bit too detailed and technical, but overall it's full of sound and useful advises.
Profile Image for Alex.
37 reviews2 followers
December 16, 2023
This one's been on my reading list for ages. Like the AWK book, it's a mixed bag. On one hand, this is a very approachable, no nonsense book. You won't find philosophical musings here, just straight up (and mostly sensible) programming advice. On the other hand, as other reviewers pointed out, I'm not really sure who this book is meant for.

The first two chapters are a very C centric style guide and a spotty intro to algorithms and data structures. The most notable thing about the algorithms chapter is probably that it includes the buggy version of binary search, so readers beware. Where the book gets interesting is in the final chapters, the ones about debugging, performance and tools. There is some solid advice there that you can see comes from real world experience. Even so, the chapters are very brief, so they only scratch the surface on some topics, especially in the last chapter, the one about tools and little languages.

So is this book worth reading? Yes, but feel free to skim the first few chapters, and focus on the second half of the book. And if there's one thing I took away from this book, it's that you should be relentless in keeping your programs simple and clear.
Profile Image for Max Galkin.
22 reviews47 followers
July 30, 2012
I had a mixed impression, the book seems to be a set of loosely related chapters, more like a collection of various experiences of authors ranging from some very narrow hardware-specific topics to very broad high-level abstract advices. Can't really recommend the book to beginners, as many of them will probably never face the specific problems mentioned in some chapters and the composition of the book makes it hard to learn any aspect of programming as a whole, but neither is this book tailored for experienced developers, who might find some chapters trivial like Data Structures and Algorithms 101. There are better books to learn that kind of material.
With all that said, there is still some amazing stuff, the kind of you expect from Kernighan and Pike, like the recommendation to consider writing your own mini-language with a just-in-time compiler to solve a particular problem and an example of one.
Profile Image for David.
259 reviews30 followers
March 24, 2008
I really like this book, which bears some semblance in style to Bentley's Programming Pearls. Or maybe it would be more accurate to say that Kernighan and Pike has the same straightforward readability that Kernighan and Ritchie has. Covers aspects of style, debugging and testing, design "in the small", portability, and the pleasure of a good notation. The last chapter (on notation) is my favorite: in the course of about 25 pages, they give a description of, and illustrative code for: a formatting string language a la printf; a regular expression matcher (I think the code here is complete); a compiler for a calculator language; a simple code generator; and a just-in-time compiler.
33 reviews3 followers
September 14, 2008
If you already know how to program well, this book will round out all your rough edges. It is kinda like a finishing school for programmers. The Regex program in the final chapter is a real gem too. Also, it effectively compares several of the compiled and scripted languages in well thought out examples.
208 reviews46 followers
July 23, 2016
This is a very quick read, and something of a classic. There is some dated information -- discussion about immature C++ compilers or early Java compilers, for instance -- but much of the book is timeless. I would love to live in a world where most professional programmers were familiar with this book and, by extension, the AT&T view of programming.
7 reviews1 follower
March 5, 2011
I had high hopes for this book, but I was disappointed. It's a good read for a student, but it doesn't go in any depth in the interesting areas (error handling, for example). Half of the book is dedicated to C/C++ specific issues, and how Java solved that. I enjoyed a bit more the chapter about testing and debugging.
Displaying 1 - 30 of 48 reviews

Can't find what you're looking for?

Get help and learn more about the design.