Jump to ratings and reviews
Rate this book

Beautiful Code: Leading Programmers Explain How They Think

Rate this book
How do the experts solve difficult problems in software development? In this unique and insightful book, leading computer scientists offer case studies that reveal how they found unusual, carefully designed solutions to high-profile projects. You will be able to look over the shoulder of major coding and design experts to see problems through their eyes.

This is not simply another design patterns book, or another software engineering treatise on the right and wrong way to do things. The authors think aloud as they work through their project's architecture, the tradeoffs made in its construction, and when it was important to break rules. Beautiful Code is an opportunity for master coders to tell their story. All author royalties will be donated to Amnesty International.

563 pages, Paperback

First published January 1, 2009

167 people are currently reading
3798 people want to read

About the author

Andy Oram

42 books7 followers

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
423 (28%)
4 stars
479 (32%)
3 stars
435 (29%)
2 stars
126 (8%)
1 star
31 (2%)
Displaying 1 - 30 of 58 reviews
Profile Image for Joshua.
87 reviews15 followers
January 24, 2008
An enjoyable book, but really mis-titled. A more descriptive title would have been:

"Leading programmers describe code they've worked on and are proud of, and then awkwardly wrap some discussion of 'beauty' around it."

However, that's a good book too, and this was. I liked the cross-disiplinary flair, and the ideas that were presented as 'beauty'. It's not a good 'skills' book, but it's a good 'mindsets' book.
Profile Image for John.
32 reviews6 followers
January 28, 2008
Beautiful Code is another non-animal O'Reilly volume, with high aspirations. As the sleeve submits: "How do the experts solve difficult problems in software development?" If this book (or any) had been able to have answered that question, reading it would be a head-spinning experience indeed.

The book's chapters are each the domain of a different prominent software developer or writer, and several are elegant outlines of what is unarguably some of the best code out there - Apache Webserver, Quicksort, and the Python interpreter. Ostensibly, the authors are talented beyond measure; the lack of a cohesive theme, a unified structure, or an overall purpose the book quickly becomes a showcase of beautiful code-essays submitted by thirty-couple completely dissonant geniuses. The fact that the book still contains not much other than what it claims is no invitation for criticism. If you want to see real kung fu code, this is your book.

The potential disparities hide in between the lines, where compilers do not tarry. Few of the essays touch on why the code is elegant, or how it got to be the way it was. Most of them wander around what problem is solved by the code, some delve deep into the minutiae of the problem, and a few contain no code at all. This last set could have been chosen to present a semblance of organization, to have pulled loose ends together and formed some conceptual continuity among a wide variety of articles, but in their current states and places even these well-intended 'theories of code beauty' ruminations are ineffectual.

If a computer scientist was so riveted by unpolished essays surrounding the world's best algorithmic hacks that they failed to notice that no new information was gained, no statements beyond the cold, functional truth were made, no concessions given to that imaginative side of the brain that, when it is given the occasional chance to influence the gnarled digits of a perl hacker, results in that big win that was sought after in wake and sleep for a week and doubles the maintainability and efficiency of some project, then that reader will be satisfied to the fullest extent.

For the rest of us, this book was no great failure but no revelation, and is deserving of its place on the shelf. And the geeks among geeks, the hackers who would have found a book closer to Hackers and Painters, held it and shook it until C code fell out, will no doubt appreciate this book.
Profile Image for Robert.
283 reviews11 followers
March 6, 2008
In Yukihiro Matsmoto's chapter on Ruby he says "Most programs are not write-once ... it is therefore more important by far for humans to be able to understand the program than it is for the computer." That's the essence of beautiful code to me. Unfortunately the book is littered with code that's clever, but not beautiful. There are plenty of chapters that are neither... exercises in what the author hacked together in Perl on their holiday. It's still a fairly interesting read, and I'd rate it more highly if it had been presented as the set of diverse essays that it is and if the editors had culled the weaker material more ruthlessly.This is the first time that I've been truly disappointed by an O'Reilly title.
Profile Image for Christian Brumm.
85 reviews21 followers
October 11, 2012
Some very nice chapters, others below the quality of an average blog post. I guess if you ask (for example) the inventor of a programming language for a chapter it's hard to say "that's crap" in editing. Anyways, poor job in selecting the chapters, could easily be 100 pages.
Profile Image for Noah Sussman.
12 reviews6 followers
Want to read
July 4, 2011
While I didn't finish the whole book, I have read Douglas Crockford's essay on writing a JavaScript parser in JavaScript, and Tim Bray on using regular expressions to extract data from log files.

