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:  

Using these links earns us commission at no cost to you

Review by Brian Clegg

Comments

Popular posts from this blog

Rakhat-Bi Abdyssagin Five Way Interview

Rakhat-Bi Abdyssagin (born in 1999) is a distinguished composer, concert pianist, music theorist and researcher. Three of his piano CDs have been released in Germany. He started his undergraduate degree at the age of 13 in Kazakhstan, and having completed three musical doctorates in prominent Italian music institutions at the age of 20, he has mastered advanced composition techniques. In 2024 he completed a PhD in music at the University of St Andrews / Royal Conservatoire of Scotland (researching timbre-texture co-ordinate in avant- garde music), and was awarded The Silver Medal of The Worshipful Company of Musicians, London. He has held visiting affiliations at the Universities of Oxford, Cambridge and UCL, and has been lecturing and giving talks internationally since the age of 13. His latest book is Quantum Mechanics and Avant Garde Music . What links quantum physics and avant-garde music? The entire book is devoted to this question. To put it briefly, there are many different link...

Should we question science?

I was surprised recently by something Simon Singh put on X about Sabine Hossenfelder. I have huge admiration for Simon, but I also have a lot of respect for Sabine. She has written two excellent books and has been helpful to me with a number of physics queries - she also had a really interesting blog, and has now become particularly successful with her science videos. This is where I'm afraid she lost me as audience, as I find video a very unsatisfactory medium to take in information - but I know it has mass appeal. This meant I was concerned by Simon's tweet (or whatever we are supposed to call posts on X) saying 'The Problem With Sabine Hossenfelder: if you are a fan of SH... then this is worth watching.' He was referencing a video from 'Professor Dave Explains' - I'm not familiar with Professor Dave (aka Dave Farina, who apparently isn't a professor, which is perhaps a bit unfortunate for someone calling out fakes), but his videos are popular and he...

Everything is Predictable - Tom Chivers *****

There's a stereotype of computer users: Mac users are creative and cool, while PC users are businesslike and unimaginative. Less well-known is that the world of statistics has an equivalent division. Bayesians are the Mac users of the stats world, where frequentists are the PC people. This book sets out to show why Bayesians are not just cool, but also mostly right. Tom Chivers does an excellent job of giving us some historical background, then dives into two key aspects of the use of statistics. These are in science, where the standard approach is frequentist and Bayes only creeps into a few specific applications, such as the accuracy of medical tests, and in decision theory where Bayes is dominant. If this all sounds very dry and unexciting, it's quite the reverse. I admit, I love probability and statistics, and I am something of a closet Bayesian*), but Chivers' light and entertaining style means that what could have been the mathematical equivalent of debating angels on...