Skip to main content

Once upon and Algorithm - Martin Erwig ***

I've been itching to start reading this book for some time, as the premise was so intriguing - to inform the reader about computer science and algorithms using stories as analogies to understand the process.

This is exactly what Martin Erwig does, starting (as the cover suggests) with Hansel and Gretel, and then bringing in Sherlock Holmes (and particularly The Hound of the Baskervilles), Indiana Jones, the song 'Over the Rainbow' (more on that in a moment), Groundhog Day, Back to the Future and Harry Potter.

The idea is to show how some aspect of the story - in the case of Hansel and Gretel, laying a trail of stones/breadcrumbs, then attempting to follow them home - can be seen as a kind of algorithm or computation and gradually adding in computing standards, such as searching, queues and lists, loops, recursion and more.

This really would have been a brilliant book if Erwig had got himself a co-author who knew how to write for the public, but sadly the style is mostly heavy academic, so the cleverness is rather wasted. Sometimes this comes across in labouring points and at others in spending a lot of effort on what is little more than defining labels for things, rather than providing useful information and context for the reader. It's not that there's not a lot of good material in there, just that it's hard work to dig it out, where I'm sure the whole idea of using the stories was to make it more approachable.

Part of the problem is that the stories themselves don't always work very well as an analogy for what's happening in the computation. So, for example, in the section dealing with sorting he comes up with the task of sorting the tasks and places that Indiana Jones needs to deal with to find the Lost Ark. The unsorted list includes the likes of: disc, sunbeam, Marion and Nepal. The algorithm used involves finding the 'smallest' element... which somehow we are supposed to instantly see is Nepal. Using numbers would not have been so well-linked to the story, but at least it would have made some sense to the reader.

Perhaps the low point is the section that uses a part of the song 'Over the Rainbow' (giving us a tenuous story connection to The Wizard of Oz) to examine language and meaning. If you aren't familiar with musical notation, I'm not sure it's a very helpful analogy... and if you are, some of the ways it's used (particular the assertion of what bars are for) doesn't entirely make sense.

I was a professional programmer for a number of years, but without a computer science background. So I was very familiar with how to do this stuff, but knew nothing of the theory behind it. As such, I found the content of the book really interesting - and the story idea should have made it doubly brilliant - but the execution meant that it didn't deliver anywhere near as well as it could have. Even so, there's a lot to savour, and it's definitely worth persevering to get a feel for why computer programs involve far more than just 'cutting code.'


Hardback:  

Kindle:  



Review by Brian Clegg

Comments

Popular posts from this blog

The Art of Statistics - David Spiegelhalter *****

Statistics have a huge impact on us - we are bombarded with them in the news, they are essential to medical trials, fundamental science, some court cases and far more. Yet statistics is also a subject than many struggle to deal with (especially when the coupled subject of probability rears its head). Most of us just aren't equipped to understand what we're being told, or to question it when the statistics are dodgy. What David Spiegelhalter does here is provide a very thorough introductory grounding in statistics without making use of mathematical formulae*. And it's remarkable.

What will probably surprise some who have some training in statistics, particularly if (like mine) it's on the old side, is that probability doesn't come into the book until page 205. Spiegelhalter argues that as probability is the hardest aspect for us to get an intuitive feel for, this makes a lot of sense - and I think he's right. That doesn't mean that he doesn't cover all …

The Best of R. A. Lafferty (SF) – R. A. Lafferty ****

Throughout my high school years (1973–76) I carefully kept a list of all the science fiction I read. I’ve just dug it out, and it contains no fewer than 1,291 entries – almost all short stories I found in various SF magazines and multi-author anthologies. Right on the first page, the sixth item is ‘Thus We Frustrate Charlemagne’ by R. A. Lafferty, and his name appears another 32 times before the end of the list. This isn’t a peculiarity of my own tastes. Short stories were much more popular in those days than they are today, and any serious SF fan would have encountered Lafferty – a prolific writer of short fiction – in the same places I did.

But times change, and this Gollancz Masterworks volume has a quote from the Guardian on the back describing Lafferty as ‘the most important science fiction writer you’ve never heard of’. Hopefully this newly assembled collection will go some way to remedying that situation. It contains 22 short stories, mostly dating from the 1960s and 70s, each w…

David Beerling - Four Way Interview

David Beerling is the Sorby Professor of Natural Sciences, and Director of the Leverhulme Centre for Climate Change Mitigation at the University of Sheffield. His book The Emerald Planet (OUP, 2007) formed the basis of a major 3-part BBC TV series ‘How to Grow a Planet’. His latest title is Making Eden.

Why science?

I come from a non-academic background. None of my family, past or present, went to university, which may explain the following. In the final year of my degree in biological sciences at the University of Wales, Cardiff (around 1986), we all participated in a field course in mid-Wales, and I experienced an epiphany. I was undertaking a small research project on the population dynamics of bullheads (Cotus gobio), a common small freshwater fish, with a charismatic distinguished professor, and Fellow of the Royal Society in London. Under his guidance, I discovered the process of learning how nature works through the application of the scientific method. It was the most exciting t…