The Crockford essay is the first article I've ever read on parsing. It's not the first article I've seen on the subject, just the first one I've managed to get through all the way. Crockford's a really good explainer in general, plus the familiarity of the language helped a lot. Now I actually understand what parsing is -- it's like a regular expression, but a more complex and nuanced method of pattern-matching. I've known for a long time that it's impossible to transform HTML using regexes, you have to have a parser. But I never understood why the parser had the advantage. Crockford's essay walks through how a parser analyzes source code, and how it identifies significant tokens.

The Tim Bray essay was also excellent -- I want to read more of his writing. After seeing him speak at An Event Apart this summer, I wasn't surprised that he chose to write about regular expressions for his "beautiful code" piece. He seems to enjoy saying outrageous things, and for most people, calling regexes beautiful definitely would seem outrageous! However, regexes are one of the core tools of the HTML hacker. When I learned Perl's regex syntax, HTML editing jobs that had previously taken days, suddenly took only a few minutes. I'm well-prepared to call regexes beautiful!
Profile Image for Wanasit.
28 reviews4 followers
December 16, 2021
I have learned some things from this book but it is not easy to read and not a happy experience.

First, the code/stories in each chapter are very different and they are not grouped in any order to help the reader (e.g. a chapter about Numpy iterator low-level design, then two chapters about enterprise applications, then a story about Solaris kernel, ...).

For the first 10 or so chapters, I tried to read each chapter from the beginning to the end (one chapter at a time). But, I eventually accepted that, even if I read every word, I'd still not be able to understand "the beauty" in some of the chapters. "How beautiful is the code" would still be subjective and depend on each reader's experience in the field.

Overall, there are several chapters I found very insightful and inspiring. For the rest (50~70%), I mostly just skim or skip.
Profile Image for Anton Antonov.
350 reviews48 followers
August 4, 2024
I have no idea why I read this book in 2017. Skimming through it again to remember what I had in my scarce notes from way back, I realize: “Ah yes, I didn’t learn anything.” 😅

What to expect from the book? Leading programmers—whatever “leading” may mean in 2024 or did mean in 2017—share their thoughts and code snippets of beautiful code.

Beautiful code is subjective, and beauty itself is even more highly subjective. If you want to read opinions from people you may idolize about the beauty of software, this book might be for you.

For me, I expected to learn something new from different perspectives, but I didn’t really.😅
Profile Image for Sandy Maguire.
Author 3 books198 followers
May 31, 2024
Most examples of "beautiful code" in this book are "look at this janky implementation I did." There are a few gems in here, but the most fun I got out of it was critiquing the bad decisions in the book.
23 reviews2 followers
February 29, 2016
Part of my mental picture of an art student is seeing them spending hours in The Louvre, slowly moving from gallery to gallery, studying the works of the great masters. I may have it all wrong. The last time I took an art class was in seventh grade, but it feels right. It seems obvious that part of learning how to create great works of art is internalizing what the world considers great art.

The editors' goal with this book is to create a museum through which the aspiring software craftsman may wander. In this collection of 33 essays, you may find an inspiration for what make great code. Spending every weekend in The Museum of Modern Art will not make you a master artist, neither will reading this book give you mastery of the art of writing beautiful code. What it will do for you is make you think about what makes truly great software.

As my reading ambled through the chapters, I loitered is some and bypassed others. I skipped a few of the writings after only reading a page or two. They didn't speak to me. Others, such as "Theory of Beautiful Code in the Large" and "The Long-Term Benefits of Beautiful Design", are covered with highlighter, marking the thoughts I want to share with others.

