Sunday, January 27, 2008

Book Review: Beautiful Code

Beautiful Code
Compiled by Andy Oram, Greg Wilson


A diamond is a chunk of coal that is made good under pressure. - Henry Kissinger

Beautiful Code is another non-animal O'Reilly volume, with high aspirations. As the sleeve submits: "How do the experts solve difficult problems in software development?" If this book had been able to answer that question, reading it would be a head-spinning experience indeed.

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

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

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

For the rest of us, this book was no great failure but no revelation, and is deserving of its place on the shelf. And the geeks among geeks, the hackers who would have found a book closer to Hackers and Painters, held it and shook it until C code fell out, will no doubt appreciate this book.

Labels: ,

Sunday, January 20, 2008

Book Review: The Art of SQL

The Art of SQL
By Stéphane Faroult, Peter Robson

As we know, there are known knowns. There are things we know we know. We also know there are known unknowns. That is to say we know there are some things we do not know. But there are also unknown unknowns, the ones we don't know we don't know. - Donald Rumsfeld (Sun Tzu's second millennium CE incarnation.)
The Art of SQL is no Web Database Applications with PHP and MySQL. It's far beyond that; it is well past even Practical PostgreSQL and the SQL Cookbook. Not only is it written for the experienced user, it is for the ambitious user, the one who wakes up with a smile trying to retain the n-dimensional join from their dream.

The excellent style of writing used is above O'Reilly par. Not only is the text concise and well edited, the book is organized very well. In a graceful and creative turn, the presentational style of the book is allusive to Sun Tzu's Art of War; query diagrams, sample datasets, and business cases are rendered as plans of attack and battle formations in the Napoleonic era. The result is phenomenal, and structurally, this book is groundbreaking - no computer science book I've read prior has had so much attention paid to making its content engaging and enjoyable to consume - this is certainly not necessary, but it is a great indication of the overall quality of the book.

The book is SQL implementation agnostic and assumes the reader is interested in data integrity, extensibility, and scalability in the database. It assumes that you care, or want to care, whether you're following third normal form. In fact, the implied understanding here is that an earnest investment in normalization will pay dividends in optimization. Only if you're willing to perspire for it - it is an art, not a school of magic.

The SQL enthusiast will learn a lot from this book - perhaps a baffling amount. I absolutely cannot recommend it highly enough. It has been some time coming, the sort of thing that is an obvious boon when one considers that our 'art' has only been around for a few decades. We'll get it right eventually, inspired by those like Faroult and Robson.

Labels: ,

Sunday, January 6, 2008

Mathematical Symbols

Mathematics, the study of totally constructed concepts like numbers, time, logic and all that, is the closest thing we've got to a universal language. Highly intuitive symbols are included, if not universal, and let me point out a few and critique them:
  • 'Square foot', exactly like it says on the box. Not that a foot is a good unit of measurement - a human foot is of course not a standard base for a system the way the size of our watery Earth is - but this symbol is excellent in its simplicity and expressiveness anyway.
  • An 'angle'! Very nice. Just a drawing of the referenced thing. Conveniently, this one is extensible - you can mark it up to show that you mean the measure or that your angle bisects another one, or what three points describe it.
  • ƒ 'Function of', pretty daft as it's just an initialization. At least it's scripted, so you can tell it's not just an F, I guess. This is precisely the kind of thing we should stay away from. A better symbol? ☡ would at least show the process of something undergoing a path, shows a thing passing a threshold.
  • 'Infinity'. Well, I guess this one works. I've never been a huge fan of the 'lazy eight', as it in no way indicates to me an unlimited amount of anything. But as an enormously abstract concept, it's not easy to symbolize without encoding, so this arbitrary, somewhat rationalizable symbol (it keeps going!) works well enough.
  • Δ 'Delta', commonly indicating a change in something over time. Pragmatically, an arrow describing the path of the sun, phases of the moon, tides, plants, something like that would be better. However, I do think it's great that, in English, a delta is a change in a river over time. A triangle shaped change. Is this intuitive? No. But for being referential in form, it's way better than 'Function of'.
  • ¬ 'Not'. One of the absolute simplest, and best. One has taken the straight tally representing 'a thing', and broken it in just such a way that negates it in form, function, and concept. One of the most intuitive, least encoded symbols we have.
  • 'And' shows the logical joining of two concepts into a higher, compound version. + is still useful as it shows two tallies in combination, but rather than depicting them together, a∧b is clearly the union between. while it's not as intuitive as +, we at least have a demonstrative picture of a joining, more indicative of the idea that 'both of these are required'.
  • 'Or' is another logical operator, used as a∨b. The deficit of this and ∧ is that, while they're wonderful in their logical inversion of one another, they are not referential of anything, and require some prior knowledge of their meaning. Good, but not perfect.
  • 'Null', a very difficult concept to represent in mathematics: a group of nothing. I'm very pleased with this one, which is so intuitive that it's more often reddened and superimposed on another symbol to show that it is not allowed. What a fantastic and practical use! Another, even more definite success where symbols are concerned.
  • Here's another terrific one. While not immediately intuitive, 'therefore' is an abstract concept. But if abstract concepts were shaped like dots, this symbol would show two of them with a third built on top, perfect units of reasoning being built on one another. Genius.

- ∧∨

Labels: ,