|
Title: Beautiful Code: Leading Programmers Explain How They Think (Theory in Practice (O'Reilly))
Purchase
Item
Manufacturer: O'Reilly Media, Inc.
List Price: $44.99
Our Price: $29.99
|
|
| Customer Reviews: |
| Beautiful Code: Leading Programmers Explain How They Think (Theory in Practice (O'Reilly)) by O'Reilly Media, Inc. A Book With An Ambitious Title | Ask a number of developers what beautiful code looks like and you'll get different answers. Take those answers and compile them into a book and you'll get this text. I don't particularly find the code in this book beautiful at all, mostly because the code was written years ago when ideas like readability (read Refactoring) were not as important, and where better tools were not available. There are a few chapters where I agree with the author's ideas on beautiful code. However, I find that in these limited cases, the case study that the author presents and the ideas on beautiful code are disjoint. I find it too often that authors re-iterated how short code is beautiful (think Perl), which is not always the case and shouldn't be something that is emphasized too much over readability, maintainability, and extensibility.
My belief is that if you're a college student, this text might give you some ideas on what good code should do (though don't specifically use the code examples, use the ideas). If you work in the industry, your code should look better than the ones presented. | | Beautiful Code: Leading Programmers Explain How They Think (Theory in Practice (O'Reilly)) by O'Reilly Media, Inc. The delusion of programming authorship | I'm willing to give this book at most three stars, mostly because I'd be ashamed to give it its first one star after the authors put so much work into this project, and I did enjoy some of the essays. I don't believe in hounding and harassing authors as was done to Herb Schildt (C author harassed for being a good mentor) and Kathy Sierra (Java authority harassed for being female).
The code in this book isn't Beautiful, and the book fosters an illusion about programming.
Rob Pike's 1998 example of a "regular expression" processor in Brian Kernighan's lead article isn't Beautiful. It doesn't process strings, properly understood; it processes arrays of bytes, and it does so with no apology from Kernighan.
It uses a value parameter as a work area without apology or explanation. Because C is a required language at Princeton for computer science majors, Kernighan feels no need to point this out, while pointing out the unusual, but correct, use of single-trip while.
It is correct in C to change a parameter passed by value ... but philosophically and from the standpoint of interlanguage readability, it's a C idiom used in a context not predeclared to be C.
We've come a long way, and a long way down, from the Algol vision of a publication language if programmers are expected to know a language, C, which has so many flaws, to learn computer science and Beauty itself.
Pike's code also repeats a test in two different functions. Brian's general apologia is that it's "efficient" but a roughly equivalent C Sharp version is only five times as slow...before you improve the latter by determining where possible the handle of the regex (the set of characters and/or strings that the regex MUST start with, which can be found using library facilities in C or C Sharp that execute for the most part fast assembler code).
The beauty in the code seems to be constituted for Kernighan in the fact that Pike wrote this flawed program in one hour with no back-talk.
The rest of the book adheres to this pattern; forced marches, vanity projects and the misuse of terminology (for example, structs are referred to as classes).
The illusion fostered by this book is that "programming" is the ideally single author writing in a flash of intuition some gnomically brief, uncommented, unHungarianized code which cleverly exploits idioms and implicitly defies a background of "dull" code written by clueless corporate drones...a sort of Star Wars urban legend in which the pure and good Beuatiful coders confront the Dark Side.
Writing about a manifestation of this urban legend in 1985, Theodore Roszak wrote (in From Satori to Silicon Valley) "how could they [the Apple kids] believe something so unlikely?"
The belief persists in technical circles that "we are Individuals who would write nothing but Beautiful code, and think naught but Beautiful thoughts, were it not first necessary to get Version 1.0 out the door and identify non-contributors and heretics, who in any way question our self-image as Luke Skywalker and Co." It persists because telling this story to yourself allows you to avoid confronting the objective subordination of the real programmer to essentially uncaring corporations with, in American law, the fiduciary responsibility to Screw U.
The fact is that "programming" is almost always collective, either in the sense of a group project, or in the creation of the first edition of an artifact which is then (even in the case of Linux and suchlike legendary products) taken from the author and transformed into a set, a series of editions which as a group solve a problem which is itself an ordered set.
Programmers rage for the fantasy of being a single author of unchanging deathless code and because they work in industry (sometimes as virtual slaves to Open Source projects, willing slavery being different in no fundamental respect from slavery, period) they never get this. The result?
Actual coding is fetishized and mystified in the real world to the point of a cargo cult, where at one and the same time, everybody wants to be the Author, but any moves, in the real world, towards this position, are considered to be disruptive, and the result is the grand fantasy of the enterprise system in which "coding", having become the nightmare inverse of the creative dream/fantasy, and the work of evilduuers, is supposed to disappear, but returns in the "mere" setting of parameters...using a Turing complete programming language which is normally pretty much of a mess.
Romanticising this process as having anything to do at all with artistic Beauty (the beauty of a Poussin, of the Ninth Symphony, of Death of a Salesman) breaks the connection with truth which is Beauty's mainstay. Nearly all code is poorly written in parallel or serial-over-time groups in which the members have been forced by management to compete with each other to the point, in some shops, of insanity, and most code unfairly structures the lives of countless employees and consumers in a way that systematically deprives them of meaningful control over their lives as employees, customers, investors, patients, or stiffs in the morgue.
An alternative way was shown early on in Algol, the product of a genuine partnership between universities, corporations and government. This effort was destroyed by IBM in favor of the infantile disorder (Fortran) and a few years on, most of the good ideas in C came from Algol, and were taken without acknowledgement.
I was somewhat saddened to see Kernighan involved with this vanity project because in his early work he sketched out a true alternative to the insanity, this being just slowing down and writing code, in whatever language (even Fortran) in a literate way. I met Brian when working at Princeton in 1987, and I felt like Garth and Wayne (Wayne's World) when they meet Alice Cooper: "we're not worthy". But it's clear to me from his essay and others that this beauty is too much in the minds of an American-centric programming culture to inspire.
Beauty is the Beast: in this book it means only doing it as fast as possible using in-jokes and idioms. There is no suffering here; suffering is prohibited as is asking questions such as "what is a string" when all you have are bytes; internationalisation is unmentionable in the Kernighan essay for this reason, as is the fact that both Java and C Sharp are international in their treatment of strings despite their *de minimis* "inefficiency" without any nonsense whatsoever. Dijkstra, the only real authority as far as I can tell on the type of elegance you need in programming, isn't even in the index.
Three stars, and that's because I'm a nice guy. I gave my own book only four stars because I didn't have enough time to do a perfect job and was perfectly willing to admit this. I despise Amazon numbers games, as well. So, Greg and Andy, consider yourself to have gotten a lucky break. | | Beautiful Code: Leading Programmers Explain How They Think (Theory in Practice (O'Reilly)) by O'Reilly Media, Inc. Beauty is in the eye of the beholder | I found the book's concept intriguing. The ability to learn from 33 highly respected members of the programming community is invaluable. I've enjoyed my daily dose of Beautify Code... but one thing caught me by surprise:
Not all samples are beautiful... well in my eyes not all samples/chapters are beautiful.
I'll skip listing the ones I found beautiful, interesting, insightful and educational because I'm sure you will find others that "do it" for you.
All in all I think it's worth giving this book a shot.
PS - I recommend reading Dmitry Dvoinikov's review and the comments associated with it... you'll get a better sense of the book.
| | Beautiful Code: Leading Programmers Explain How They Think (Theory in Practice (O'Reilly)) by O'Reilly Media, Inc. Beauty in the Eye of the Programmer | Beautiful Code is a unique book. It is not bound by a particular system, or programming language, or methodology. Instead, it tries to straddle the entire field of programming with the ostensible aim of exploring beauty in computer code.
What we get is a smorgasborg of essays that posits competing definitions of technical beauty in very different pieces of code. As such, the book becomes a dialectical argument between different conceptions of technical beauty. It may even serve as a rorsarch test to your sensibilities as a programmer. In the process, you may discover algorithms that are startling in their beauty and ingenuity.
Given the broad sweep of the book, the quality of the essays is somewhat of a crap-shoot. What I found more interesting was working out why I found some of the essays elegantly persuasive, whilst others, I found to be a turgid sludge to wade through. In the end, it becomes almost impossible to separate the quality of the writing from the definition of beauty defined in the essay.
Technical beauty is a very strange beast. It is different from the kind of beauty that resides in the curve of Scarlet Johanssen's lips. In physics and maths, there is a tradition of invoking beauty in certain equations. Einstein's equations for general relativity surely merits that description, as does Euler's formula. For me, technical beauty refers to that rare fusion of concision, efficiency and surprisingly deep connections between seemingly unrelated phenomena.
I found that the essays that I liked were the ones that focused on very specific pieces of code. These essays would carefully explain the problem that the programmer was trying to solve, articulate the constraints, and show the straightforward (and usually less elegant) alternatives. They would then go through all the blind-alleys before unveiling the final solution, which would be as surprising as it was elegant. After all, the father of the essay, Montaigne, coined the term "essai", which means attempt in french.
The essays that didn't work would try to describe how the software worked, and skip over the details. But these are technical essays, after all, and without a careful consideration of technique, all that is left is flabby writing. Surprisingly, there were quite a number of essays devoted to scientific programming, with contributions from the writers of BioPerl, Numpy, LAPACK, and the NASA Mars module. Most of these I found rather unsatisfactory, the kind of flabby essays that skipped over interesting technical details. They offered no fundamental insight to how the code was implemented other than the fact that these packages have stood the test of time. The exception was Trevor Oliphant's essay on Numpy, which showed how a powerful iterator implementation can dramatically simplify the organization of a linear algebra library.
How detailed were the techniques? In Henry S. Warren Jr's essay, he describes how one might count bits in C. It's a marvelous essay because through the description of such an elementary operation, Warren illuminates just how close to the metal one can go in a low-level language like C. At the other end of the scale, Jeffre Dean and Sanjay Ghemawat, engineers at Google, describe the MapReduce algorithm, part of the secret sauce that squeezes out information from Google's gigantic parallel arrays of hard-disks and processors.
There is a the famous dictum attributed to Fred Brooks that if you know the data structure of a program, you will know how the program works. The design of the key data structure reveals the inner workings of a piece of software better than any flow-chart ever could. Greg Kroah-Hartman describes an object-oriented design right in the heart of the Linux kernel driver, written in nothing less than C. Here is found one of the scariest looking C macros that I have ever seen. In one of the most twisted pieces of logic, Kroah-Hartman argues that by not simplifying the macro (including such hand-holding as run-type checking), it keeps away people who don't know what they are doing from touching the code. That, for Kroah-Hartman, is beautiful code. Andrew Kuchling's essay explained how dictionaries are implemented in Python. In the process, I finally understood how dictionaries underpin virtually everything in Python, from objects to locally scoped variables. That's why dictionaries in Python need to be as fast as they are.
Two essays introduced me to some radically different programming techniques. Charles Petzold's essay on writing fast image filters shows how you can do custom compilation on very small pieces of code for incredible speed gains. The essay by Andreas Zeller described perhaps the strangest algorithm in the book. He was working a GNU debugger GUI front-end that got broken after the back-end debugger was upgraded to a newer version. Rather that go through each of the 10000 different patches individually by hand, Zeller came up with a perversely beautiful technique to systematically identify which patch broke the GUI front-end.
Some of the essays flew straight over my head, but such is the nature of such an eclectic collection as this. Beauty, some might argue, is the ability to see hidden patterns in the world, so it seems appropriate to mention Brian Kernighan's essay on a terse 35 line C-program that implements a regular expression matcher. It makes extensive use of recursion, of course. | | Beautiful Code: Leading Programmers Explain How They Think (Theory in Practice (O'Reilly)) by O'Reilly Media, Inc. There are better books than this. | If you take the title of this book as its premise, then there are 2 other books that are better both in commentary, thought and detail. Go deeper.
The Practice of Programming (Addison-Wesley Professional Computing Series)
Programming Pearls (2nd Edition) (ACM Press) | | Beautiful Code: Leading Programmers Explain How They Think (Theory in Practice (O'Reilly)) by O'Reilly Media, Inc. Product Description | | 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. The book includes: Chapter 1, A Regular Expression Matcher, by Brian Kernighan, shows how deep insight into a language and a problem can lead to a concise and elegant solution. Chapter 2, Subversion's Delta Editor: Interface as Ontology, by Karl Fogel, starts with a well-chosen abstraction and demonstrates its unifying effects on the system's further development. Chapter 3, The Most Beautiful Code I Never Wrote, by Jon Bentley, suggests how to measure a procedure without actually executing it. Chapter 4, Finding Things, by Tim Bray, draws together many strands in Computer Science in an exploration of a problem that is fundamental to many computing tasks. Chapter 5, Correct, Beautiful, Fast (In That Order): Lessons From Designing XML Verifiers, by Elliotte Rusty Harold, reconciles the often conflicting goals of thoroughness and good performance. Chapter 6, Framework for Integrated Test: Beauty throughFragility, by Michael Feathers, presents an example that breaks the rules and achieves its own elegant solution. Chapter 7, Beautiful Tests, by Alberto Savoia, shows how a broad, creative approach to testing can not only eliminate bugs but turn you into a better programmer. Chapter 8, On-the-Fly Code Generation for Image Processing, by Charles Petzold, drops down a level to improve performance while maintaining portability. Chapter 9, Top-Down Operator Precedence, by Douglas Crockford, revives an almost forgotten parsing technique and shows its new relevance to the popular JavaScript language. Chapter 10, The Quest for an Accelerated Population Count, by Henry S. Warren, Jr., reveals the impact that some clever algorithms can have on even a seemingly simple problem. Chapter 11, Secure Communication: The Technology of Freedom, by Ashish Gulhati, discusses the directed evolution of a secure messaging application that was designed to make sophisticated but often confusing cryptographic technology intuitively accessible to users. Chapter 12, Growing Beautiful Code in BioPerl, by Lincoln Stein, shows how the combination of a flexible language and a custom-designed module can make it easy for people with modest programming skills to create powerful visualizations for their data. Chapter 13, The Design of the Gene Sorter, by Jim Kent, combines simple building blocks to produce a robust and valuable tool for gene researchers. Chapter 14, How Elegant Code Evolves With Hardware: The Case Of Gaussian Elimination, by Jack Dongarra and Piotr Luszczek, surveys the history of LINPACK and related major software packages, to show how assumptions must constantly be re-evaluated inthe face of new computing architectures. Chapter 15, The Long-Term Benefits of Beautiful Design, by Adam Kolawa, explains how attention to good design principles many decades ago helped CERN's widely used mathematical library (the predecessor of LINPACK) stand the test of time. Chapter 16, The Linux Kernel Driver Model: The Benefits of Working Together, by Greg Kroah-Hartman, explains how many efforts by different collaborators to solve different problems led to the successful evolution of a complex, multithreaded system. Chapter 17, Another Level of Indirection, by Diomidis Spinellis, shows how the flexibility and maintainability of the FreeBSD kernel is promoted by abstracting operations done in common by many drivers and filesystem modules. Chapter 18, Python's Dictionary Implementation: Being All Things to All People, by Andrew Kuchling, explains how a careful design combined with accommodations for a few special cases allows a language feature to support many different uses. Chapter 19, Multi-Dimensional Iterators in NumPy, by Travis E. Oliphant, takes you through the design steps that succeed in hiding complexity under a simple interface. Chapter 20, A Highly Reliable Enterprise System for NASA's Mars Rover Mission, by Ronald Mak, uses industry standards, best practices, and Java technologies to meet the requirements of a NASA expedition where reliability cannot be in doubt. Chapter 21, ERP5: Designing for Maximum Adaptability, by Rogerio Atem de Carvalho and Rafael Monnerat, shows how a powerful ERP system can be developed with free software tools and a flexible architecture. Chapter 22, A Spoonful of Sewage, by Bryan Cantrill, lets the reader accompanythe author through a hair-raising bug scare and a clever solution that violated expectations. Chapter 23, Distributed Programming with MapReduce, by Jeff Dean and Sanjay Ghemawat, describes a system that provides an easy-to-use programming abstraction for large-scale distributed data processing at Google that automatically handles many difficult aspects of distributed computation, including automatic parallelization, load balancing, and failure handling. Chapter 24, Beautiful Concurrency, by Simon Peyton Jones, removes much of the difficulty of parallel program through Software Transactional Memory, demonstrated here using Haskell. Chapter 25, Syntactic Abstraction: The syntax-case Expander, by Kent Dybvig, shows how macros-a key feature of many languages and systems-can be protected in Scheme from producing erroneous output. Chapter 26, Labor-Saving Architecture: An Object-Oriented Framework for Networked Software, by William Otte and Douglas C. Schmidt, applies a range of standard object-oriented design techniques, such as patterns and frameworks, to distributed logging to keep the system flexible and modular. Chapter 27, Integrating Business Partners the RESTful Way, by Andrew Patzer, demonstrates a designer's respect for his programmers by matching the design of a B2B web service to its requirements. Chapter 28, Beautiful Debugging, by Andreas Zeller, shows how a disciplined approach to validating code can reduce the time it takes to track down errors. Chapter 29, Treating Code as an Essay, by Yukihiro Matsumoto, lays out some challenging principles that drove his design of the Ruby programming language, and that, by extension, will help produce better software in general. Chapter 30, When a Button Is All That Connects You to the World, by Arun Mehta, takes you on a tour through the astounding interface design choices involved in a text editing system that allow people with severe motor disabilities, like Professor Stephen Hawking, to communicate via a computer. Chapter 31, Emacspeak: The Complete Audio Desktop, by TV Raman, shows how Lisp's advice facility can be used with Emacs to address a general need-generating rich spoken output-that cuts across all aspects of the Emacs environment, without modifying the underlying source code of a large software system. Chapter 32, Code in Motion, by Laura Wingerd and Christopher Seiwald, lists some simple rules that have unexpectedly strong impacts on programming accuracy. Chapter 33, Writing Programs for "The Book," by Brian Hayes, explores the frustrations of solving a seemingly simple problem in computational geometry, and its surprising resolution. |
No item elements found in rss feed.
|