In my opinion, to get the most value from this book, two things must be true. You have to have a few years of experience writing software for others. You have to have worked on ugly code, whether it is your own or someone else's, to understand importance of the authors' words. You need to be in a situation where you can share and discuss what you encountered between the pages. True understanding and personal growth will come from blending the nuggets of wisdom with the experience of you and your contemporaries to find your personal style.
Profile Image for Sean Macdonald.
12 reviews2 followers
October 31, 2014
I went in with high expectations because of the title, and the list of contributors. They were dashed. Every so often in the wild I come across beautiful code. It speaks for itself. It is concise and unassuming, yet powerful. I did not come across any in this book (or if I did, i was too dense to see it, which is possible). It seems I am more likely to find beautiful code @ http://codegolf.stackexchange.com/que...
Profile Image for Ioana Balas.
868 reviews88 followers
January 4, 2023
I had high expectations of 'Beautiful Code': I wanted to learn. Learn from how some of the best people in the industry view beautiful code, how they define it, how they work towards it, how they identify smells (for lack of a better word) and any techniques I could replicate too. But this book is borderline unreadable: the essays are disjointed, the quality of writing and explanations is all over the place, and it reads indulgent rather than educational.

There is a vast range of code approached here - from C to Java to Fortran to Matlab and even assembly, and if you are looking to learn how to judge the beauty of code, it becomes quite the exercise if you aren't versed in all of the programming languages it's going to be difficult to grasp all the intricacies you should be criticising. And I would even argue it's not useful to try, Fortran isn't used in the industry today apart from highly specialised weather predictions, and the code presented aged pretty badly with some examples being as old as from the 70s. Other essays were useless for me personally, but other readers might interact with them differently - having read the MapReduce paper by Jeffrey Dean, this abridged version did nothing for me, it's literally a fragment of the paper.

Where was the editor? The contributors seem to have been given complete free reign to the degree that the text turned from teaching to bragging. Also, the quality goes down very rapidly, and some essays don't even feature code, but are more akin to meditations on characteristics of refactored code or high level architectural concepts, like the principles in Ruby.

