Just A Summary : Category review, everything about review http://www.bofh.org.uk/articles/category/review.rss en-us 40 Piers Cawley Practices Punditry Reading Beautiful Code <p>I&#8217;m reading <cite><a href="http://www.amazon.co.uk/exec/obidos/ASIN/0596510047/justasummary-21">Beautiful Code</a></cite> and it&#8217;s very good indeed. However, you have to feel sorry for <a href="http://www.tbray.org/ongoing">Tim Bray</a> &#8211; his chapter, &#8220;Finding Things&#8221; is excellent, as you&#8217;d expect. The only problem is, he&#8217;s following <a href="http://en.wikipedia.org/wiki/Jon_Bentley">Jon Bentley</a>, author of that perennial classic, <a href="http://www.amazon.co.uk/exec/obidos/ASIN/0201657880/justasummary-21">Programming Pearls</a>. It&#8217;s been a while since I (re)read anything by Bentley and I&#8217;d forgotten how good his <em>prose</em> was.</p> <p>Which isn&#8217;t to say that Tim Bray is a bad writer. Far from it. It&#8217;s just that Jon Bentley is a very good one indeed.</p> <p>Apart from that, <cite>Beautiful Code</cite> is a cracking book so far, and the royalties go to <a href="http://www.amnesty.org/">Amnesty International</a>. You should buy a copy.</p> Tue, 21 Aug 2007 18:49:57 -0500 urn:uuid:6de7ee7b-b1a8-4718-bf1b-31ff7880af37 pdcawley@bofh.org.uk (Piers Cawley) http://www.bofh.org.uk/articles/2007/08/21/reading-beautiful-code#comments The Practice of Programming Review http://www.bofh.org.uk/articles/2007/08/21/reading-beautiful-code Holiday Reading <p>Mmm&#8230; back from Scotland with a chunk of reading done:</p> <p><a href="http://www.amazon.co.uk/exec/obidos/ASIN/0747591059/justasummary-21">Harry Potter And The Deathly Hallows</a>. Mmm&#8230; top notch stuff. Wraps up the series perfectly.</p> <p><a href="http://www.amazon.co.uk/exec/obidos/ASIN/0385611463/justasummary-21">The Book Thief</a>. Wow! Seriously&#8230; wow. Whatever you do, don&#8217;t read the last chapter of this in public. I was a wreck. Beautiful. Sad. Really Sad. Life affirming stuff. Read it.</p> <p><a href="http://www.amazon.co.uk/exec/obidos/ASIN/0141028491/justasummary-21">The Complete Polysyllabic Spree</a>. Nick Hornby writes exceedingly good litcrit/columns.</p> <p><a href="http://www.amazon.co.uk/exec/obidos/ASIN/0321486811/justasummary-21">Compilers: Principles, Techniques and Tools</a> aka The Dragon Book. Good, crunchy computer science full of stuff I&#8217;ve skirted around learning for ages now. I&#8217;m still far from finished with this book. It does feel old fashioned though, and a little light on techniques for implementing highly dynamic languages.</p> <p><a href="http://www.amazon.co.uk/exec/obidos/ASIN/0126339511/justasummary-21">Programming Language Pragmatics</a>. More seriously crunchy computer science; I&#8217;ve only really skimmed the surface of this one so far, but I&#8217;m liking it a lot so far.</p> <p><a href="http://www.amazon.co.uk/exec/obidos/ASIN/1841154938/justasummary-21">The Amazing Adventures of Kavalier &#38; Clay</a>. Another wow. What&#8217;s not to like? Golden Age Comic book history. Close up magic and escape artistry. Nazis! Citizen Kane! Astonishing, page turning, storytelling. No wonder it won a Pulitzer. It might well make you cry too (though not as much as <cite>The Book Thief</cite>)</p> <p><a href="http://www.amazon.co.uk/exec/obidos/ASIN/0198250797/justasummary-21">The Essential Turing</a>. You know how everyone who knows anything about computing tells you that Alan Turing was a genius? They&#8217;re right. I knew they were right before I read <cite>On Computable Numbers, with an Application to the Entscheidungsproblem</cite> (the first paper in this book and the only one I&#8217;ve read so far), but the paper drove home how <em>much</em> of a genius he was. The way he bootstraps from the idea of the Turing Machine to a Universal Turing Machine is just beautiful &#8211; one minute he&#8217;s describing the basic workings of a seemingly simple machine and a few conventions he intends to use and then within a few pages he&#8217;s implementing a Universal Turing Machine and describing it using the kind Higher Order Functions that get &#8216;metaprogrammers&#8217; so excited whenever the come across a language like Ruby. Great, great stuff.</p> Sat, 21 Jul 2007 17:21:00 -0500 urn:uuid:15ae10a7-acec-43b0-8e25-ff3cb7c6fe0d pdcawley@bofh.org.uk (Piers Cawley) http://www.bofh.org.uk/articles/2007/07/21/holiday-reading#comments Review http://www.bofh.org.uk/articles/2007/07/21/holiday-reading Why don't more books work like this? <p>When you read Christopher Alexander&#8217;s <cite><a href="http://www.amazon.co.uk/exec/obidos/ASIN/0195019199/justasummary-21">A Pattern Language</a></cite>, the patterns within the language are interdependent and ordered from big patterns down to small ones. Each pattern has a number and wherever one pattern refers to another it&#8217;s referenced with both the pattern&#8217;s name and its number.</p> <p><a href="http://www.amazon.co.uk/exec/obidos/ASIN/013476904X/justasummary-21">Beck</a>, <a href="0201485672">Fowler</a> and the <a href="http://www.amazon.co.uk/exec/obidos/ASIN/0201633612/justasummary-21">Gang of Four</a> (if memory serves) go one better, wherever they reference a pattern, they give the pattern&#8217;s page number (ah, the joys of computer typesetting). I&#8217;m not sure it&#8217;s an enormous improvement over pattern numbers with the pattern numbers in the running heads, but both practices make the books easy to use.</p> <p>Writing this up as mini patterns, (very roughly based on Alexander&#8217;s pattern format) you&#8217;d have something like:</p> <h3>A Tiny Pattern Language for technical writers</h3> <h4>1. Organizing Principle</h4> <p>You&#8217;re writing a <cite><a href="http://www.amazon.co.uk/exec/obidos/ASIN/019019199/justasummary-21">Pattern Language</a></cite> on paper</p> <p><strong>Without some organizing principle, a random collection of patterns is just that</strong></p> <p>When you&#8217;re organizing material in a book which needs to be usable both as a learning resource and as reference material there&#8217;s a tension between the needs of the new reader who wants each pattern to follow logically from the patterns she has already read about, and the needs of a seasoned pattern user who needs to find details of a specific pattern.</p> <p>It&#8217;s tempting to take the view that a reader is only new once, so it&#8217;s best to arrange the material to suit the reference user and put your patterns in alphabetical order. Don&#8217;t. If your material doesn&#8217;t make sense to the new reader, they&#8217;ll never reach the point where they use your book as a reference.</p> <p>Therefore:</p> <p><strong>Arrange your patterns for new readers. Provide an index and cross references to support reference use</strong></p> <p>Use <cite>Arrange Patterns by Scale(2)</cite> to order your patterns and <cite>Reference by Name and Number(3)</cite> for your cross references. Provide a <cite>Table of Contents</cite> and an <cite>Alphabetical Index</cite>.</p> <h4>2. Arrange Patterns by Scale</h4> <p>You&#8217;re choosing an <cite>Organizing Principle(1)</cite> for your pattern language</p> <p><strong>It&#8217;s hard to understand a pattern without some idea of where it fits in the scheme of things</strong></p> <p>Read <cite>A Pattern Language</cite>, look at the way that each pattern in the book flows from the ones that precede it and leads you on to the patterns that support it. There&#8217;s a huge amount of information in that book, but it just flows. It has The Quality Without A Name.</p> <p>Now read <a href="http://www.amazon.co.uk/exec/obidos/ASIN/1592530079/justasummary-21">Universal Principles of Design</a>, another book which contains a great deal of good information backed up with great pictures and some real research. Each spread in the book is analogous to a Design Pattern, and each spread is great. It&#8217;s a bugger to read though. The designers have chosen to arrange their principles in alphabetical order; reading through is like being taken on a drunkard&#8217;s walk by a conceptual grasshopper. Many of the principles are hierarchical, but the reader is left to work that out for themselves. It reminds me of the joke about reading a dictionary; the content&#8217;s great, but the characterisation and plot are all over the place.</p> <p>Therefore:</p> <p><strong>Find patterns that use other patterns, put them before the patterns they use. Group patterns with a similar scale or motivation in chapters.</strong></p> <h4>3. Reference by name and page number</h4> <p>You&#8217;re referring to a pattern.</p> <p><strong>Why can&#8217;t books be more like the web?</strong></p> <p>We&#8217;ve all done it I&#8217;m sure; one part of a book refers to another part and gives just the section title. We curse the author or his editor and go scurrying off to the table of contents or the index to find the referenced page and then turn to it, all the while keeping our index finger jammed between the pages so we don&#8217;t lose our original place.</p> <p>Or the author has taken pity on us and, following the Chicago manual of style, supplies a section number (with multiple decimal points) and we start flipping forwards or backwards to find the right section number. This is less fun than it could be because no two sections are the same length. Or the content&#8217;s arranged alphabetically, and every section is the same length, but we&#8217;re not entirely sure of how many sections start with any given letter &#8211; I&#8217;m looking at you <cite>Universal Principles of Design</cite>.</p> <p>There has to be a better way. Wouldn&#8217;t it be great if we could just go directly to the right page as if we were following a hypertext link?</p> <p>Indeed it would.</p> <p>Therefore:</p> <p><strong>Whenever you refer to another pattern, use both the pattern&#8217;s name and its page number; that way the reader can turn directly to the right page without having to visit an index or flip hopefully trying to guess how long each section is.</strong></p> <h3>What next?</h3> <p>Obviously we need to hunt down and deliver a good telling off to authors, editors and publishing houses that don&#8217;t follow this pattern language.</p> <p>Would you believe that I started this article meaning to write a review of <cite>Universal Principles of Design</cite>? Despite my grumbles about it above, it&#8217;s a cracking book full of really meaty stuff. I commend it to you all.</p> Sun, 06 May 2007 02:57:00 -0500 urn:uuid:658c2589-bff8-44fa-92e7-75273506df4e pdcawley@bofh.org.uk (Piers Cawley) http://www.bofh.org.uk/articles/2007/05/06/why-dont-more-books-work-like-this#comments Musings Review patternlanguage http://www.bofh.org.uk/articles/2007/05/06/why-dont-more-books-work-like-this Spiers and Boden: Songs <p>Listen to <a href="http://www.squeezy.fsnet.co.uk/spiers_boden/Bold%20Sir%20Rylas.mp3">this</a>. You&#8217;ll not regret it.</p> <p>Whee! John Spiers and Jon Boden have finally made an album (<cite>Songs</cite>) that sounds as good as they do live. Not that <cite>Through and Through</cite> and <cite>Bellow</cite> are bad albums, it&#8217;s just that their playing has improved somewhat since they were recorded. On stage, Jon and John play with an almost telepathic level of communication. <cite>Songs</cite> captures that magic.</p> <p><cite>Songs</cite> is the companion piece to <cite asin="B0009OORKG">Tunes</cite>[1] and it fairly fizzes with excitement. The material is almost all Big Ballads, and these are handled with a freshness and authority that is great to hear. The only ballad here that&#8217;s familiar to me from other singers is <cite>Lucy Wan</cite>, which Martin Carthy does so well. Jon and John give the nod to that version as their inspiration, but the result is entirely their own.</p> <p>There&#8217;s one modern piece, <cite>Innocent When You Dream</cite> by Tom Waits, and it&#8217;s fabulous&#8212;the sort of song that wouldn&#8217;t sound out of place in Peter Bellamy&#8217;s repertoire next to the obscure Dylan covers, big ballads and the Kipling. You can hear Bellamy&#8217;s influence everywhere. He&#8217;s the source for one song (<cite>Derry Gaol</cite>), but Jon&#8217;s singing style has Bellamy written all over it. Like Bellamy, Jon will start a song with a testing range at least three notes higher than seems sensible and then thrill you as he hits all the high note with ease<sup><a href="#fn3">3</a></sup>. And, just like Bellamy, Jon sounds like nobody else<sup><a href="#fn4">4</a></sup>.</p> <p>Buy this CD. And if you get a chance, go and see them live. Good as this album is, these guys are still improving and in a year or so this is going to sound a little bit disappointing compared to what they&#8217;re doing on stage. If they can keep doing that trick, who knows what&#8217;s going to happen.</p> <p id="fn1"><sup>1</sup> Although <cite>Tunes</cite> was released earlier this year, I&#8217;ve not actually listened to it; I&#8217;m more of a songs person I guess.</p> <p id="fn2"><sup>2</sup> A year or so ago I found myself singing a high harmony while Jon sang Bellamy&#8217;s setting of <cite>The Old Songs</cite> at the Cumberland singing session <del>- I was up next and that was the song I was planning to sing so when Jon started in on it I thought &#8220;What the hell?&#8221; and came in with a harmony line -</del> I didn&#8217;t know I could go so high. Those notes are often there if you&#8217;ve got the nerve to really go for them; they only disappear if you don&#8217;t think you can get them.</p> <p id="fn3"><sup>3</sup> There&#8217;s nothing here like Bellamy&#8217;s astonishing <cite>Santa Fe Trail</cite> where, having sung the whole thing at very high altitude he repeats the last chorus singing a high harmony line that leaves you gasping. But some of the stuff he was singing with Bellowhead a few weeks ago was definitely getting that way.</p> <p id="fn4"><sup>4</sup> It&#8217;s the old problem isn&#8217;t it? Bellamy sounded entirely like himself; the best way to follow his lead is to sound entirely like yourself.</p> Sat, 15 Oct 2005 09:22:00 -0500 urn:uuid:b40f5c4b-bf86-4b02-a269-3057a71a1580 pdcawley@bofh.org.uk (Piers Cawley) http://www.bofh.org.uk/articles/2005/10/15/spiers-and-boden-songs#comments Review spiersandboden music folksongs http://www.bofh.org.uk/trackbacks?article_id=spiers-and-boden-songs&day=15&month=10&year=2005 http://www.bofh.org.uk/articles/2005/10/15/spiers-and-boden-songs Had we but world enough, and time: Serenity <p>Joss Whedon&#8217;s <cite>Firefly</cite> was a sf series that was never given time; episodes were jumbled by the network and the show got cancelled just when it was starting to build a serious fanbase. And that&#8217;s all she wrote.</p> <p>Except, as fans of <cite>Buffy</cite> and <cite>Angel</cite> know, Joss Whedon doesn&#8217;t tell the same stories as everyone else. He managed to hold his cast together and found the funding to make <cite>Serenity</cite>. It isn&#8217;t quite the film of series they didn&#8217;t have time to make, but it comes close.</p> <p>Capsule review: I liked it. I liked it a lot. You should see it.</p> <p>For a slightly longer, and possibly spoilery review, kindly step behind this curtain&#8230;</p> <p>I really liked <cite>Firefly</cite>. I pulled the episodes down via bittorrent as they became available and watched them in all their lo-fi glory, putting up with jaggies, out of sync audio and the rest. I bought the DVDs, downloaded the soundtrack and, a couple of weeks ago, went to one of UK&#8217;s &#8220;Can&#8217;t Stop The Signal&#8221; previews of the finished movie and laughed in all the right places as, instead of the usual previews, Joss introduced the film.</p> <p>The film is great. Like most modern sf films, it&#8217;s something of a ride. There&#8217;s even the cliche of the big fight over the bottomless pit in there somewhere. But there&#8217;s snappy dialogue and food for thought too, and some beautifully violent fights (everyone else take note, casting a dancer as your lethal weapon is a good move).</p> <h3>However&#8230;</h3> <blockquote> <p>But at my back I always hear<br/> Time&#8217;s wing&egrave;d chariot hurrying near<br/></p> </blockquote> <blockquote> <p style="margin-top: -1em; text-indent: 2em;">&#8212;Andrew Marvell, <cite>To His Coy Mistress</cite></p> </blockquote> <p>You can almost hear Time&#8217;s chariot as you watch <cite>Serenity</cite>. The shows were never slow, but the film rattles along at astonishing speed: there&#8217;s no time for sitting round the galley table; no time to give sense of lives being lived; no time for Shepherd Book; no time for anything that isn&#8217;t going to be relevant within the space of this film. Most films do this, but it&#8217;s more noticeable when you already know the characters from a TV series.</p> <p>The decision makers at Fox took that time away. The bastards. I <em>really</em> want to see <cite>Serenity</cite> get spun off into another TV series, but the grapevine has it that that&#8217;s not going to happen&#8212;apparently Fox won&#8217;t relinquish the rights. The bastards.</p> <h3>&#8220;If you can&#8217;t do something smart, do something right&#8221;</h3> <blockquote> <p>Thomas More: The last temptation is the final treason,<br/> To do the right thing for the wrong reason</p> </blockquote> <blockquote> <p style="margin-top: -1em; text-indent: 2em;">&#8212;TS Eliot <cite>Murder in the Cathedral</cite></p> </blockquote> <p>If the film has a message, and I think it does, it&#8217;s the same one that Whedon sent in <cite>Buffy</cite> and <cite>Angel</cite>. Morality is about personal choice. When it comes down to it, integrity is all that we have and that integrity only exists if you have the freedom to do the wrong thing. For Joss, the greatest sin is taking someone&#8217;s freedom to sin from them, because by doing that you take away their chance of redemption.</p> <p>Which brings us perilously close to politics, but I&#8217;ll save that for another entry.</p> Fri, 07 Oct 2005 00:51:00 -0500 urn:uuid:1d298c5e-749a-45b2-b270-53d5f5d8c8c3 pdcawley@bofh.org.uk (Piers Cawley) http://www.bofh.org.uk/articles/2005/10/07/had-we-but-world-enough-and-time-serenity#comments Review firefly spoilers review film serenity http://www.bofh.org.uk/trackbacks?article_id=had-we-but-world-enough-and-time-serenity&day=07&month=10&year=2005 http://www.bofh.org.uk/articles/2005/10/07/had-we-but-world-enough-and-time-serenity A bright light on the culinary road to Damascus <p>If you&#8217;ve eaten with me, you might be aware that I&#8217;m not a big one for chili heat. I don&#8217;t mind it, but you won&#8217;t find me chopping up the Scotch Bonnets for a mole or ladling out the chili oil in a Chinese restaurant.</p> <p>If you&#8217;d suggested that I would cook something that involved 3 <em>tablespoons</em> full of chili oil, complete with the sludge of seeds from the bottom of the jar, in a dish for two people I would have thought you had gone mad. If you had then suggested that I&#8217;d love the resulting dish with a passion that made me want to rush off and blog about it&#8230;</p> <p>It all started 4 years ago when I read an <a href="http://observer.guardian.co.uk/foodmonthly/story/0,9950,502317,00.html">article</a> in The <em>Observer</em> by Fuchsia Dunlop about her time in Sichuan Province and how she became the first Western woman to study at the Chengdu School of Cookery, and how she ended up writing a book about <cite asin="0140295410">Sichuan Cookery</cite>. It was a fabulous article, beautifully written and it set my mouth watering as I read it. &#8220;I should get that book when it comes out&#8221; I thought, and promptly forgot about it.</p> <p>A few weeks ago, browsing in the Newcastle branch of Borders, I came across the paperback edition and grabbed it, took it home and read it in short order. Wow. So many Western books about Chinese food (and probably other foreign foods, I only really &#8220;know&#8221; about Chinese food) are full of compromises, on ingredients, recipe choice, cooking methods&#8230; I don&#8217;t want to learn how to make westernised restaurant standards like day glo sweet and sour pork, or chop suey. I want to know how to make Siu Yuk, or the fabulous &#8216;Braised Belly Pork with Sweet Preserved Vegetables&#8217; they do at Mangos, or the amazing &#8216;fried blood&#8217; I once ate with Jon Singer<sup><a href="#fn1">1</a></sup> at a hole in the wall Chinese Restaurant in Washington DC&#8217;s Chinatown.</p> <p><cite>Sichuan Food</cite> definitely goes in the &#8216;authentic&#8217; section of your cookery bookshelf. Heck, it took me about a month to get the store cupboard stocked with basic ingredients and I&#8217;m <em>still</em> trying to find a source for dried sky facing chilies and Sichuan pickled chilies, but tonight I finally cooked something from it. I went for &#8216;Cold Chicken Slices in a Hot and Numbing Sauce&#8217;. The thing was simplicity itself: Boil the chicken (at least free range, in our case organic), for half an hour, cover it in cold water for a couple of hours to cool down, slice the meat from one side, stick it in a bowl with some sliced spring onions, sprinkle a teaspoon of ground roast sichuan pepper over it, pour on a sauce made from the aforementioned 3 tablespoons of (home made) chili oil + sludge, sweetened soy sauce and a splash of sesame oil, mix it up and serve with rice.</p> <p>It was <em>fabulous</em>. I confess that I was prepared to find it inedibly hot, but wow. The combination of flavours and the amazing tingly &#8216;numbing&#8217; sensation from the sichuan pepper took away the burn and let you savour the tastes and textures. I&#8217;d probably eat an old boot if you chopped it up small and covered it with this sauce. But on top quality chicken&#8230; I know what I&#8217;m doing next time we have leftovers from a roast bird.</p> <p>I dunno what I&#8217;m doing next from this book, but I&#8217;m delighted to report that on first showing it&#8217;s at least as good to cook from as it is to read. Definitely one for the shelf in the kitchen with Nigel, Hugh, Elizabeth and Fergus. I just wish I&#8217;d had the sense to remember to buy it in hardback.</p> <p id="fn1"><sup>1</sup> If you ever meet Jon, for heaven&#8217;s sake don&#8217;t play the &#8220;I&#8217;ve eaten weirder Chinese food than you&#8221; game. I actually managed to outweird him on the Japanese stakes, but I reckon we probably managed a Chinese tie by having the fried blood&#8230;</p> Wed, 03 Aug 2005 17:17:26 -0500 urn:uuid:6390d00046c7c8f3d2970fe6c0fed7b5 pdcawley@bofh.org.uk (Piers Cawley) http://www.bofh.org.uk/articles/2005/08/03/a-bright-light-on-the-culinary-road-to-damascus#comments Review http://www.bofh.org.uk/trackbacks?article_id=a-bright-light-on-the-culinary-road-to-damascus&day=03&month=08&year=2005 http://www.bofh.org.uk/articles/2005/08/03/a-bright-light-on-the-culinary-road-to-damascus The Pickaxe Book <p>I can&#8217;t remember when <a href="http://use.perl.org/~ziggy/journal/">Adam Turoff</a> pointed me at <a href="http://www.rubyonrails.com/">Ruby On Rails</a>, but I&#8217;m still grateful. Blame Adam for the fact that this weblog is no longer running on Movable Type, but on <a href="http://typo.leetsoft.com/trac/">Typo</a>. My initial plan was to roll my own blogging software on top of Rails, but by the time I got my act together it just made sense to grab an existing package and extend it as required.</p> <p>I first heard about Ruby when I read Andy Hunt and Dave Thomas&#8217;s excellent book <cite asin="020161622X">The Pragmatic Programmer</cite>. I thought, &#8220;that looks interesting&#8221;, so I read the first edition of <cite>Programming Ruby</cite> aka the Pickaxe Book, learned the syntax and some of the idioms and then sort of forget about it. As a programming language Ruby pushes a lot of my buttons: it has closures, objects all the way down, dynamic typing and its refreshingly concise. However, I never quite got round to writing anything in it (not the language&#8217;s fault, I wasn&#8217;t writing anything in anything at the time).</p> <p>Then along came Ruby on Rails and it&#8217;s lovely. I saw the first version of the <a href="http://media.nextangle.com/rails/rails_setup.mov">Rails Video</a> and it knocked me out. Rails does so much <em>right</em>. Here was a web development tool that did most of the heavy lifting for you, and makes it easy to do things Right. David Heinemeier Hansson was obviously getting a great deal of leverage from Ruby&#8217;s dynamic nature and I wanted some of that.</p> <p>However, I found that Ruby had moved on since I skimmed the first Pickaxe so I got hold of a copy of the second edition of <cite asin="0974514055">Programming Ruby</cite>. What a cracking book it is. My personal benchmark of quality when it comes to a language reference is the first edition of <cite>Programming Perl</cite> which, as well as being a language reference was an introduction to a programming ethos. Whilst I don&#8217;t think the Pickaxe is quite that good, it&#8217;s definitely up there. The chapter on &#8216;Duck Typing&#8217;, for instance, is wonderful. It&#8217;s a well made argument for dynamic typing and it deserves to be widely read. I sometimes think that there are two sorts of programmers in the world, those who think typed <em>values</em> are essential, and those who think typed <em>variables</em> are essential. I&#8217;m definitely a typed values kind of guy. Typed variables have their place, but that place is in the optimization toolbox next to the profiler.</p> <p>Ruby&#8217;s a great language. I don&#8217;t <em>think</em> it&#8217;ll ever be my primary language&#8212;I still have high hopes for Perl 6, which will have all the things I like about Ruby whilst addressing some of the things about it that make me uncomfortable. But in the unlikely event that Perl 6 crashes and burns, Perl 5 finally has a competitor that I enjoy using if only because I&#8217;m sick of typing:</p> <pre><code>sub foo { my $self = shift; my($arg1, $arg2) = @_;</code></pre> <p>at the start of every method.</p> <pre><code>def foo(arg1, arg2)</code></pre> <p>is just so much shorter. And until I can do</p> <pre><code>method foo($arg1, $arg2) {</code></pre> <p>Ruby will entice me. Maybe I should just get Emacs to fill in the Perl 5 boiler plate&#8230;</p> Mon, 01 Aug 2005 14:20:00 -0500 urn:uuid:5b41308433fd48012cfeafe63fb2798c pdcawley@bofh.org.uk (Piers Cawley) http://www.bofh.org.uk/articles/2005/08/01/the-pickaxe-book#comments The Practice of Programming Review http://www.bofh.org.uk/trackbacks?article_id=the-pickaxe-book&day=01&month=08&year=2005 http://www.bofh.org.uk/articles/2005/08/01/the-pickaxe-book Quite Ugly One Morning <p>Spurred on by the forthcoming adaptation on <span class="caps">ITV</span>, I&#8217;ve finally got round to reading Christopher Brookmyre&#8217;s first novel, <cite asin="0349108854">Quite Ugly One Morning</cite></p> <p>Wow.</p> <p>If you can make it past the (quite disgusting) first chapter, then you&#8217;ll be in it for the long haul. Great characters, spiky dialogue, twisty plot, worrying prescience and some fabulously gruesome set pieces and comeuppances.</p> <p>So, in summary. Buy this book. Then do what I did and buy the other Parlabane books too; they&#8217;re worth it for the titles alone.</p> Fri, 03 Sep 2004 03:39:00 -0500 urn:uuid:b03d0f24e593f763150942c7def065e5 pdcawley@bofh.org.uk (Piers Cawley) http://www.bofh.org.uk/articles/2004/09/03/quite-ugly-one-morning#comments Review http://www.bofh.org.uk/trackbacks?article_id=quite-ugly-one-morning&day=03&month=09&year=2004 http://www.bofh.org.uk/articles/2004/09/03/quite-ugly-one-morning 'Extreme Building' <blockquote> <p>Our experience as contractors, engineers and architects during the last 15 years has proved one thing over and over again: The things placed on drawings are inevitably &#8211; always &#8211; wrong in many particulars. Drawings serve as an important rough sketch of something that will be built, but must be executed with constant attention to room shape, light, wall and ceiling detail, openings &#8211; above all to the feelings which arise in each place, in the construction, as it is taking shape. These feelings are too complicated to predict and <em>cannot</em> be predicted. When a building is built from plans that are conceived on the drawing board and then simply built, the result is sterile at best &#8211; silly most of the time &#8211; and sometimes unthinkably bad. This is something familiar in virtually all large buildings that have been built since 1950. It is inevitable, given the process of construction used to build them. And it is inevitable that this process must lead to unsatisfactory results.</p> </blockquote> <blockquote> <p>&#8212;Christopher Alexander, Gary Black &#38; Miyoko Tsutsui <cite asin="0195210174">The Mary Rose Museum</cite></p> </blockquote> <p>Another installment in my ongoing series of reviews of books that Amazon will take an age to deliver.</p> <p><cite>The Mary Rose Museum</cite> is an account of the Center for Environmental Structure&#8217;s bid to build a museum around the <em>Mary Rose</em>, Henry <span class="caps">VIII</span>&#8217;s flagship, which, in 1545 unaccountably sank in calm seas, in the sight of the King himself<sup><a href="#fn1">1</a></sup> with the loss of nearly 700 men. The story of how the wreck was <a href="http://www.maryrose.org/project/proj1.htm">found, raised and conserved</a> is pretty impressive in itself. I can remember watching <span class="caps">BBC</span> specials on the process as it was happening and being amazed at the dedication/insanity of those involved, but that&#8217;s not really what Alexander&#8217;s book is about.</p> <p>In 1991, Christopher Alexander was in conversation with Prince Charles (whose interest in architecture is (in)famous). They were lamenting the then design for a museum to be built over where the <em>Mary Rose</em> still lies beneath a huge tent, continuously sprayed with a cold mist of water to prevent any decay of the timbers. The proposed design was for yet another anonymous hangar-like structure at odds with the other buildings in the Portsmouth Naval Dockyard, and not exactly sympathetic to either the <em>Mary Rose</em> or <em><span class="caps">HMS</span> Victory</em> which sits in a nearby dry dock. The Prince sketched (probably not on a fag packet, but who knows) a profile, saying to Alexander &#8220;What about something like this?&#8221;, and off Alexander went.</p> <p>At Charles&#8217; request, the <em>Mary Rose</em> Trust commissioned Alexander to produce the proposal for building The <em>Mary Rose</em> Museum that is, ostensibly what this book is about. The bulk of the book&#8217;s 128 pages is taken up by a description of the proposed museum, outlining its development from the original rough sketch through to a fully costed, structurally feasible design.</p> <p>At this point, the principle sponsor backed out leaving the project with no funds and it had to be shelved. Alexander says that, by then, he and his team had put in some 5000 man hours of work on the project; I&#8217;m sure they must have been gutted to have the plug pulled. A smaller section at the back then goes on to discuss the (much rougher) work the team did on redesigning the museum so that it could be built in incremental fashion without needing all the funds up front in the hope that the Trust&#8217;s funding could be spent on something permanent rather than having to spend a large amount of the donated money on temporary measures to maintain the structural integrity of the current &#8216;tent&#8217; over the ship.</p> <p>So, it&#8217;s a war story from a failed project, why should you part with the thick end of £30 to read about that? And what does all this have to do with programming? Here&#8217;s why: Christopher Alexander is the most influential bricks and mortar architect that the world of computer programming has ever known, if only for his work on <cite asin="0195019199">Pattern Languages</cite> and <cite asin="0195024028">&#8216;The Quality Without a Name&#8217;</cite>. As a literary form, the design pattern and the larger pattern language are fabulously useful (and egregiously abused) ways of describing how to solve many of the problems we face as programmers.</p> <p>However, what is often overlooked about Alexander&#8217;s work is that an awful lot of what he advocates about the process of generating a room, building or town foreshadows the processes advocated by the <cite>Extreme Programming</cite> people. You should not be surprised to learn that Kent Beck, author of the seminal book on XP, was also one of the earliest writers to use design patterns as a way of addressing programming issues.</p> <p>In <cite>The Mary Rose Museum</cite>, Alexander describes the &#8216;agile&#8217; process his team uses on projects, and he also shows the basic contracts between Owner and Architect, and Architect and Subcontractor that he and his team use when building.</p> <p>As a houseowner who had some fairly substantial house renovation done I&#8217;ve been a signatory to a standard <span class="caps">RIBA</span> contract for building works, and it&#8217;s a very different beast indeed from the Center for Environmental Structure (CES) contracts. I would rather have signed the <span class="caps">CES</span> ones. Alexander maintains, and I think I agree with him, that his form of contract deliberately nurtures the process of building something that will live, while the standard contracts are based on the myth that the plan is how it will be and any variation will cost the client. The <span class="caps">CES</span> contracts state up front that change happens, and handle that change without having tons of &#8216;extras&#8217; added to the cost. Here&#8217;s an extract from the <cite>Craftsman/Subcontractor</cite>[2] contract.</p> <blockquote> <p><span class="caps">ARTICLE 5</span>. CRAFTSMAN&#8217;S <span class="caps">GOAL</span>. The ultimate purpose of this agreement is to secure the craftsman&#8217;s work under conditions which make the craftsman&#8217;s work a work of beauty and pride and self-respect, and in which the craftsman leaves behind work he is proud of, and can cherish in the future.</p> </blockquote> <blockquote> <p>It is specifically understood that the craftsman&#8217;s goal is not only to be paid for his work, but that the beauty and satisfaction of the work itself provide part of the craftsman&#8217;s reward. To this end, the craftsman shall be treated as an artist who has some power and control over his work as necessary to allow the creation of a beautiful and fitting work within limits accepted by <span class="caps">CES</span>.</p> </blockquote> <p>It seems to me, as someone who believes that we programmers are more craftsmen than engineers, that the <span class="caps">CES</span> contracts for building works may well offer a useful model for designing contracts for building software using agile processes. Certainly Alexander has interesting things to say that will repay your careful reading and consideration.</p> <p id="fn1"><sup>1</sup> One theory my wife has heard is that someone on board said &#8220;Ee look, there&#8217;s t&#8217; King!&#8221; at which point everyone on board rushed over to one side of the ship to take a look, and the subsequent heeling of the ship meant she started shipping water through the lowest gun ports.</p> <p id="fn2"><sup>2</sup> The contract is careful always to refer to subcontractors as craftsmen &#8220;in order to emphasize the craft-like nature of the work which <span class="caps">CES</span> expects.&#8221;</p> Sat, 30 Aug 2003 09:54:00 -0500 urn:uuid:b2becf12ab37ce9f3083d2752a5ed479 pdcawley@bofh.org.uk (Piers Cawley) http://www.bofh.org.uk/articles/2003/08/30/extreme-building#comments Musings The Practice of Programming Review review designpatterns extremeprogramming http://www.bofh.org.uk/trackbacks?article_id=extreme-building&day=30&month=08&year=2003 http://www.bofh.org.uk/articles/2003/08/30/extreme-building "The best thing for being sad" <blockquote> <p>&#8220;The best thing for being sad,&#8221; replied Merlin, beginning to puff and blow, &#8220;is to learn something. That&#8217;s the only thing that never fails. You may grow old and trembling in your anatomies, you may lie awake at night listening to the disorder of your veins, you may miss your only love, you may see the world about you devastated by evil lunatics, or know your honour trampled in the sewers of baser minds. There is only one thing for it then&#8212;to learn. Learn why the world wags and what wags it. That is the only thing which the mind can never exhaust, never alienate, never be tortured by, never fear or distrust, and never dream of regretting. Learning is the only thing for you. Look what a lot of things there are to learn.&#8221; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&#8212;T.H. White, <cite asin="0006483011">The Once and Future King</cite></p> </blockquote> <p>T.H. White is one of my favourite writers. It&#8217;s easy to be dismissive of <cite>The Once and Future King</cite>, based on the <cite asin="B00005U1Y5">Disney adaptation</cite>&#8212;which, like their version of <cite asin="0140621040">The Jungle Books</cite>, is great fun but a travesty of the original. However, as I hope the extract shows, there&#8217;s rather more to him than that.</p> <p>My favourite chapter in the book was the one dealing with the night Wart spent in the castle mews with the falcons and the baleful nightmare, Cully. Ever since I read it I&#8217;ve been fascinated by falconry&#8212;I&#8217;ll know I&#8217;ve made my fortune when I can retire to a large house in the country and keep and become a falconer. I mentioned this to Gill shortly after we met and she pressed <cite asin="1558214356">The Goshawk</cite> on me. Wow. This is a fabulously written account of White&#8217;s attempts to train a Goshawk using a medieval textbook as his guide (even when he wrote the book, the profession had moved on a great deal, but White didn&#8217;t know that). It&#8217;s been described by austringers<sup><a href="#fn1">1</a></sup> as the ideal &#8216;how not to&#8217; book. But you don&#8217;t read it for the techniques, you read it for White&#8217;s perfect prose, for the boundless patience of the man and the seemingly boundless stubbornness of the bloodyminded Cully. I&#8217;ve flown a Harris Hawk on a course that Gill arranged for my birthday one year, walking around with a hawk on your fist, calmly talking to it and getting it used to you is (for me) an indescribable experience; the best I can do is point at <cite>The Goshawk</cite> and say &#8220;Read that!&#8221;</p> <p>I wish I could say that Merlin&#8217;s speech branded itself on my brain when I first read it around 25 years ago, but sadly, I can&#8217;t. It only had that effect when I logged into my Linux box one morning and my standard <code>.profile</code> ran <a href="http://linux.ctyme.com/man/man0810.htm" title="6">fortune</a> and up it popped. Merlin&#8217;s dead right you know, the process of learning things is the finest pill to purge melancholy I know. At my father-in-law&#8217;s funeral (he had been a stalwart of the <a href="http://www.wea.org.uk" title="Workers' Educational Association"><span class="caps">WEA</span></a> for a large part of his life), we took that passage and had it printed up on cards for the mourners, and Gill used it as a reading. Everyone who knew him remarked on how appropriate and cheering it was. I hope that it will be just as appropriate a reading for me when my time comes.</p> <p id="fn1"><sup>1</sup> Fabulous word isn&#8217;t it? An austringer is someone who flies hawks, as opposed to a falconer, who flies falcons.</p> Fri, 29 Aug 2003 06:28:00 -0500 urn:uuid:a939bac30008588623d3d0e65b82fd5f pdcawley@bofh.org.uk (Piers Cawley) http://www.bofh.org.uk/articles/2003/08/29/the-best-thing-for-being-sad#comments Review http://www.bofh.org.uk/trackbacks?article_id=the-best-thing-for-being-sad&day=29&month=08&year=2003 http://www.bofh.org.uk/articles/2003/08/29/the-best-thing-for-being-sad Laying out code <p>A couple of articles back, I reviewed <cite asin="013476904X">Smalltalk Best Practice Patterns</cite> and mentioned that it&#8217;s a book that concentrates on the tactics of programming rather than the big strategic stuff. Beck even takes his life in his hands and lays down a set of patterns for laying out code. The (very short) set of patterns he comes up with do seem to generate remarkably clear code.</p> <p>I&#8217;m a big fan of this book, and I&#8217;ve lifted many of the ideas about how to structure Smalltalk code and used them when I&#8217;m writing OO Perl (to the extent that I sometimes find myself wishing that Perl had Smalltalk like message selectors), so now I&#8217;m toying with the idea of using Beck&#8217;s rules, or something like them, for laying out my Perl code.</p> Here&#8217;s a method from Pixie::Proxy (one of the scarier classes in Pixie I must admit): <pre><code language="Perl"> sub _px_extraction_thaw { my $self = shift; my $pixie = Pixie-&gt;get_the_current_pixie; my $ret = $pixie-&gt;cache_get($self-&gt;_oid); if ( defined $ret ) { $pixie-&gt;obliterate($self); return $ret; } $self-&gt;px_lock_strategy( $pixie-&gt;get_the_current_lock_strategy ); if ($self-&gt;px_class-&gt;px_is_immediate) { my $oid = $self-&gt;_oid; $pixie-&gt;obliterate($self); return $pixie-&gt;_get($oid); } else { $self-&gt;px_the_store($pixie); $pixie-&gt;cache_insert($self); return $self; } } </code></pre> Now, here it is again reformatted according to my adaptation of Beck&#8217;s rules. <pre><code language="Perl"> sub _px_extraction_thaw { my $self = shift; my $pixie = Pixie-&gt;get_the_current_pixie; my $ret = $pixie-&gt;cache_get($self-&gt;_oid); if ( defined $ret ) { $pixie-&gt;obliterate($self); return $ret; } $self-&gt;px_lock_strategy( $pixie-&gt;get_the_current_lock_strategy ); if ($self-&gt;px_class-&gt;px_is_immediate) { my $oid = $self-&gt;_oid; $pixie-&gt;obliterate($self); return $pixie-&gt;_get($oid) } else { $self-&gt;px_the_store($pixie); $pixie-&gt;cache_insert($self); return $self; } } </code></pre> The main change in appearance comes from using what Beck calls rectangular blocks. Moving to this style has shortened the method by three lines, which isn&#8217;t bad. Moving to using cuddled elses<sup><a href="#fn1">1</a></sup> would only have saved one line and I don&#8217;t like them anyway because I tend to lose the <code>else</code>. With rectangular blocks, the control structure is still evident, which is nice. <p>It&#8217;s quite strange looking at that code; it looks odd, but I don&#8217;t think it looks actively <em>bad</em>. I&#8217;m off to recast a whole module in this style and see if I can boil things down to as compact a set of rules as Beck came up with. Or I might decide it looks horrible, but I do think it&#8217;s worth a look.</p> <p>Has anyone else tried anything like this? Did it work for you?</p> <p id="fn1"><sup>1</sup> A cuddled else looks like <code language="Perl">} else {</code> and is evil, bad and wrong.<cite asin="0596001738"> </cite></p> Sat, 16 Aug 2003 13:51:00 -0500 urn:uuid:f74aa57633891feb5d9647017bdd2db4 pdcawley@bofh.org.uk (Piers Cawley) http://www.bofh.org.uk/articles/2003/08/16/laying-out-code#comments Review http://www.bofh.org.uk/trackbacks?article_id=laying-out-code&day=16&month=08&year=2003 http://www.bofh.org.uk/articles/2003/08/16/laying-out-code Essential Perl 6 <p>As most of you probably know, unless you&#8217;re one of the people who came here via a link from <a href="http://weblogs.java.net/pub/wlg/353">java.net,</a> I write a summary every week of the ongoing developments on the Perl 6 development mailing lists. Which means, if nothing else, that my review of <cite asin="0596004990">Perl 6 Essentials</cite> by Randal, Sugalski &#38; T&ouml;tsch might be just a little partial.</p> <p>Any book which aims to hit a target as mobile as Perl 6 and Parrot<sup><a href="#fn1">1</a></sup> is always going to have a hard time, but the writers are all intimately involved in their design and development, so they&#8217;re going to be closer to the mark than most. Allison Randal is a member of the core team designing Perl 6 the language; Dan Sugalski is the project leader for Parrot and Leopold T&ouml;tsch, generally described in my <a href="http://www.perl.com/pub/at/16">Perl 6 Summaries</a> as the Patch Monster has a phenomenal work rate and knows Parrot inside out.</p> <p>The book opens with a short overview of the genesis of Perl 6 and how the project is structured and managed, and how you can get involved in the various subprojects. Included in this section is an overview of how Perl 6 the language is being designed. One of the criticisms that&#8217;s been levelled at Perl 6 is that it&#8217;s being <a href="http://bleaklow.com/alanbur/p6_cover.gif">designed by a committee.</a> However, this isn&#8217;t the way most of the people involved in Perl 6 see it. The language is being designed by Larry Wall, with direct support from Damian Conway, Allison Randal and the others on the core team. Meanwhile mailing list participants pitch in with new ideas, questions, clarifications etc. It might look like there&#8217;s a lot of noise and disparate voices if you&#8217;re watching the mailing lists, but it&#8217;s very apparent from reading the design documents that Larry puts out (<a href="http://www.perl.com/pub/au/Wall_Larry">The Apocalypses</a>) that Larry is <em>the</em> designer of Perl 6. There&#8217;s a distinctive Wallian feel to them that&#8217;s very different from the stuff produced on the mailing lists, and even from the stuff Damian Conway did in his <a href="http://www.yetanother.org/damian/Perl5+i/">Perl 5+i</a> effort. It&#8217;s quite weird&#8212;often I&#8217;ll see an idea on the mailing list and think &#8220;No, that&#8217;s just going too far.&#8221;, then along comes Larry in the next Apocalypse and he&#8217;s taken the idea I&#8217;d previously rejected, pushes it even further and comes back with something that&#8217;s powerful, Perlish and broadly useful.</p> <p>Ahem, I digress.</p> <p>Next up is an overview of the Perl 6 design philosophy. If you&#8217;ve seen Allison speaking about this at <span class="caps">OSCON</span> or <span class="caps">YAPC</span> then much of the material in this chapter will be familiar (I do find myself wondering which came first, the talk or the chapter<sup><a href="#fn2">2</a></sup>). This is a well written, thoughtful explanation of the principles underlying the language design. In a sense, this chapter can be thought of as an essence of Perl <del>- There is very little in here that doesn&#8217;t apply equally to earlier Perls, possibly right back to Perl 0.whatever. Even if you&#8217;re not particularly interested in Perl 6 (or even Perl) there&#8217;s a good deal to think about here -</del> the importance of considering natural languages when designing programming languages, and of giving the program the freedom to express her intent in several ways (and the responsibility to choose the clearest option of course)&#8212;there&#8217;s certainly plenty of meat for the <a href="http://lambda.weblogs.com/">Lambda the Ultimate</a> and <a href="http://ll1.ai.mit.edu/"><span class="caps">LL1</span></a> crowds.</p> <p>Chapter 4 covers the syntax of Perl 6. It&#8217;s written as if it&#8217;s an early draft of the Perl 6 edition of <cite>Programming Perl</cite>. I really like this chapter, it covers an awful lot of ground and it does so with admirable clarity. The most obvious change is Larry&#8217;s total rethink of the pattern matching syntax, which is a fantastic piece of work and no mistake, but a no less important change (to my way of thinking at least) is the changes in the way blocks work.</p> <p>If you listen to the likes of <a href="http://perl.plover.com/">Mark Jason Dominus</a> (and if you don&#8217;t listen to Mark, you really should) you&#8217;ll be aware of the importance that he places on Perl&#8217;s very high level capabilities, particularly its functional programming capabilities. Well, in Perl 6, functional programming just got a whole lot less wordy. And with tail call elimination on the cards, it should be getting faster too.</p> <p>The shift to function signatures which name the arguments helps to reduce the &#8216;noise&#8217; in the body of the the subroutine. Hoisting parameter naming into the signature gets rid of all the tedious manipulation of <code language="Perl">@_</code> that characterises every single subroutine block in Perl. I sometimes think that the parameter handling folderol is one of the main reasons that too many Perl 5 functions and methods stay long and don&#8217;t get factored into small, comprehensible units of code.</p> <p>Perl 6 has also dropped the requirement to use <code language="Perl">sub</code> to declare anonymous subroutine, making it far easier to write methods and functions that can be used as if they were part of the language. And hey, it&#8217;s four characters less to type every time you call a higher order function or method. It doesn&#8217;t <em>sound</em> like much, but if you go and take a look at Ruby or Smalltalk and the way in which so many of those languages&#8217; powerful constructs make heavy use of syntactically light<sup><a href="#fn3">3</a></sup> blocks. See <a href="http://www.perl.com/pub/a/2003/07/29/exegesis6.html">Exegesis 6</a> for a very good set of examples covering almost everything to do with subroutines, methods and blocks.</p> <p>Also in this chapter is coverage of Perl 6&#8217;s replacement for Perl Compatible Regular Expressions. Wow. If I were a Python or Ruby evangelist, then I&#8217;d currently be busy stealing the ideas and syntax in the new Perl 6 Rules and trying to get something up and running before Perl 6 does. The new Perl 6 Rules/Grammar system is a comprehensive rethink of how pattern matching works and should work. As I&#8217;ve mentioned in an earlier entry, I went to Damian Conway&#8217;s talk on Perl 6 Rules at <span class="caps">OSCON</span> this year, and he showed off a partial implementation (in Perl 5) and they&#8217;re phenomenal parsing tools. That afternoon, I rode in Ward Cunningham&#8217;s Jeep back from Portland Zoo and we talked about Perl 6 rules. I may not have got my Ward number down to 1 at <span class="caps">OSCON</span>, but I can say that Ward seemed excited by the possibilities inherent in the new rules system. He&#8217;s not alone.</p> <p>The rest of the book is concerned with Parrot, Perl 6&#8217;s target VM(Virtual Machine). Unlike Perl 6, Parrot is available to download and run today. It&#8217;s not finished, but it&#8217;s becoming more capable as every day passes (thanks in no small part to Leo T&ouml;tsch&#8217;s phenomenal workrate, and, in recent weeks, Michal Wallace&#8217;s sterling work on getting Python up and running on Parrot). This does mean that the Parrot section of the book has a few inaccuracies where Parrot has changed the way it works. My favourite is found in the discussion of Coroutines on p93 where Dan writes &#8220;Coroutines can be implemented in terms of continuations if need by, but that requires using a full continuation-passing function call system, something we choose not to do&#8221;. Well, that&#8217;s what most copies say; Mine has a signed correction from Dan as I believe that particular statement was out of date about a day after too book went to press. There aren&#8217;t many of these however, and I&#8217;d be worried if there weren&#8217;t <em>any</em>&#8212;good design arises from experience, and there aren&#8217;t too many people with experience of writing a register based VM. Overall, the Parrot Internals chapter is strong on the structure of Parrot, and offers insight into the <em>why</em> of it. If you intend to help with the task of implementing Parrot then this is an excellent place to start; you&#8217;ll still have to read the source, and the detailed design documents, but if you&#8217;ve read this you&#8217;ll have a good map in your head of how things hang together.</p> <p>The last two chapters are concerned with writing assembly programs to run on Parrot. Essentially the would be language implementer can either write all his code in native Parrot Assembly Language, managing register allocations and the like himself and generally getting all those associated headaches. Or, he can write code for <acronym title="InterMediate Code Compiler">IMCC</acronym> using Parrot Intermediate Language (known as <span class="caps">PIR</span> for reasons that aren&#8217;t entirely clear even to one who has been watching the mailing list since the Parrot project started) which is an &#8216;overlay&#8217; on top of <span class="caps">PASM</span>. IMCC handles all your register allocation needs, implements macros, handles the parrot callling conventions and generally makes the poor compiler writer&#8217;s life easier. The idea is that <span class="caps">IMCC</span> will provide language independent optimizations such as automatic inlining of function calls, loop unrolling and (eventually) the whole arsenal of assembly level optimization tricks that have been developed down the years. All you have to do is write your compiler/interpreter reasonably simply and let <span class="caps">IMCC</span> handle the bookkeeping. But, I&#8217;m getting ahead of myself again.</p> <p>Reading the chapter on Parrot Assembly Language can be a strange experience, especially if you&#8217;re used to &#8216;real&#8217; assembly languages. It starts off gently, looking pretty much like &#8216;real&#8217; machine code, but with the odd wrinkle that there seems to be no way of accessing the main memory, and there&#8217;s <acronym title="Parrot Magic Cookie">PMC</acronym>s to worry about that don&#8217;t look like anything you&#8217;d get in a &#8216;real&#8217; assembler&#8212;what was the last chip you saw with a fully functioning <code>sprintf</code> opcode? The chapter finishes with a handy reference of Parrot ops and how to use them, which is excellent; I generally don&#8217;t have sufficient screen real estate to go tracking through doc files in search of something, but a book open beside you is a godsend. Parrot Assembly is a remarkably powerful and expressive assembly language, but for anything serious you should really press on to the next chapter, which covers <span class="caps">IMCC</span>.</p> <p><span class="caps">IMCC</span> is great. Although it was intended as a target for compilers that didn&#8217;t want to have to worry about the register allocation bookkeeping, it&#8217;s also a very pleasant environment in which to write your own code. Again, this section of the book is well written and makes a very handy reference. Last but not least is a decent index (given the speed with which this book was put together I&#8217;m amazed that it has <em>an</em> index, let alone a decent one.)</p> <amazon asin="0596004990"><cite>Perl 6 Essentials</cite></amazon> has had a somewhat mixed reception in various places. The major criticism (from those who have neither read it nor intend to read it) is along the lines of &#8220;Even by the most optimistic estimates, Perl 6 is at least a couple of years away, why do we need this book?&#8221; Well, yes, Perl 6 is at least a couple of years away, but Parrot (or something very like it) is here right now and it&#8217;s supporting some &#8216;real&#8217; programming languages, not just toys like <span class="caps">BASIC</span> and Python, it can even host Brainfuck and Befunge. If you want to start targetting Parrot, then this book is a great place to start. <p>The Perl 6 half of the book is important too. Allison has pulled together the existing Apocalypses and Exegeses, taken the various changes that have happened since they were written and boiled the state of Perl 6 down into a straightforward and readable description of where we stand. From the feedback I&#8217;ve been getting about my weekly Perl 6 Summaries, I know that there are plenty of people out there who are interested in what&#8217;s going on in Perl 6, but who don&#8217;t have the time to read the mailing lists. I don&#8217;t doubt that there are also people out there who are interested in Perl 6 but who don&#8217;t have time to read the summaries for whom this book would also be ideal.</p> <p>I do wish it had larger margins though. I can see this becoming a book that I end up covering with annotations and addenda as the language changes with each new Apocalypse, Exegesis, Parrot Design Document and large patch from Leo T&ouml;tsch. And I do wonder if it wouldn&#8217;t have been better entitled <cite>The Perl 6 Annual 2003</cite>.</p> <p id="fn1"><sup>1</sup> Parrot is the register based virtual machine that will host Perl 6.</p> <p id="fn2"><sup>2</sup> Ah&#8230; I just got mail from Allison, the chapter got done first and the process of writing it inspired the talk.</p> <p id="fn3"><sup>3</sup> By which I mean blocks are introduced with a minimum of gubbins, no keywords required.</p> Fri, 15 Aug 2003 10:13:00 -0500 urn:uuid:ad9426bd1e0458c4fc4f3164ed90f2d9 pdcawley@bofh.org.uk (Piers Cawley) http://www.bofh.org.uk/articles/2003/08/15/essential-perl-6#comments Perl 6 Review http://www.bofh.org.uk/trackbacks?article_id=essential-perl-6&day=15&month=08&year=2003 http://www.bofh.org.uk/articles/2003/08/15/essential-perl-6 The Quality Without A Name <p>The Quality Without A Name is a phrase coined by Christopher Alexander in <cite asin="0195024028">The Timeless Way of Building</cite> to describe the feeling of satisfaction and contentment engendered by good building. He later went on to call it &#8216;life&#8217;, but a friend of mine described it as &#8216;The Tao of Building&#8217;, which seems rather appropriate too. <cite>The Timeless Way of Building</cite> is a fantastic, if somewhat overwritten book, introducing Alexander&#8217;s themes and ideas about how modern architects and builders can recapture the qualities inherent in great (usually old) buildings.</p> <p>Alexander later went on to crystallize his ideas about how to lay out cities, towns, neighbourhoods, houses, rooms, windows, etc in his massively influential book, <cite asin="0195019199">A Pattern Language</cite>, in which Alexander and his co-authors attempted to set down a &#8216;language&#8217; that would enable anyone to design and build somewhere that possessed the Quality Without a Name for themselves. Sadly, as they admit later, they failed in this attempt; efforts to use this pattern language by laymen resulted in interesting, but flawed buildings. Despite the failure (in Alexander&#8217;s terms) it&#8217;s a great book; the prose can be a little annoying at times, but the analysis is deep, and mind-changing. Here&#8217;s an extract from one of the patterns:</p> <blockquote> <p><b>208. Gradual Stiffening</b></p> </blockquote> <blockquote> <p><strong>The Fundamental philosophy behind the use of pattern languages in buildings is that buildings should be uniquely adapted to individual needs and sites; and that the plans of buildings should be rather loose and fluid, in order to accommodate these subtleties.</strong></p> </blockquote> <blockquote> <p>[An essay describing the problem more fully, and the reasoning behind the solution presented]</p> </blockquote> <blockquote> <p>Therefore:</p> </blockquote> <blockquote> <p><strong>Recognize that you are not assembling a building from components like an erector set, but that you are instead weaving a structure which starts out globally complete, but flimsy; then gradually making it stiffer buit still rather flimsy; and only finally making it completely stiff and strong. We believe that in our own time, the most natural version of this process is to put up a shell of sheet materials, and then to make it fully strong by filling it with compressive fill.</strong></p> </blockquote> <p>Look, Agile Building!</p> <p>Alexander and his co-writers have found a remarkably powerful way of managing complexity by isolating parts of the process of building in individual patterns, but neatly tying them into the greater whole by their use of introductory and closing paragraphs to explain the context in which a pattern is used. When I read it, I find I&#8217;m constantly flipping back and forth to look at these contextual patterns that support (or use) the pattern that I&#8217;m concentrating on. The book itself has the Quality Without a Name.</p> <p>It was only after I&#8217;d read <cite>The Timeless Way</cite> and <cite>A Pattern Language</cite> that I came across the idea of Design Patterns in programming (In fact, I was working as a contractor and had a copy of <cite>The Timeless Way</cite> on my desk when a coworker spotted it and made a remark along the lines of &#8220;Ah, going back to the source eh?&#8221;, which he then had to explain as I didn&#8217;t know what he was talking about.) when a friend lent me the Gang of Four&#8217;s <cite asin="0201633612">Design Patterns</cite>.</p> <p>I don&#8217;t really like <cite>Design Patterns</cite>. Too many of the patterns seem to be concerned with working around problems with the static nature of C++ and Java&#8212;not exactly useful if you&#8217;re used to a more dynamic OO language. Another, deeper failing, is the disjointed nature of the patterns presented; there&#8217;s no attempt to tie the patterns together in a coherent language and the whole thing feels like a mishmash of ideas waiting to be turned into a finished book.</p> <p>There is one software patterns book I&#8217;ve read that gets it though, that has The Quality Without A Name in the same way that <cite>A Pattern Language</cite> does. That book is <cite asin="013476904X">Smalltalk Best Practice Patterns</cite> by <a href="http://www.c2.com/cgi/wiki?KentBeck">Kent Beck</a>. If you don&#8217;t know Smalltalk, don&#8217;t be put off by that title; a very sizable fraction of the book can be applied directly to any suitably dynamic OO language (Perl, Python, Perl 6, Javascript&#8230;) and the syntax of Smalltalk is virtually nonexistent and easy enough to pick up.</p> <p>The book works well because Beck, quite deliberately, limits its scope to the tactics of coding. Instead of going for the big things, we&#8217;re dealing with the nuts and bolts: how to choose good names, how to write methods in ways that encourage reuse and flexibility, how to keep things loosely coupled. Beck explains this stuff with concrete examples and simple rules, that work phenomenally well together. It&#8217;s hard to put my finger on <em>why</em> it works so well, but my gut feeling is that it&#8217;s because Beck has not forgotten the importance of context.</p> <p>Very few of the patterns are strictly standalone, they refer to each other up and down the &#8216;levels&#8217; of the various patterns and the individual patterns are small enough, and well enough supported by the other patterns in the language that they remain tightly focussed on the issue they address.</p> <p><cite>Smalltalk Best Practice Patterns</cite> is a complete pattern language, something that I&#8217;ve not seen achieved in any other software patterns book (though Martin Fowler&#8217;s <cite asin="0201485672">Refactoring: Improving the Design of Existing Code</cite> gets pretty close.) It&#8217;s easy to read; full of practical wisdom from someone who knows their stuff and can explain it well.</p> <p>I recommend this book wholeheartedly to anyone who wants to become a better programmer, and especially to anyone who does object oriented programming in a dynamic language of any kind. If you find me in a bar amongst programmers, and we&#8217;re talking about how to get better at our craft, then I&#8217;ll almost certainly be banging on about how good this book is.</p> <p>I believe the Java types are fans too, but if I were a java programmer then I&#8217;d find the kind of flexibility inherent in Smalltalk as expressed in this book would just make me want to abandon Java in favour of something more expressive.</p> Tue, 29 Jul 2003 06:06:00 -0500 urn:uuid:a857db3e470e75cbe6da6e39d32982cf pdcawley@bofh.org.uk (Piers Cawley) http://www.bofh.org.uk/articles/2003/07/29/the-quality-without-a-name#comments The Practice of Programming Review review practiceofprogramming designpatterns XP extremeprogramming agilemethods http://www.bofh.org.uk/trackbacks?article_id=the-quality-without-a-name&day=29&month=07&year=2003 http://www.bofh.org.uk/articles/2003/07/29/the-quality-without-a-name