検索対象: The Best Software Writing I. Selected and Introduced by Joel Spolsky
ABOUT THE AUTHORS Kevin Cheng is an independent user experience specialist and global nomad. He hOldS a master's in human-computer interaction and ergonomics from the University College London lnteraction Centre (UCLIC) and has spoken at UXNet, UPA, and ACM-SIGCHI. He is the cofounder and cocreator Of OK/Cancel (www.ok-cancel.com/, an online site believed to be in the top five of usability and HCI-themed comics. Tom Chi has a Masters Degree in Electrical Engineering, which proba- bly means he's qualified neither t0 talk about HCI nor t0 write any sort 0f funny thing. Yet, week after week he dreams the impossible dream at ok-cancel. com. AS for credentials, there is the small matter Of having designed UI features for two releases 0f Microsoft Out100k, as well as his dark history of consulting for F500 clients—but these are topics that civilized people shouldn't speak of. Shhh. Cory Doctorow (craphound.com/ is European Affairs Coordinator for the Electronic Frontier Foundation (www.eff.0 て g ) , a member-supported non- profit group that works t0 uphold civil liberties values in technology law, policy, and standards. He represents EFF'S interests at various standards bOdies and consortia, and at the United Nations' World lntellectual Property Organizat10n. Doctorow is alSO a prolific writer who appears on the mastheads at Wired, Ma た ら and 0 々 〃 / 4 Sc 〃 magazines, and whose science fiction novels have won the Campbell, Sunburst, and Locus Awards. His novel DO 曜 〃 4 〃 d 〇 舫 ビ Magic Kingdom is a finalist for this year's Nebula Award. He is the coeditor of the popular weblog B0ing B0ing (boingboing. net). Born in Canada, he now lives in London, England. Bruce EckeI ( w血.BruceEckeI.com/ is the author of T ん 〃 た g (Prentice Hall, 1998 , 2nd edition, 2000 , 3rd edition, 2003 , 4th edition, 2005 ) , the Ha 〃 - O 〃 va 立 川 CD-ROM (available on the website), T ん 〃 た g 加 C + + ()H 1995 ; 2nd edition 2000 , Volume 2 , with Chuck AIIison, 2003 ) , and C + + Out (Osborne/McGraw-Hill, 1993 ) , among Others. given hundreds Of presentations throughout the world, published over 150 articles in numerous magazlnes, was a found- ing member 0f the ANSI/ISO C + + committee, and speaks regularly at conferences. He provides public and private seminars and design con- sulting in C + + and Java.
Adam Bos ル or ル ICSOC04 TALK 1 A B05 曜 0 な わ な 々 ro わ 4 わ the 川 05 川 々 0 4 SO ″ ル 4 d お れ 0 〃 ' 怩 れ わ ビ d 0 ん 4 れ d 0 れ ビ 0 ー 舫 ビ ル 4 市 れ g 舫 た 催 s 4 わ 0 so ″ - sc れ 〃 s な じ ea 川 4 レ 0 〃 5 edifices ofrigid CO 川 々 ズ / り ル 4 右 4 ビ 川 - 々 0 co 々 〃 d ル わ 〃 川 4 4 〃 ア 〃 れ れ d , 50 ル ビ れ ビ レ go 4 れ ア ル わ ど 巳 B 〃 ル ビ 4 〃 ア 5 川 4 な CO 川 々 〃 s じ 肥 れ 〃 s な 〃 s ビ ル 耘 ル g ビ 〃 川 々 〃 舫 耘 designs, 川 4 た g ル ビ 川 ル 0 黻 4 わ ル ル the 川 4S5 s , 4 れ d ー わ 05 ど 4 舫 ど 4 わ / c s 舫 4 右 川 4 な e Back 2002 ー ル ro : Whenever somebody gives you a spec for some new technology, if you can't understand the spec, don't worry t00 much. N0b0dy else is going tO understand it, either, and it's probably not going tO be important. This is the lesson of SGML, which hardly anyone used, until Tim Berners-Lee dumbed it down dramatically and suddenly people under- stood it. For the same reason he simplified the file transfer protocol, creating HTTP t0 replace FTP. You can see this phenomenon all over the place; even within a grven technology some things are easy enough tO figure out and people use them (like COM's IUnknown), while others are so morbidly compli- cated (IMonikers) when they should be simple (what's wrong with URLs?) that they languish. 2 1. Adam Bosworth, "ICSOC04 Talk, ” Adam Bosworth's Weblog: Thoughts on computing (http://www.adambosworth.net), November 18 , 2004. See http://www.adambosworth. net/archives/000031. html. Originally presented at the 2nd lnternational Conference on Service-Oriented Computing in New York City. 2. / 0 0 れ So ″ ル 4 entry for April 2 , 2002. On the Web at http : / / w . joelonsoftware. com/news/20020402. html.
26 THE BEST SOFTWARE WRITING I Consider search. I remember the first clunky demos that Microsoft presented when Bill Gates first started t0 talk about lnformation At Your Fingertips5 with their complex screens for entering search criteria and their ability to handle B001ean logic. One of my own products, Access, had the seemingly easier Query by Example. 6 Yet, today half a billion people search every day and what do they use? Not Query by ExampIe. Not B001ean logic. They use a solution 0f staggering simplic- ity and ambiguity, namely free-text search. The engineering is hard, but the user model is simple and sloppy. Consider user interface.When HTML first came out it was unbeliev- ably sloppy and forgiving, permssive and ambiguous. I remember listening many years ago t0 the head, then and now, 0f Microsoft Office, saying contemptuously in 1995 that HTML would never succeed because lt was SO primitlve and that Word would win because Word dOC- uments were SO rich and controlled in their layout. Of course, HTML is today the basic building block for huge swathes of human information. What's more, ln one of the unintended ironres of soft 、 vare history, HTML was intended to be used as a way to provide a truly malleable plastic layout language that would never be bound by 2-dimensional limitatlons—lronic because hordes Of CSS fanatics have been trying tO bind it with straightjackets ever since and bad-mouthing tables, and gen- erations Of tOOls have been layerlng pixel-precise 2-dimensional layout on top of it. And yet, ask any gifted web author, like Jon Udell, and they will tell you that they often use it in the lazy, sloppy, intuitive human way that it was designed t0 work. They just pour in content. ln 1996 1 was at some Of the initial XML meetings. The participants' anger at HTML for "corrupting" content with layout was intense. Some of the initial backers of XML were frustrated SGML folks who wanted a better, cleaner world in which data was pristinely separated from pres- entation. ln short, they disliked one Of the great success stories Of software history, one that succeeded because Of its limitatlons, not 5. lnformation At Your Fingertips, or IAYF, was the 、 'vision" BilI Gates laid out for Microsoft to work on in the early 1990S , before the lnternet happened. ー Ed. 6. Query by Example is a user interface that lets you search a database for rows by entering a new row with some 0f the values filled in and the rest of the values left blank. Then you press a button and the database engine returns a list Of all the rows that match those part1C- ular values. So for example if you entered a row with 。 、 く 18 " ⅲ the age field and "NY" ⅲ the State field, you'd get a complete list of people under the age of 18 in New York. ー Ed.
ADAM BOSWORTH 27 despite them. I very much doubt that an HTML that had initially shipped as a clean layered set 0f content (XML, layout rules—XSLT, and formatting—CSS) would have had anything like the explosive uptake. Now I backed XML in 1996 , but as it turns out, I backed it for exactly the opposite reason. I wanted a flexible, relaxed, sloppy human way t0 share data between programs, and compared t0 the RPCs and DCOMs and IIOPs of that day, XML was an incredibly flexible, plastic, easy-golng medium. lt still is. And because it is, not despite it, it has rap- idly become the most widely used way to exchange data between programs in the world. And slowly, but surely, we have seen the other Older systems collapse, crumple, and descend toward irrelevance. Consider programming itself. An unacknowledged war goes on every day in the world 0f programming. lt is a war between the humans and the computer scientists. lt is a war between those whO want simple, sloppy, flexible, human ways t0 write code and those wh0 want clean, cr1SP, clear, correct ways tO write COde. lt is the war between PHP and C + + /Java. lt used t0 be the war between C and dBASE. Programmers at the level of those who attend Columbia University, programmers at the level of those who have made it through the gauntlet that is Google recruiting, programmers at the level Of this audience are all people whO love precise t001S , abstraction, serried ranks Of orderly propositions, and deduction. But most people writing COde are more like my son. COde is just a hammer they use t0 d0 the j0b. PHP is an ideallanguage for them. lt is easy. lt is productive. lt is flexible. Associatrve arrays are the back- bone of this language, which, like XML, is therefore flexible and self-describing. They can easily write code that dynamically adapts t0 the information passed in and easily produces XML or HTML. For them, the important issue is the content and the community, not the technology. How do they find the right RSS feeds? How do they enable a community tO collaborate, appoint moderators, and dynamically decide whose posts can go through and whose should be reviewed ~ How dO they filter information by reputation? These are the issues that they worry about, not the language ・ ln the same way, I see tWO diametrically opposed tendencies in the model for exchanging information between programs today: On the one hand we have RSS 2.0 or Atom. The documents that are based on these formats are growing like a bay weed. N0b0dy really cares which one is used because they are largely interoperable. B0th are
WHY THE LUCKY STIFF 271 Concerning Commercial Uses of the (Poignant) Guide The (Poignant) Guide is released under a Creative Commons license that allOWS unlimited commercial use Of this text. Basically, this means you can sell all these bootleg copies of it and keep the revenues for yourself. I trust my readers (and the world around them) to rip me 0 圧 丁 0 put out some crappy Xerox edition with that time-tested clipart of praying hands on the cover. Guys, the lawsuits just ain't worth the headache. SO l'm just going to straight- up endorse authorized piracy, folks. Anybody who wants to read the book should be able to read it. Anybody who wants to market the book or come up with special editions, l'm flattered. Why would I want the $ $ $ ? IGNORE ALL OTHER SIDEBARS: l'velost the will to be a rich slob. Sounds inhuman, but I like my little black-and- white television. Also my hanging plastic flower lamp. I don't want to be a career writer.. Cash isn9t going inspire me. Pointless. So, if money means nothing to the lucky stiff, why rip me off when you could co-opt shady business practices to literally crush my psyche and leave me wheezing in some SOOty iron lung? Oh, and the irony of using my own works against me! Die, Poignant BOY! TO give you an idea of what I mean, here are a few underhanded concepts that could serio usly kill my willpower and force me to reconsider things like existence. IDEA ONE: BIG TOBACCO Buy a cigarette company. Use my cartoon foxes tO fuel an aggressive ad campaign. Here's a billboard for starters: ヤ 0 れ 一 & し 、 k ・ f ( を し ヤ e ( ツ を 幵 eveR / Make it 0 ト ⅵ ous that you're targeting children and the asthmatic. Then once you've got everyone going, have the truth people dO an expose on me and my farm of inky foxes.
84 THE BEST SOFTWARE WRITING I genius, some deep wisdom that transcends every thought process that came before, that they are the fulfillment of the Macluhanist prophecy. Except there are an awfullot 0f amazingly smart people wh0 never gave a damn about Cascading Style Sheets, working for nonprofits, selling things, building things. And many of them, unlike many of us, still have jobs doing what they love. You have to wonder how great the Web really is, if SO many Of its staunchest advocates can't make a living working tO improve it. I think it's time t0 step back and say, "ls all this really worth a11 the fuss? ' ' Of co 〃 ビ you can guess my answer,8 but I think it's still an lmportant question tO ask. L00king at Processing, I find myself thinking: I wish the Web worked like this. I don't wish the Web was a collection of little clickable graph- ics, but rather I wish that people would take a step back and 100k at everything we've done and "elegantize" the Web as a construct, define a set Of core goals that web developers want tO SOlve, and create as small a language as possible, based on the smallest possible set 0f principles, that will help them meet those goals. At this point in my life as a web developer, I don't want tutorials on hacking my CSS so it 100kS good in IE 5.2 for the Macintosh (l'm about to give up on that very thing, in fact, after dozens Of hours); rather, I want an answer tO the question "What iS a I don't 、 vant someone tO make it easler, another Dreamweaver or FrontPage, I want it to be ど ル ga 厩 , like the computer language Scheme is elegant. I want tO know: 1. What is a web page?Where does it begin and end? ls such a con- cept useful, or should we see the web page as a single view 0f a much larger database Of interlinked documents? 2. ls the browser the right way to navigate the Web? lt's okay for viewing HTML pages, but l'd much rather have a smart data- base/spreadsheet that lets me search the Web and my local files, and pops up a browser when I want one. That is, like Google, but inside Excel. A huge portion Of web content is metadata—search boxes, tables Of contents, navigation, most recently added. Just as sites can have a single, tiny icon that appears in the URl naviga- tion bar, wouldn't it be useful for them to have a single navlgation system that iS available at the top Of the site? 8. l've written the world's only 200-megabyte personal ad in the form of a website.
BRUCE ECKEL 75 expression Of concepts is simply not worth the danger—even if that ben- efit is a productivity increase Of 5 tO 10 times over that Of Java or C 十 十 . What happens when such a problem occurs in a Python program— an object somehow gets where it shouldn't be? Python reports all errors as exceptions, like Java and C# do and like C + + ought to do. So you do find out that there's a problem, but it's virtually always at runtime. "Aha ! " you say, "There's your problem: you can't guarantee the correctness Of your program because you don't have the necessary C01 れ - pile-time type checking. When I wrote T ん 〃 た g C + + , 7 計 E 市 行 0 〃 (Prentice Hall PTR, 1998 ) , I incorporated a very crude form of testing: I wrote a program that would automatically extract all the code from the book (using com- ment markers placed in the code t0 find the beginning and ending of each listing), and then build makefiles that would compile all the code. This way I could guarantee that all the code in my books compiled and so, I reasoned, I could say, "lf it's in the book, it's correct. '' I ignored the naggmg VOice that said, 、 。 Compiling doesn't mean lt executes properly, because it was a big step tO automate the COde verification in the first place ()s anyone wh0 100kS at programming books knows, many authors still don't put much effort intO verifying COde correctness). But naturally, some 0f the examples didn't run right, and when enough of these were reported over the years I began tO realize I could no longer ignore the issue Of testing. I came tO feel SO strongly about this that in the third edition of T ん 〃 た g ル , I wrote: lfit's not tested, it's broken. That is to say, if a program compiles in a statically typed language, it just means that it has passed some tests. lt means that the syntax is guar- anteed tO be correct (Python checks syntax at compile time as well— Just doesn't have as many syntax constraints). But there's no guarantee Of correctness just because the compiler passes your code. If your code seems tO run, that's alSO no guarantee Of correctness. The only guarantee of correctness, regardless of whether your lan- guage is statically or dynamically typed, is whether it passes all the tests that d 〃 〃 舫 じ 0 e じ ビ ss 0 ー ア 0 〃 r 々 og 川 . And you have tO write some Of those tests yourself. These, Of course, are unit tests, acceptance tests,
COLOPHON We adopted the cover of this book from the title page of the first com- plete English edition of Euclid's E ル な , published in 1571. lnterestingly enough, that book was translated from the Greek by Sir Henry BilIingsIey, who became the Lord Mayor of London. ()e aren't sure whether any politicians since then would have the knowledge of both mathematics and Greek needed to do such a wonderful job. ) Also noteworthy is that Billingsley relied on John Dee for help in the transla- tion; this is the same JOhn Dee WhO became famous in fantasy literature—for example, in H. P. Lovecraft's short story "The Dunwich Horror. ' ' (Actually, most scientists Of his time, including Newton him- self, straddled the worlds of science and magic. ) Anyway, John Dee contributed a wonderful preface t0 this book that argued the central lmportance Of mathemat1CS in the artS and sciences— 、 Of course endeared him tO all subsequent mathematicians such as our publisher, Gary Cornell. After all, it said, among other things O comfortable allurement, 0 ravishing persuasion to deal with a SC1ence Whose subJect iS SO ancient, SO pure, SO excellent, SO surrounding crea- tures, so used of the almighty and incomprehensible wisdom of the Creator. Still, as important as this translation is, it lsn't without its problems; most noteworthy is that the original title page (shown here) has an error: Billingsley ascribed the E ル 川 れ な to the wrong Euclid, EucIid of Megara, who alas, was not the Euclid of Alexandria who worked and taught at the great library and actually wrote the E 川 な ! Our copy 0f the title page comes from a copy held at the Bancroft Library of the University 0f California at Berkeley. lt was scanned for us at 2400 dpi by the nice folks at Bancroft Library. The usual foxing found in a bOOk SO 01d was removed and the Other needed modifications made t0 the title page through the wizardry 0f Kurt Krames, Apress's chief designer, using Ad0be Ph0toshop 7 on a Mac G4.
PAUL FORD That's one website, for one person. T00 much. 83 TeX is extraordinarily flexible in what it defines a book to be, and what might go into a book, and it has been used to publish thousands of works. But it's ultimately two small, homely languages: TeX for the lay- out and MetaFont for the glyphs, with a variety of sublanguages and libraries available to extend it. Suites like Adobe's InDesign, Photoshop, and lllustrator combo seem to address a similar problem: they provide a consistent envlronment, in thiS case one Where you P()111t and CIiCk instead 0f programming, for doing work. A problem is solved in one place, ln one envlronment, 、 vith one set Of tOOlS. Websites are not any more complicated to produce than books—and in fact are much less complicated in many ways—but the book produc- tion process is codified and clearly established; there are norms, a clear division Of labor, and an understanding Of what comes next at each point. Read a few manuals 0f typography and visit a publishing plant, 100k at a Heidelberg press, then talk to an editor at a large publishing house. If you cut your teeth on the Web, the process will seem agoniz- ingly slow and inflexible—for example, the demand for the latest Harry Potter pushed back dozens of other books so that the multimillion-copy first edition of Rowling's book could be shipped. On the lnternet, you can simply snap a few new servers intO place, buy more bandwidth, and meet demand. But you'd have to figure out who to call first, and figure out all man- ner 0f switchover and high-availability processes before you could do this; it's possible, but not easy. SO, all right, in the publishing world there's less flexibility, but less sobbing in terror. Because the web devel- opment process is horrifying. There is no point where you can say with total confidence, "l'm done. " Right now I am fielding steady complaints concerning this website from users Of Macintosh lnternet Explorer 5.2. l've done about 10 different things to make this site passable in their browser of choice, but with no 応 ck. 7 The drawing board continually beckons, as does the possibility 0f failure—because some problems gen- uinely cannot be SOlved, not without resources, tlme, and research, and all three are in short supply for those who must get the site up by 9 p. m. Sunday night. I think part of the problem is that the web folks are still riding high on the new economy hubris, believing that they have some special 7. This site is, in truth, the dumbest possible hobby I could ever choose.
product cost, 238 product need, 237 technical support, 241 REST (RepresentationaI state Transfer), 86 ー 87 INDEX 301 syntax and punctuation, 269 ー 70 variables, 274 RuntimeException, 70 runtime VS. compile time type revolution in social software, 194 checking, 75 rhetorical tradition vs. logical tradition, 91 Ries, AI, 240 Ritchie, Dennis, 267 RSS, 27 Ruby arrays, 282 block arguments, 281 blocks, 280 class methods, 278 class variables, 280 computer language or coderspeak, 269 constants, 276 data types, 275 , 276 discussron 0f code examples, 286 ー 87 , 289 do/end blocks, 281 global variables, 279 hashes, 283 lnstance variables, 279 keywords, 285 method arguments, 278 method chaining, 278 methods, 277 operators, 284 parts 0f speech, 273 pipe character block argument delimiter, 281 ranges, 282 regular expressions, 284 salesmen character traits, 228 compensation effects, 226 defining characteristic, 225 description, 224 management of, 227 , 228 skill set, 226 and small software vendors 230 sales Of software. ど ビ software sales SC1ence fiction, software in, 36 Scrum Master, 158 search Microsoft vs. Google, 8 simple vs. complex design, 26 Semantic Web, 87 ー 88 Senate Bill 88 , 64 Seven Pillars of Wisdom, 33 SHOE (Simple HTML ()ntology Extensions), 87 Sifry, Dave, 29 , 32 SimCity, Windows compatibility, 47 Simple HTML Ontology Extensions (SHOE), 87 simple VS. complex software design, 23 ー 24