Archive for the ‘reading’ Category

a coder's bookshelf

August 30th, 2008

What is this obsession people have with books? They put them in their houses - like they're trophies. What do you need it for after you read it?
- Jerry Seinfeld

I think it's because reading a book takes a lot of effort, and we want to get credit for it. Reading a big book takes considerably longer than anything else you might do for "fun". And then you can point to it and say, "look, this is what I know".

I have a bunch of computer books, a lot of them from college, that I'll probably never toss out even though I'm unlikely to ever re-read them. Meanwhile, I can do what a lot of people are doing and put them on display. "Look, I must be really clever, I have all these books!"

Frankly that's all they're good for after I'm done with them.

Beautiful code

August 16th, 2008

I don't remember who metioned this book or where they did it. I seem to remember it being mentioned by several people. But for one reason or another I decided to order it and I've eventually made my way through to it.

"Beautiful code" is a compilation of 30-something case studies, each chapter written by a different contributing author, describing code or systems they found beautiful. I suppose it is subjective how wide your definition of "beautiful code" is, but some authors describe architectures rather than code, which isn't quite what I'd expect. To me "code" is generally something that happens at the statement/function level, otherwise you call it "design" or "architecture".

The case studies are extremely diverse, you have everything from kernel code to high level systems. As I'm not a kernel hacker I have to say I didn't understand much of the chapter on Linux drivers, but then I get the feeling I'll never grok c types without a mentor or something, the Hungarian notation style variable naming tells me little about their meaning. There's a FreeBSD chapter on filesystem layering, and that's fairly straightforward, then there's a Solaris chapter on thread handling which is interesting, but the code unfortunately is less instructive to me than is the prose (the author's fascination with sewage is also mildly disturbing).

You'll find the code examples in a variety of languages, some familiar (c++, haskell, java, python, ruby), some not directly familiar but partly or mostly understandable (c, c#, javascript, perl, scheme), and some foreign (elisp, fortran, matlab, visual basic). There are two chapters showing implementations of python datastructures (in c) that I found quite interesting, one from the standard library (dictionaries), the other from NumPy (n-dimensional arrays).

It turns out this book is more interesting than I expected. Some of the chapters I'm just not in a position to understand, but many of them are well written and interesting to delve into. I successfully killed 4-5 hours of time in flight and at the airport with it, which is better mileage than I get out of books on tape. What I really like about it is that it's a book for hackers in the trade -- it's a book that shows you stuff, not one that tries to teach you. Which means you get right to the point without the obligation to introduce and prepare you for what you're about to read. It's a lot more like reading a blog.

So then there's the question, is the code that these supposed masters of the trade write more beautiful than yours and mine? Well, not necessarily. In some of the examples presented it's the design that's supposed to make it beautiful, not the code itself. And try as you might to imagine how an expert will wield untold levels of voodoo to problems you and I would love to solve better, most of the time they don't. I guess there isn't all that much hidden magic out there.

books "you have to read"?

May 16th, 2008

This list of 100 books to read showed up on reddit today. I leafed through it and thought I'd do the general public a service by giving some annotations ;)

The Great Gatsby by F. Scott Fitzgerald :)

1984 by George Orwell :star:

The Republic by Plato :)

Brave New World by Aldous Huxley :thumbup:

The Iliad and Odyssey of Homer :) :nervous:

Catch-22 by Joseph Heller :yawn: :nervous:

Lord of the Flies by William Golding :lala: :cap:

The Metamorphosis by Franz Kafka :)

Ulysses by James Joyce :/

Crime And Punishment by Fyodor Dostoevsky :star:

The Art of Warfare by Sun Tzu :)

Don Quixote by Miguel de Cervantes Saavedra :thumbup:

The Divine Comedy by Dante Alighieri :/

Animal Farm by George Orwell :star:

Hamlet by Shakespeare :neutral: :nervous:

A Farewell To Arms by Ernest Hemingway :yawn:

The Stranger by Albert Camus :neutral:

Treasure Island by Robert Louis Stevenson :thumbup: :cap:

Foucault’s Pendulum by Umberto Eco :yawn:
Absolutely not. Go read The name of the rose instead, it's a masterpiece.

The Count of Monte Cristo by Alexandre Dumas :/ :cap:
If you find the novel too slow paced, see the mini-series with Gerard Depardieu, it's fantastic!

:cap: A children's book.
:nervous: I saw the movie or the play, didn't read the text itself.

