1. 37

I know someone who is currently learning to program: they are nearing the end of a short college course. For their birthday, they requested Robert Martin’s “Clean Code” or the Gang of Four’s “Design Patterns”. I really dislike both of those books, so I bought them something else from their birthday list instead.

However, it made me wonder what a good alternative would have been. If someone just asked for a book for a beginning programmer, what would you recommend?

The only one I have and like is Pike and Kernighan’s “The Practice of Programming”. I have a few other books that I like but they aren’t really for beginners. What else is out there?

    1. 18

      “A Philosophy of Software Design” is a good book. It’s based on the author’s teaching experience so seems like it’s at the right level. “The Practice of Programming” is also great, as you said :).

      A book that’s not recommended a lot, but is in roughly the same category as Kernighan and Pike’s is “Writign Solid Code”.

      Maybe “Programming Pearls” would be a good choice too. “Software specifications and requirements” by Jackson is a collection of essays about programming and it comes highly recommend by Jon Bentley.

      Plauger’s “Programming on Purpose I” has some good essays.

      A more specialized, but still accessible read is “Invariants: A generative approach to programming”.

      And since we’re in the specialized area, I can’t help mentioning “From mathematics to Generic Programming”, if they are somewhat mathematically inclined.

      1. 3

        Thanks! “A Philosophy of Software Design” has been recommended by a few commenters here - it definitely seems like the closest fit to “Clean Code” in terms of target audience, while actually being a good book.

        I hadn’t heard of “Writing Solid Code” - I couldn’t quite tell from the reviews whether it was suitable for beginners or not… I guess I’ll just have to buy a copy and see what I think.

        1. 1

          While I love Writing Solid Code (it was one of the few books that really changed how I approach programming), all the examples are in C (it was written in the 90s). While some of the advice in the book is still applicable today, I’m not sure of the value to someone learning programming for the first time. Especially if they aren’t learning C.

          1. 1

            Fair enough. IIRC there’s plenty of language agnostic advice, but it’s been a while since I read it, so I may be exaggerating the ratio of C specific to generic advice.

            Then again, TPoP is also quite C heavy.

          2. 1

            You should be able to pick up a copy of the first edition for a few dollars on ebay. I hear it’s not worth getting the second edition since the changes aren’t that significant (based on an Amazon review, so take it with a grain of salt).

        2. 11

          The Pragmatic Programmer is very good as it discusses not only code but all other activities involving programming: debugging, planning, testing, etc.

          1. 3

            They recently released a 20th anniversary edition as well so it is fairly up to date. I would highly recommend it.

          2. 8

            A Philosophy of Software Design has become my goto recommendation in lieu of Clean Code.

            For people working in Java, Effective Java is a superb recommendation, but that’s a less frequent starting language these days. There are books along the same lines in other languages, and I don’t think it’s bad to have a language specific book. I think most people would benefit from reading at least one language specific book about “programming in the small”.

            David Agan’s book on Debugging is great. It’s concise, has important advice, and I’d recommend it for most programmers who have never read a book on Debugging.

            1. 2

              Thank you, those all look like good options. “A Philosophy of Software Design” looks like the closest thing to Clean-Code-but-actually-good that I’ve seen so far.

              1. 2

                Seconding the Agans book! I gift copies to all the junior programmers I know.

              2. 8

                “Algorithms To Live by” was a good and easy read. Totally different direction than the ones you’re mentioning but it’s good to give beginners a variety of exposure.

                I think if I was serious about helping someone new, helping them program would be better than a book. Maybe give them some coupons “good for an hour of pairing” if they don’t have something to work on you can look at past advent of code problems. Better though, would be finding a topic that excites them (say, web development) and get a book on that topic and go through it with them. Any time someone asks me “how can I learn to code” or “what language should I learn” I encourage them to look for what excited them instead. Staying interested enough to grind away at hours of practice required to program (and not getting stuck) is the hard part. Design patterns etc. are much higher on the Maslow hierarchy of beginner programmer needs.

                1. 5

                  “Algorithms To Live By” is fantastic. It’s a conversational version of “Cracking the Code Interview”, giving high level descriptions of a bunch of computer science problems and using real world examples to ground them.

                  (People don’t believe me when i tell them I used its description of The Secretary Problem to find my wife when I started dating again. Turns out, the algorithms are quite livable.)

                  1. 4

                    Ha, that’s great. Unrelated to the book but it’s a fun tidbit:

                    I met my wife, named Ruby, at a Ruby on Rails meetup.

                    1. 1

                      haha That’s wonderful.

                    2. 2

                      You are going to love this post.

                  2. 7

                    Can you tell us more about the person? It is hard to just give recommendations for programming books.

                    I agree that both of those books would have made lousy gifts.

                    I am a fan of A Philosophy of Software Design by John Ousterhout.

                    1. 3

                      I’m not really looking for recommendations for one particular person: that experience was just what prompted my question. It made me wonder what other options are out there for someone who wants a book like “Clean Code”, i.e. same kind of target audience but not such a lousy book.

                      “A Philosophy of Software Design” seems like it might fit the bill though, thanks!

                      1. 3

                        One book (of two) that changed how I approach programming is Thinking Forth. For a book written in the 80s, it comes across as written in the early 2000s (it’s a mixture of extreme programming and agile, about twenty years earlier and told without the hype) only all the code is in Forth. Even though I never used Forth in my career, it did shape how I approached programming.

                    2. 6

                      I always recommend Soul Of A New Machine to newer developers. While it is not directly about design patterns or anything, it proves the age-old lesson that software is as much of a human problem as a computational one. Its age and staying power shows that while alot has changed in the software industry many of the fundamental problems we face (project management, customer alignment) are some of the biggest. It’s one of those books where you can re-read it at any stage in your career and glean new lessons.

                      1. 5

                        For me, the book which occupies a very special place in my heart is https://en.m.wikipedia.org/wiki/Modern_Operating_Systems. Got a real paper version of it in Russian, it was monumental!

                        Before I read this book, I considered myself mathematician with a curious interest in programming. After this book, I was like “nah, screw theorems, I’d love to code”.

                        In general. I must say I tend to enjoy domain specific books more that the general programming advice: game programming patterns, obey the testing goat, physically based rendering.

                        1. 1

                          Seconding this. I can’t even say why but I’ve reread this book or chapters of it over the years and I just love it.

                          Unfortunately I usually don’t work low-level enough to be a good judge if it’s still “good enough” or if enough happened in the last years that it is not accurate enough, but I suppose if you work with POSIX systems most things still apply.

                        2. 5

                          The New Turing Omnibus is a really cool introduction to computer science (less so programming). I think this book would have gotten me fired up when I was first getting into coding.

                          1. 4

                            “The C programming language” is an excellent book, not for what it explains (programming in C) but for how it explains it.

                            It encourages simple, clean code. It covers the most important programming topics (arithmetic, strings, memory, libraries). It is an extremely elegant and succinct book.

                            Furthermore, every programmer is fated to encounter C code at some point in their life. Even if the recipient of the book never programs a single line of C, they should know C.

                            1. 4

                              Two books I wish I had had 20+ years ago when I was a novice programmer are Code by Charles Petzoid and Crafting Interpreters by Robert Nystrom (@munificent).

                              The first is an excellent introduction to “computing” as a whole, focused on “how to encode real world information into signals that can be interpreted by another human which in turn can be interpreted by a computer”. I don’t think I would have understood it all in my early teens, but it would have given me a much more solid baseline for handling everything that came after.

                              The second is a rock solid dive into “actually building something useful” that touches on all aspects of development in a conversational tone that I would have delighted in. Too many similar books are dry and boring, and having someone make jokes in the text would have helped me stay focused and follow through.

                              1. 1

                                I can second the recommendation for Code, which has a recent second edition. I’m not a programmer by trade (just by hobby) but I didn’t really feel like I had a good grasp of how computers actually worked until I read that book.

                              2. 3

                                I’d recommend Coders at Work as well as well as A Philosophy of Software Design. Coders at work is, perhaps, a bit on the older side at this point in terms of the interviewee list, but it’s got a lot of useful perspectives in it, IMO.

                                1. 3

                                  I think my two favourite, most fun books are Data-oriented Design and The Design and Implementation of the 4.4 BSD Operating System. Both full of widely applicable, timeless, yet specific knowledge. Data-oriented Design is one of those books I keep by my desk, just to be in its presence.

                                  1. 3

                                    “Data-Oriented Design” looks good: some of the reviews seem to suggest it’s more aimed at people with a couple of years of experience though, rather than beginners. What do you think?

                                    1. 1

                                      I think anyone who picks it up and doesn’t grok it will pick it up again when they’ll be able to grok it.

                                    2. 2

                                      Thanks for the recommendation for Data-oriented Design!

                                    3. 3

                                      My son liked Guide to competitive programming even though neither of us is into it (and I don’t even do C++). As long as you do not read it for competitive reasons, this is a really nice intro to many subjects.

                                      I have gifted Pike’s book to an undergraduate, but I think they were not motivated enough (or you can say the school dismotivated them) to read it.

                                      To a person I do not know much about, I might gift Mazes for programmers

                                      1. 3

                                        Great question. For me, the contemporary “antidote” for those books has been “A Philosophy of Software Design” by John Ousterhout. Not only it gave me new tools to reason about design, It made me change some of my habits and opinions of what good code is 15+ years into my career.

                                        I’d add The Pragmatic Programmer (the most recent edition) as a good mix of coding and personal/team/professional practices.

                                        Assuming an interest in professional software development beyond just programming, “The Missing README” is a good beginner-friendly overview.

                                        1. 2

                                          The Little Schemer is a lovely book. While it uses Scheme as a language to explain principles, it isn’t about the language - it teaches one the skill of using recursion. It works all the way up to having the reader derive the Y combinator from first principles, which is an amazing feat for such a thin book. And as a bonus, if they liked it, next year you can get them the Seasoned Schemer :)

                                          1. 2

                                            Concepts of programming languages, by Robert W. Sebesta.

                                            I read a good chunk of it for a semester-long discipline in college, and it’s probably the thing that most shaped my understanding of programming languages in general. I rarely see it mentioned or recommended, so, maybe there are better alternatives, but that’s the one I stumbled upon.

                                            1. 2

                                              can’t beat TPOP imo

                                              1. 1

                                                What’s TPOP?

                                                1. 1

                                                  The Practice of Programming by Kernighan and Pike

                                              2. 2

                                                It’s nice to think that in a discipline such as programming where the ground shifts constantly beneath us that there is something written—if not in stone, at least on paper—that feels like it’s going to last. When I was first starting out, I read books on programming because I had to. There weren’t many other options. So, speaking as someone who spent a good chunk of his adolescent allowance on newer editions of books he already had, I have not experienced any such permanence in dead trees. I do have a few personal favorites I still cherish. (If your friend develops an interest in Lisp or lambda calculus, for example, I have a couple I would recommend.) But, like a lot of genres, programming books also tend to cave to publisher pressure to present a fat spine to sell on the bookstore shelf. Such books, like me, take their sweet time to get to the point.

                                                Nowadays there are a lot of alternatives: blog articles; Wikipedia articles; open standards specifications; version control hosts with open source code, issue trackers, and discussions; Exercism tracks; and Stack Overflow questions and other forums and communities spread across many languages and domains. Not only would I not recommend any one book, I wouldn’t recommend any one thing to all beginner programmers, except to read and write as much code in languages and domains that interest them as possible. Once they pick a direction, the relevant resources follow.

                                                1. 2

                                                  It’s more historical than practical, but I like “Programming As If People Mattered” for showing that frontend has always been a mess.

                                                  1. 3

                                                    I always give beginners SICP

                                                    1. 0

                                                      Cannot go wrong with SICP

                                                    2. 1

                                                      “Expert C Programming: Deep C Secrets” by Peter van der Linden.

                                                      a) it’s a good book

                                                      b) it serves as a reminder why you should not write in C ;)

                                                      Also “Algorithms and Data Structures” by Niklaus Wirth. It’s a bit cumbersome and there must be better books on the topic, but it’s still good.

                                                      1. 1

                                                        I don’t really do books on coding best practices (or much in terms of learning from books in general), but I think broadening their horizon at this stage would be a better use of their time than holy scriptures on what constitutes as “good code” brought down by gurus.

                                                        For example, Is Parallel Programming Hard, And, If So, What Can You Do About It? looks to be a satisfactory introductory book (disclaimer: I haven’t exhaustively read all chapters so far) on parallelism. Best of all, it’s free. From a cursory glance, it seems more focused on the gory CPU implementation details than theoretical exercises in misery like dataflow programming. No judgement on whether that’s good or bad, it depends on where the reader’s interests lie.

                                                        If they are in any way, shape or form interested in anything remotely touching on graphics, machine learning or video games, then get them some linear algebra textbook if they are not already taught that through their college education. Any code trying to solve things already modeled by linear algebra without actually knowing linear algebra is going to be bad code, as many an indie game code base can attest to. I’ve heard Interactive Linear Algebra by Dan Margalit and Joseph Rabinoff is good (and once again free), though I have not read it myself.

                                                        More than any book, I would recommend they read and hack on code from high-profile widely used FOSS software. You’ll get to see which design patterns hold up when applied to 10+ years of technical debt, moving requirements and underfunded volunteer maintenance.

                                                        1. 1

                                                          “Working Effectively with Legacy Code” is a better book than Clean Code, and one that will help most people’s programming careers immensely. Most code people will read and write is going to be code that’s running already and needs to be changed, rather than code that is new and can stand the opinionated weight of Clean Code / GoF brought to bear on it.

                                                          1. 2

                                                            Working Effectively with Legacy Code introduces very helpful language (e.g. “data as seams”) for doing the actual work in existing code bases. I think Clean Code can largely be summarized today as “use linters and auto-formatters where you can, else agree on a style guide” but was written before those tools really existed.

                                                          2. 1

                                                            I loved SICP even though I’ve not really touched Scheme since. However, some of its examples assume a basic familiarity with the sort of mathematics an MIT freshman would know. If you don’t already intuitively know what the chain rule is, using it as a motivating example to illustrate symbolic programming may be a case of NowIHaveTwoProblems. For me, I had a degree in the sciences so no problem, and I am very pleased I worked through it. I understood (and was very up for the fact) that it was a book to be worked through for the intellectual curiosity, not an immediate path to writing useful web apps in python. So, with all of those caveats, I’d heartily recommend it.

                                                            1. 1

                                                              Thank you very much to everyone who replied.

                                                              It seems that A Philosophy of Software Design is the clear favourite!

                                                              Here are the top recommendations:

                                                              5   A Philosophy of Software Design
                                                              3   The Practice of Programming
                                                              3   The Pragmatic Programmer
                                                              3   SICP (with a warning that it requires a mathematical background)
                                                              2   Debugging
                                                              2   Working Effectively with Legacy Code
                                                              

                                                              There were also plenty of recommendations for other sorts of books, ranging from specific technologies and histories to computing in general. Thanks all!

                                                              1. 1

                                                                After they get their feet wet and are comfortable with one language and installing toolchains (maybe the end of semester 2). I’d recommend 7 programming languages in 7 weeks. They’ll miss the nuance, but it’ll help them get away from the “programming is text on a screen” and into “text on a screen is a way of modeling computation”, which I think is a serious step to enlightenment (at least as I know it).

                                                                1. 1

                                                                  I know this is something that is a bit “head first in” of a dive, but they’re extremely useful IMO: K&R C and Introduction to Algorithms by Cormen.

                                                                  1. 1

                                                                    I really liked Object Thinking by David West when I was first learning how to do ‘grown up’ programming and not just the hobby-level hackery that got me through college and my first job. It’s perhaps a little dated now, but I still like it.

                                                                    I’m a ruby guy at heart so anything by Sandi Metz is good.