Synopses & Reviews
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 through Fragility, 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 in the 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 accompany the 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.
Synopsis
In this unique work, leading computer scientists discuss how they found unusual, carefully designed solutions to difficult problems. This book lets the reader look over the shoulder of major coding and design experts to see problems through their eyes.
Synopsis
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 the following contributions: Beautiful Brevity: Rob Pike's Regular Expression Matcher by Brian Kernighan, Department of Computer Science, Princeton University. Subversion's Delta Editor: Interface as Ontology by Karl Fogel, editor of QuestionCopyright.org. Co-founder of Cyclic Software, the first company offering commercial CVS support. The Most Beautiful Code I Never Wrote by Jon Bentley, Avaya Labs Research. Finding Things by Tim Bray, Director of Web Technologies at Sun Microsystems, co-inventor of XML 1.0. Correct, Beautiful, Fast (In That Order): Lessons From Designing XML Validators by Elliotte Rusty Harold, Computer Science Department at Polytechnic University. Author of Java I/O, Java Network Programming, and XML in a Nutshell (O'Reilly). The Framework for Integrated Test: Beauty through Fragility by Michael Feathers, consultant at Object Mentor. Author of Working Effectively withLegacy Code (Prentice Hall) Beautiful Tests by Alberto Savoia, Chief Technology Officer, Agitar Software Inc. On-the-Fly Code Generation for Image Processing by Charles Petzold, author Programming Windows and Code: The Hidden Language of Computer Hardware and Software (both Microsoft Press). Top Down Operator Precedence by Douglas Crockford, architect at Yahoo Inc. Founder and CTO of State Software, where he discovered JSON. Accelerating Population Count by Henry Warren, currently works on the Blue Gene petaflop computer project Worked for IBM for 41 years Secure Communication: The Technology of Freedom by Ashish Gulhati, Chief Developer of Neomailbox, an Internet privacy service Developer of Cryptonite, an OpenPGP-compatible secure webmail system. Growing Beautiful Code in BioPerl by Lincoln Stein, investigator at Cold Spring Harbor Laboratory Develops databases and user interfaces for the Human Genome Project using the Apache server and its module API. The Design of the Gene Sorter by Jim Kent, Genome Bioinformatics Group, University of California Santa Cruz How Elegant Code Evolves With Hardware: The Case Of Gaussian Elimination by Jack Dongarra, University Distinguished Professor of Computer Science in the Computer Science Department at the University of Tennessee. Also, Distinguished Research Staff member in the Computer Science and Mathematics Division at Oak Ridge National Laboratory (ORNL). and Piotr Luszczek, Research Professor at the University of Tennessee. Beautiful Numerics by Adam Kolawa, co-founder and CEO of Parasoft. The Linux Kernel Driver Model by Greg Kroah-Hartman, SuSE Labs/Novell. Linux kernel maintainer for driver subsystems. Author of LinuxKernel in a Nutshell, co-author of Linux Device Drivers, 3rd Edition (O'Reilly). Another Level of Indirection by Diomidis Spinellis, Associate Professor at the Department of Management Science and Technology at the Athens University of Economics and Business, Greece. An Examination of Python's Dictionary Implementation by Andrew Kuchling, longtime member of the Python development community, and a director of the Python Software Foundation. Multi-Dimensional Iterators in NumPy by Travis Oliphant, Assistant Professor in the Electrical and Computer Engineering Department at Brigham Young University. A Highly Reliable Enterprise System for NASAs Mars Rover Mission by Ronald Mak, co-founder and CTO of Willard & Lowe Systems, Inc. Formerly a senior scientist at the Research Institute for Advanced Computer Science on contract to NASA Ames. ERP5: Designing for Maximum Adaptability by Rogerio de Carvalho, researcher at the Federal Center for Technological Education of Campos (CEFET Campos), Brazil. and Rafael Monnerat, IT Analyst at CEFET Campos, and an offshore consultant for Nexedi SARL. A Spoonful of Sewage by Bryan Cantrill, Distinguished Engineer at Sun Microsystems, where he has spent most of his career working on the Solaris kernel. Distributed Programming with MapReduce by Jeff Dean and Sanjay Ghemawat, Google Fellows in Google's Systems Infrastructure Group. Beautiful Concurrency by Simon Peyton Jones, Microsoft Research. Key contributor to the design of the functional language Haskell, and lead designer of the Glasgow Haskell Compiler (GHC). Syntactic Abstraction: The syntax-case expander by Kent Dybvig, Developer of Chez Scheme and author of the Scheme ProgrammingLanguage. Object-Oriented Patterns and a Framework for Networked Software by William Otte, a Ph.D. student in the Department of Electrical Engineering and Computer Science (EECS) at Vanderbilt University. and Doug Schmidt, Full Professor in the Electrical Engineering and Computer Science (EECS) Department, Associate Chair of the Computer Science and Engineering program, and a Senior Research Scientist at the Institute for Software Integrated Systems (ISIS) at Vanderbilt University. Integrating Business Partners the RESTful Way by Andrew Patzer, Director of the Bioinformatics Program at the Medical College of Wisconsin. Beautiful Debugging by Andreas Zeller, computer science professor at Saarland University. Author of Why Programs Fail: A Guide to Systematic Debugging (Morgan Kaufman). Code That's Like an Essay by Yukihiro Matsumoto, inventor o
Synopsis
How do the experts solve difficult problems in software development? In this unique and insightful book, leading computer scientists offer case studies
Synopsis
As programmers, we've all seen source code that's so ugly and buggy it makes our brain ache. And let's be honest, we've all written code like that. With this book, you'll learn to write code that's easy to read and understand. You'll have more fun and your coworkers will love you.
The Art of Coding focuses on the nuts and bolts of programming, with simple and practical techniques you can use every time you sit down to write code. You'll find tips throughout the book, with easy-to-digest code examples, helpful illustrations, and cartoons for fun.
- Learn to pick variable names that are "dense with information"
- Organize your loops and conditionals so they're easy to understand
- Make your comments short and sweet
- Recognize when your code is doing too many things at once
- Write tests that are concise, but thorough
- Master the art of breaking hard problems into many smaller ones
Synopsis
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.
This book contains 33 chapters contributed by Brian Kernighan, KarlFogel, Jon Bentley, Tim Bray, Elliotte Rusty Harold, Michael Feathers,Alberto Savoia, Charles Petzold, Douglas Crockford, Henry S. Warren,Jr., Ashish Gulhati, Lincoln Stein, Jim Kent, Jack Dongarra and PiotrLuszczek, Adam Kolawa, Greg Kroah-Hartman, Diomidis Spinellis, AndrewKuchling, Travis E. Oliphant, Ronald Mak, Rogerio Atem de Carvalho andRafael Monnerat, Bryan Cantrill, Jeff Dean and Sanjay Ghemawat, SimonPeyton Jones, Kent Dybvig, William Otte and Douglas C. Schmidt, AndrewPatzer, Andreas Zeller, Yukihiro Matsumoto, Arun Mehta, TV Raman,Laura Wingerd and Christopher Seiwald, and Brian Hayes.
Beautiful Code is an opportunity for master coders to tell their story. All author royalties will be donated to Amnesty International.
About the Author
Andy Oram is an editor at O'Reilly Media, a highly respected book publisher and technology information provider. An employee of the company since 1992, Andy currently specializes in free software and open source technologies. His work for O'Reilly includes the first books ever published commercially in the United States on Linux, and the 2001 title Peer-to-Peer. His modest programming and system administration skills are mostly self-taught.
Greg Wilson holds a Ph.D. in Computer Science from the University of Edinburgh, and has worked on high-performance scientific computing, data visualization, and computer security. He is the author of Data Crunching and Practical Parallel Programming (MIT Press, 1995), and is a contributing editor at Doctor Dobb's Journal, and an adjunct professor in Computer Science at the University of Toronto.
Table of Contents
Dedication; Foreword; Preface; How This Book Is Organized; Conventions Used in This Book; Using Code Examples; How to Contact Us; Safari® Enabled; Chapter 1: A Regular Expression Matcher; 1.1 The Practice of Programming; 1.2 Implementation; 1.3 Discussion; 1.4 Alternatives; 1.5 Building on It; 1.6 Conclusion; Chapter 2: Subversion's Delta Editor: Interface As Ontology; 2.1 Version Control and Tree Transformation; 2.2 Expressing Tree Differences; 2.3 The Delta Editor Interface; 2.4 But Is It Art?; 2.5 Abstraction As a Spectator Sport; 2.6 Conclusions; Chapter 3: The Most Beautiful Code I Never Wrote; 3.1 The Most Beautiful Code I Ever Wrote; 3.2 More and More with Less and Less; 3.3 Perspective; 3.4 What Is Writing?; 3.5 Conclusion; 3.6 Acknowledgments; Chapter 4: Finding Things; 4.1 On Time; 4.2 Problem: Weblog Data; 4.3 Problem: Who Fetched What, When?; 4.4 Search in the Large; 4.5 Conclusion; Chapter 5: Correct, Beautiful, Fast (in That Order): Lessons from Designing XML Verifiers; 5.1 The Role of XML Validation; 5.2 The Problem; 5.3 Version 1: The Naïve Implementation; 5.4 Version 2: Imitating the BNF Grammar O(N); 5.5 Version 3: First Optimization O(log N); 5.6 Version 4: Second Optimization: Don't Check Twice; 5.7 Version 5: Third Optimization O(1); 5.8 Version 6: Fourth Optimization: Caching; 5.9 The Moral of the Story; Chapter 6: Framework for Integrated Test: Beauty Through Fragility; 6.1 An Acceptance Testing Framework in Three Classes; 6.2 The Challenge of Framework Design; 6.3 An Open Framework; 6.4 How Simple Can an HTML Parser Be?; 6.5 Conclusion; Chapter 7: Beautiful Tests; 7.1 That Pesky Binary Search; 7.2 Introducing JUnit; 7.3 Nailing Binary Search; 7.4 Conclusion; Chapter 8: On-the-Fly Code Generation for Image Processing; Chapter 9: Top Down Operator Precedence; 9.1 JavaScript; 9.2 Symbol Table; 9.3 Tokens; 9.4 Precedence; 9.5 Expressions; 9.6 Infix Operators; 9.7 Prefix Operators; 9.8 Assignment Operators; 9.9 Constants; 9.10 Scope; 9.11 Statements; 9.12 Functions; 9.13 Array and Object Literals; 9.14 Things to Do and Think About; Chapter 10: The Quest for an Accelerated Population Count; 10.1 Basic Methods; 10.2 Divide and Conquer; 10.3 Other Methods; 10.4 Sum and Difference of Population Counts of Two Words; 10.5 Comparing the Population Counts of Two Words; 10.6 Counting the 1-Bits in an Array; 10.7 Applications; Chapter 11: Secure Communication: The Technology Of Freedom; 11.1 The Heart of the Start; 11.2 Untangling the Complexity of Secure Messaging; 11.3 Usability Is the Key; 11.4 The Foundation; 11.5 The Test Suite; 11.6 The Functioning Prototype; 11.7 Clean Up, Plug In, Rock On...; 11.8 Hacking in the Himalayas; 11.9 The Invisible Hand Moves; 11.10 Speed Does Matter; 11.11 Communications Privacy for Individual Rights; 11.12 Hacking the Civilization; Chapter 12: Growing Beautiful Code in BioPerl; 12.1 BioPerl and the Bio::Graphics Module; 12.2 The Bio::Graphics Design Process; 12.3 Extending Bio::Graphics; 12.4 Conclusions and Lessons Learned; Chapter 13: The Design of the Gene Sorte; 13.1 The User Interface of the Gene Sorter; 13.2 Maintaining a Dialog with the User over the Web; 13.3 A Little Polymorphism Can Go a Long Way; 13.4 Filtering Down to Just the Relevant Genes; 13.5 Theory of Beautiful Code in the Large; 13.6 Conclusion; Chapter 14: How Elegant Code Evolves with Hardware The Case of Gaussian Elimination; 14.1 The Effects of Computer Architectures on Matrix Algorithms; 14.2 A Decompositional Approach; 14.3 A Simple Version; 14.4 LINPACK's DGEFA Subroutine; 14.5 LAPACK DGETRF; 14.6 Recursive LU; 14.7 ScaLAPACK PDGETRF; 14.8 Multithreading for Multi-Core Systems; 14.9 A Word About the Error Analysis and Operation Count; 14.10 Future Directions for Research; 14.11 Further Reading; Chapter 15: The Long-Term Benefits of Beautiful Design; 15.1 My Idea of Beautiful Code; 15.2 Introducing the CERN Library; 15.3 Outer Beauty; 15.4 Inner Beauty; 15.5 Conclusion; Chapter 16: The Linux Kernel Driver Model: The Benefits of Working Together; 16.1 Humble Beginnings; 16.2 Reduced to Even Smaller Bits; 16.3 Scaling Up to Thousands of Devices; 16.4 Small Objects Loosely Joined; Chapter 17: Another Level of Indirection; 17.1 From Code to Pointers; 17.2 From Function Arguments to Argument Pointers; 17.3 From Filesystems to Filesystem Layers; 17.4 From Code to a Domain-Specific Language; 17.5 Multiplexing and Demultiplexing; 17.6 Layers Forever?; Chapter 18: Python's Dictionary Implementation: Being All Things to All People; 18.1 Inside the Dictionary; 18.2 Special Accommodations; 18.3 Collisions; 18.4 Resizing; 18.5 Iterations and Dynamic Changes; 18.6 Conclusion; 18.7 Acknowledgments; Chapter 19: Multidimensional Iterators in NumPy; 19.1 Key Challenges in N-Dimensional Array Operations; 19.2 Memory Models for an N-Dimensional Array; 19.3 NumPy Iterator Origins; 19.4 Iterator Design; 19.5 Iterator Interface; 19.6 Iterator Use; 19.7 Conclusion; Chapter 20: A Highly Reliable Enterprise System for NASA's Mars Rover Mission; 20.1 The Mission and the Collaborative Information Portal; 20.2 Mission Needs; 20.3 System Architecture; 20.4 Case Study: The Streamer Service; 20.5 Reliability; 20.6 Robustness; 20.7 Conclusion; Chapter 21: ERP5: Designing for Maximum Adaptability; 21.1 General Goals of ERP; 21.2 ERP5; 21.3 The Underlying Zope Platform; 21.4 ERP5 Project Concepts; 21.5 Coding the ERP5 Project; 21.6 Conclusion; Chapter 22: A Spoonful of Sewage; Chapter 23: Distributed Programming with MapReduce; 23.1 A Motivating Example; 23.2 The MapReduce Programming Model; 23.3 Other MapReduce Examples; 23.4 A Distributed MapReduce Implementation; 23.5 Extensions to the Model; 23.6 Conclusion; 23.7 Further Reading; 23.8 Acknowledgments; 23.9 Appendix: Word Count Solution; Chapter 24: Beautiful Concurrency; 24.1 A Simple Example: Bank Accounts; 24.2 Software Transactional Memory; 24.3 The Santa Claus Problem; 24.4 Reflections on Haskell; 24.5 Conclusion; 24.6 Acknowledgments; Chapter 25: Syntactic Abstraction: The syntax-case Expander; 25.1 Brief Introduction to syntax-case; 25.2 Expansion Algorithm; 25.3 Example; 25.4 Conclusion; Chapter 26: Labor-Saving Architecture: An Object-Oriented Framework for Networked Software; 26.1 Sample Application: Logging Service; 26.2 Object-Oriented Design of the Logging Server Framework; 26.3 Implementing Sequential Logging Servers; 26.4 Implementing Concurrent Logging Servers; 26.5 Conclusion; Chapter 27: Integrating Business Partners the RESTful Way; 27.1 Project Background; 27.2 Exposing Services to External Clients; 27.3 Routing the Service Using the Factory Pattern; 27.4 Exchanging Data Using E-Business Protocols; 27.5 Conclusion; Chapter 28: Beautiful Debugging; 28.1 Debugging a Debugger; 28.2 A Systematic Process; 28.3 A Search Problem; 28.4 Finding the Failure Cause Automatically; 28.5 Delta Debugging; 28.6 Minimizing Input; 28.7 Hunting the Defect; 28.8 A Prototype Problem; 28.9 Conclusion; 28.10 Acknowledgments; 28.11 Further Reading; Chapter 29: Treating Code As an Essay; Chapter 30: When a Button Is All That Connects You to the World; 30.1 Basic Design Model; 30.2 Input Interface; 30.3 Efficiency of the User Interface; 30.4 Download; 30.5 Future Directions; Chapter 31: Emacspeak: The Complete Audio Desktop; 31.1 Producing Spoken Output; 31.2 Speech-Enabling Emacs; 31.3 Painless Access to Online Information; 31.4 Summary; 31.5 Acknowledgments; Chapter 32: Code in Motion; 32.1 On Being "Bookish"; 32.2 Alike Looking Alike; 32.3 The Perils of Indentation; 32.4 Navigating Code; 32.5 The Tools We Use; 32.6 DiffMerge's Checkered Past; 32.7 Conclusion; 32.8 Acknowledgments; 32.9 Further Reading; Chapter 33: Writing Programs for "The Book"; 33.1 The Nonroyal Road; 33.2 Warning to Parenthophobes; 33.3 Three in a Row; 33.4 The Slippery Slope; 33.5 The Triangle Inequality; 33.6 Meandering On; 33.7 "Duh!"--I Mean "Aha!"; 33.8 Conclusion; 33.9 Further Reading; Afterword; Contributors; Colophon;