:star: Stellar, unforgettable, a must read.
:thumbup: Highly recommended.
:) Well worth a look, but doesn't leave a lasting impression.
:neutral: Mediocre.
:yawn: Interminable.
:/ Gave up, the author could not convince me it was worth reading in a reasonable amount of time.

God is not great

March 30th, 2008

Christopher Hitchens is not just an author, he's also a journalist and speaker. His style is very characteristic for its intellectual depth and eloquent expressions. There is an interesting debate on Google Video among four critics of religion where he takes part.

God is not Great: How Religion Poisons Everything is one of the best books I've read about religion. It is also a rather deep book. Unlike Sam Harris, who apart from presenting examples also includes a lot of his own reasoning, Hitchen tries to present his arguments by finding quotes and references for everything. This might make the argument more convincing, but it also makes it a bit hard to follow with the flurry of examples he draws upon.

Hitchens makes many points in his book, but one of his central and probably most interesting arguments is that religion is man made. And from there on he finds it not excessively difficult to explain the many atrocities associated with religious groups over the centuries.

The Ambler Warning

February 12th, 2008

Every detective story or for that matter, spy novel, has the same overreaching goal: to give you an interesting puzzle to solve. A story is being told - you have to pay attention, and while you're taking notes you're also continuously assembling a repository of information and scouring it for relationships and patterns. And once you link two facts together, you've understood a part of the puzzle. A couple of factors determine why this is fun. First of all, the content of the puzzle should be fun, that is if you're putting together a puzzle of the Eiffel Tower, you will have fun if you like the Eiffel Tower. Then there are different ways of creating a puzzle, deciding what the pieces will be, how clear or faint the connections are going to be and so on. And finally there are different ways of giving you the pieces, at a certain pace, in a certain order. In as much as there are dependencies between the pieces, such that one will not help you without having a certain other piece, you can craft a complicated scheme. All these factors vary from story to story, some puzzles are fun, some are not.

This process of solving a puzzle is actually very intuitive. It's the same process by which we learn things. The difference is that when learning we're trying to understand an incidental truth, which isn't governed by any person's capricious decisions to make it so. And it could well be beyond your ability to solve. It may also be that no one has solved that puzzle. A man made plot, on the other hand, is a puzzle created specifically for our enjoyment, where the creator makes all the decisions, limits the scope appropriately, and deliberately sets the difficulty at a certain level.

A spy novel is always about deception upon deception, and as a reader you participate. Not only is the character in the story being deceived, you are as well. The author will be meticulous about telling you facts that point to a certain conclusion, but it's actually a decoy. Equally, he will mention facts that don't have any apparent use at the moment, but they will explain something further along, and if you're careful, keep you from walking right into a trap. It's really just a mind game.

The Ambler Warning was actually published in 2005, based on an unfinished manuscript Ludlum was working on when he passed away in 2001. In other stories of his that I've read he generally likes to run a chronological race, with very economical use of facts. This requires efficient reading, because rarely is anything said twice. The socio-political setting of the story also lets certain bits of information permeate from the surroundings. And when it comes to giving up information, Ludlum keeps you from seeing very far into the horizon. Most of the time he lets you guess and suspect things that won't be revealed for a long time yet. This puts you into a mode of forensics, trying to make what you know go as far as possible. It culminates in the economical resolution of some question, solving it with the least amount of facts possible. At other times he likes to keep you starved of new facts for a while, causing you to go back over what you already know and dig for new deductions in vain, before he finally drops something significant that has a big impact, but which changes so many existing variables that you get overwhelmed by the amount of information you have to process.

In The Ambler Warning we get a different kind of story telling. For one thing, only pieces of the timeline are accounted for, the rest isn't told. But it's enough to make sense of, again playing on the economical use of information. Secondly, the pieces are not told in chronological order. There is a leap from chapter one into what chronologically is the third chapter, but told in a different order.

This changes a lot of the assumptions of a continuous story, the fact book keeping takes on a different model. Since it's not chronological, you can't keep the chapters completely self sufficient, you have to make some modest references to chapter three in order to maintain a smooth reading experience. And as shown in the figure, this builds certain expectations about chapter three. But it does mean that you have to stack up certain facts from chapter two whose meaning you don't yet know, and won't, until you reach chapter three. This is a different mode of puzzle solving than I've seen in other Ludlum books, but it's pretty interesting.

The plot and the characters are actually a bit below par. I wonder if this is the influence of the editor who shaped an unfinished manuscript into a novel. And the conspiracy holds up nicely until the resolution. In fairness, this is very common. Authors build expectation with a meticulous use of detail, but then fail to make the conspiracy live up to those expectations. It's a difficult thing to do, and what they pull off is impressive enough.