I did have a favourite, though! The essay on Quicksort optimisation was interesting, a step by step journey into code analysis, how to view performance, how to look under the hood at how each instruction runs. Also towards the beginning of the book was an essay on three-way diffs, how trees model them, and that I also thought was explained well, was approachable yet challenging. Out of the later essays, probably the ones focused on Python, on the internal dictionary implementation and Numpy, were interesting to read about and potentially applicable.
227 reviews1 follower
February 11, 2020
Czytałem tę pozycj�� prawie 2 lata, ale nie temu że była ciężka do strawienia, ale chciałem
się delektować jak najdłużej każdym rozdziałem. W sumie czytałem to jak antologie opowiadań.
Każdy rożdział jest swojego rodzajem podróżą, ale nie np. w światy fantastyczne a w głąb świata IT.
Oczywiście trzeba mieć jakieś pojęcie o komputerach, żeby się zagłębić w lekturę i odbierać jako coś fascynującego, a nie nudną lekturę techniczną.
Jeżeli ktoś uwielbia czytać beletrystykę i przy okazji zajmuję się IT, a w szczególności programowaniem, to mogę mu polecić mu "Piękny k0d"
Niektórym może się wydać za trudna, ale nie fascynatom. Jednak osoby które lubią programowanie, mogą się czuć lekko zawiedzonie, bo czystego kodu jest bardzo mało.
Jednak jest ponad 30 "opowiadań". Każde jest o czymś innym. Nie są ze sobą powiązane, więc możesz je czytać "randomowo". Autorzy tych rozdziałów (a są to gwiazdy, wśród nich np. Yukihiro Matsumoto twórca języka Ruby) opowiadają w swój charakterystyczny dla nich sposób o pięknym kodzie.
I wydanie było w 2007 roku, paręnaście lat temu, a dekada w informatyce to szmat czasu. Jednak większość pomysłów zawartych na pięknych stronach nie straciła swojego uroku. Wyrażenia regularne, kryptografia, jądro Linuxa są obecne dalej w 2020 roku. Jednak parę koncepcji z tej "antologii" odeszło niestety do /dev/null. Trochę się zdezaktualizowało. Jednak to nie jest winą książki.
Polecam.
Profile Image for Gary Lang.
254 reviews37 followers
June 10, 2017
As I read elsewhere, a better description of this book would seem to be “programs I have written and how I would describe them as ‘beautiful’ since the O’Reilly editor asked me to”. It’s fine – I like hearing programmers talk about their work. Not much new here (yet another MapReduce description) but might is probably very instructive and even inspiring for people starting out.
Profile Image for Hao Ca Vien.
74 reviews4 followers
June 16, 2018
Beautiful Code is an insightful journey into the minds of some of the greatest programmers to date. Many hot topics are traversed with explanations, jokes and anecdotes that enliven the journey. Beautiful Code is a true compendium of 2000's greatest programming topics and is a must-read for all aspiring programmers.
58 reviews3 followers
January 18, 2018
Pretty hit-or-miss but the hits (e.g. Rob Pike's regex matcher, the SVN delta tree editor, Simon Peyton-Jones's explanation of software transactional memory, among others) make up for the misses (anything about parsing or generating XML or reminiscing about pet projects).
Profile Image for Timur Koshel.
12 reviews
November 8, 2017
The book has 2-3 (or less) nice chapters. It wasn't worth to read the whole book.
Profile Image for Brian.
12 reviews
Read
October 17, 2016
I'll have to re-read this… I finished it so long ago, I've forgotten what I got out of it. :-(
Profile Image for Mark.
950 reviews82 followers
November 27, 2007
A collection of essays from programmers, some about beautiful aspects of code, some about how a programmer thought about a problem, and some about whatever aspect of programming the writer felt like writing about. Royalties from the book are donated to Amnesty International, which explains why the theme isn't the driving force behind this collection.

This is not a book for beginning-level programmers. Mastery of the fundamentals, such as Code Complete, The Pragmatic Programmer, and their ilk, are far more important than this book.

The individual essays vary greatly, by language, by topic, by application, etc. This variety is both a strength and a weakness. It means you will probably find some essays that are interesting and some that are relevant to you, and you also will probably find some that are not interesting and not relevant to you. A wide range of programming languages are used, and it can be difficult to read essays that are heavily dependent on details of unfamiliar languages.

My main disappointment is that many essays are not written very well for learning. Many essays take the form of "A is beautiful. See me use it here, here, and here." That makes me ask (1) what are other options B,C,D? (2) what differentiates A from B,C,D? (3) what are the weaknesses of A? It's like writing "Solar energy is the best, see the solar panels on my house". That shows the writer likes solar for their particular case, but doesn't really help me decide whether to use solar for my needs. There are definitely precious nuggets buried here, but many of them are unnecessarily hard to dig out.
Profile Image for Yevgeniy Brikman.
Author 4 books722 followers
July 21, 2014
A mixed bag, but overall, worth reading.

Pros: I think programmers do not spend enough time studying the code of others, so books like this are an important step in encouraging the study of this craft. Each chapter of the book is written by a different (often famous) programmer, uses a different language, and discusses a different domain, so you get to see a huge range of different types of code. Multidimensional Iterators in NumPy, Distributed Programming with MapReduce, Beautiful Concurrency, and Writing Programs for the "Book" were my favorite chapters.

Cons: given all the different authors, the quality of the chapters is uneven. A few are boring; a few are interesting, but very tough to follow; a few just discuss high level principles and don't show much code. Also, while I recognize that beauty is subjective, for a prompt of "what's the most beautiful code you've ever seen", a few of the code snippets were questionable.
Profile Image for Dave Peticolas.
1,377 reviews45 followers
October 8, 2014

This is a large collection of articles on the subject of beauty in software engineering. There are some real gems here, including articles by Brian Kernighan and Jon Bentley.

There are also a lot of rather dry articles where the author basically pats himself on the back for some project X he worked on.

I suppose that's what they were asked to write about, but Kernighan, who has no doubt written more beautiful code than any other author, has the class and the tact to pick someone else's code to write about.

I suspect not all the authors would agree with all the aesthetics on display. There's a chapter on debugging some hairy locking issues in the mult-threaded Solaris 8 kernel, which evidently had more locks than San Quentin. Two articles later, another author explains why locks are not beautiful and how the Haskell language manages to avoid them.

Profile Image for Dave.
188 reviews
February 11, 2017
The quality (and my enjoyment) of these essays varied quite a bit. The overall quality seem much higher in the first half of the book, the last half was a big slog for me. I ended up skimming some of them, as otherwise I never would've finished.

It's not just that the essays were outside my areas of interest (I enjoyed some of them for that very reason), but more that they had little of interest to say. The "beautiful code" theme was also rather broadly interpreted. One essay in particular was about some VB6 codebase that even the author admitted was low quality (that particular piece should not have been included in the book).

I'd say the book is worth skimming; some of the essays were very thought provoking.

Not a book that I see myself referencing or even re-reading.
Profile Image for Chris.
18 reviews5 followers
July 3, 2008
Some of the chapters weren't all that great (sorry, but verbosely writing bytecode by hand is *not* beautiful), but a few were *spectacular*. I liked the subversion delta editor, as an interesting interface that looked weird to me but was perfectly suited to its task. I liked the chapter on dealing with a locking bug in the priority inversion code in the Solaris kernel, because after tons of thought and careful analysis, the change they made to the code was tiny and simple to understand.

I especially liked the chapter "Beautiful Concurrency" about Software Transactional Memory in Haskell. STM is really, really neat, but Haskell may be the star of that chapter with how elegantly it includes STM while still letting the code be simple and clear.
This entire review has been hidden because of spoilers.
14 reviews
September 9, 2011
The idea behind the book is sound: experienced programmers tell you about how they solved complicated programs and unique and efficient ways. In practice, the book reads more like a series of success stories, and it almost feels like the programmers are gloating rather than teaching at times. The useful information contained in this book isn't really anything I haven't carried away from other books in a much clearer context. This might be an interesting book if you like the historical factor of some commonly-used programs out there, but as an educational tool, I felt it was lacking in content
Profile Image for Matthew.
35 reviews3 followers
March 26, 2015
What a fantastic book on design. This book is very much a novelty, but I think that most senior software engineers with some design experience under their belt can really appreciate the insight that their peers and/or betters are doing and have done to solve the kinds of challenges you're facing. It's also a good way to tell if your career arc in software is moving towards the kind of software you WANT to be writing, because the projects that were dissimilar to my current work didn't seem like the kind of work I'd want to be working on anyways. Perspective!
Profile Image for David Lindelof.
44 reviews19 followers
August 13, 2011
A collection of 30+ essays on various definitions of what constitutes 'Beautiful' code. Some of the essays are outright brilliant; none is mediocre. One of them helped me break through a programming job I was working on.

The book could be going slowly at some points. Some essays are particularly hard to read/understand. But overall I definitely think that this book will make you a better programmer.
Profile Image for Daniel Schulte.
357 reviews4 followers
September 9, 2013
Great idea. Not executed as well as it could have been. The beginning chapters were awesome and memorable (especially the one about quick sort), however the middle chapters were boring and not really all that interesting. Instead of talking about why things were beautiful, they just talked about their code and their design. I really liked the quicksort chapter and the colinear chapter because they walked us through the thoughts of leading developers.
6 reviews66 followers
September 15, 2007
I've only read bits and pieces of this, but some of the articles I found TRULY WONDERFUL . I suspect, though, that which articles are "wonderful" will depend very much on each individual reader.

My friend Mark Bernstein will probably write a lengthier review on one of his blogs. I will include a link to it when I run across it.
Profile Image for Patrick Boykin.
8 reviews5 followers
January 4, 2008
The idea of this book is excellent since many programmers need to think more about how to build beautiful (not necessarily clever) code. However, not all of the chapters really strike rise to the standard I expected. Overall, it's a nice book to have and to read, but several of the chapters could have been removed, so read the ones that interest you, skip the ones that don't.
Profile Image for Deryck Hodge.
67 reviews7 followers
August 28, 2009
There are some great essays here and some long and winding, less interesting, essays here. I read them out of order and sporadically and enjoyed the book, but there was a part of me that was disappointed. Perhaps there's no way to avoid too high of expectations with a title like this. But overall, certainly worth a read.
Displaying 1 - 30 of 58 reviews

Can't find what you're looking for?

Get help and learn more about the design.