Foundation and Chaos is the second in a trilogy of books written after Isaac Asimov’s death by distinguished Science Fiction writers. The first was Foundation and Fear, which was okay but included lengthy passages concerning Voltaire and Joan of Arc which I didn’t really follow. This book is much better and centres on the growing populations of mentalics, humans with an assortment of mental powers (like persuasion). It also includes Hari Seldon’s trial as a traitor against the Empire (his prediction of the fall of the Empire being seen as treachery). The debate between rival bands of robots (the Giskardians led by R Daneel and the Calvinians), differentiated by their adoption of the zero’th law or otherwise, is fascinating.
Book Review: Foundation and Chaos, Greg Bear
Filed under Book Review
Bruce Dawson – crash investigator
Another great post from Bruce Dawson,
with some valuable tips to check compiler flags in Visual Studio to aid debugging of an entire class of crashes.
/GS, /NXCOMPAT, /DYNAMICBASE, /analyze and all its associated labors – plus actually fixing the bug – took a lot of time, but it was definitely worth it. Most of these changes were trivial and had huge payoffs. Running /analyze was by far the biggest task but, like other smart programmers, I am convinced that it was invaluable. Entire classes of bugs – serious crashing bugs and crazy logic errors – that use to show up quite frequently are now entirely extinct. It is not often that you get to entirely eradicate dozens of types of bugs and doing this definitely increased developer productivity and product reliability.
I’ll certainly check these are set for the projects that I own.
Filed under C++, Programming
How to achieve pattern matching in C++ using boost::regex
Suppose you are parsing text input and need to handle the string representation of a field that could have several formats. In that case, using regular expressions is appealing because you can try a number of patterns sequentially (taking the most likely first) and exit when you get a match.
When I tried to do this in C++, I found it hard to find an easy example to follow. Here’s the way I’ve been doing it, based on a simple example to parse a length that could be in any of several units of measure:
#include <boost/algorithm/string_regex.hpp>
void parse( const std::string& candidate )
{
boost::smatch value;
if ( boost::regex_search( candidate, value, boost::regex( "(.*)ft(.*)in" )) )
{
auto feet = atol( value[1].str().c_str() );
auto inches = atof( value[2].str().c_str() );
std::cout << "Matched " << feet << " feet and " << inches << " inches\n";
}
if ( boost::regex_search( candidate, value, boost::regex( "(.*)m(.*)cm" )) )
{
auto metres = atol( value[1].str().c_str() );
auto centimetres = atof( value[2].str().c_str() );
std::cout << "Matched " << metres << " metres and " << centimetres << " centimetres\n";
}
if ( boost::regex_search( candidate, value, boost::regex( "([0-9]+)mm" )) )
{
auto millimetres = atol( value[1].str().c_str() );
std::cout << "Matched " << millimetres << " millimetres\n";
}
throw std::runtime_error( (boost::format( "Failed to match candidate '%1%' with ft/in, m/cm or mm" ) % candidate).str() );
}
This only uses a fraction of what can be done with regex – the point is to show how to use boost::regex. One gotcha is that, as per the code above, the string matches that are written into value are indexed from 1 – for some reason, the zero’th index accesses the whole candidate expression. Another gotcha is that boost::regex is one of the few boost libraries that isn’t just implemented using templates in a header file, so you also have to add the appropriate .lib into the linker inputs.
Filed under C++, C++ Code, Programming
Usability woes
When working remotely, I am able to log into my desktop machine and work pretty much as if sitting at my desk in the office. Unfortunately, though, whoever wrote the remoting layer thought that “SHIFT+F3” would be an inconspicuous shortcut for logging out immediately, without even a confirmation dialog box.
My main applications include Visual Studio and Excel – so I log myself out several times a day when in-the-zone and either searching code or editing functions respectively.
I’ve resorted to taking the key out to avoid the reconnection penalty every time this happens.
Filed under Musing, Programming
Book Review: The Reversal, Michael Connelly
The other day I watched The Lincoln Lawyer, featuring main character Micky Haller as a defence lawyer. I’d read the book long ago and hadn’t realised that Michael Connelly wrote about a second character (having read several Harry Bosch books). Better still, Haller and Bosch are half-brothers and both feature in this book.
The plot is that Haller is asked to appear as an independent prosecutor in an unusual case – a man found guilty 24 years ago faces a re-trial following some new evidence. Haller appoints his ex-wife as co-counsel (yes, really) and Harry Bosch as his investigator. I found it interesting how chapters written in the first person are told from Haller’s point of view, whereas other chapters are narrated in the third person, typically when describing action concerning Harry Bosch. Of course, in Harry Bosch thrillers, his own chapters are in the first person, so it’s clear the focus is on Micky Haller in this one.
I enjoyed this book – the blurb on the cover referred to the threat to Bosch and Haller’s own families which I didn’t think was explored as much as it could have been, but otherwise it was a good read.
Filed under Book Review
Book Review: Inferno, Dan Brown
This is another in Dan Brown’s series of Robert Langdon escapades, and follows the usual formula. There’s a brilliant, female co-conspirator who seems to cast aside all her initiative and insight on meeting Langdon, becoming merely a foil for Langdon to show off his knowledge of history of art and symbology. And there’s a peculiar, driven assassin – in Da Vinci code it was an albino monk, here it’s a blond biker with spiky hair, but the character is largely the same.
Dan Brown’s books frustrate me greatly – there’s no doubt that the formula is successful and this book is a real page-turner – but there’s no depth to it. As an example, take Robert Langdon. We’re told he always wears the Harris Tweed jackets and the same make of shoe, has done for 20 years. As a wearer of Berghaus outdoor pursuits equipment, I respect that. Yet within minutes of trying an Italian suit and shoes (surely a case of product placement by the company, Brown mentions the maker so many times for no good reason) he makes a mental note to buy the new brand in the future. What?! So much for brand loyalty.
Filed under Book Review
Flow – the secret to happiness?
Interesting TED talk on “Flow”, that sometimes elusive state in which you feel incredibly productive, in which hours fly by and seem like minutes, and when the activity in which you’re engaged is a joy.

It appears that when Sony was founded, they got the idea of flow and set up the company to best achieve it for their engineers. This slide is also interesting:

It claims that flow is only possible for high skills, high challenge tasks. That would explain why I regularly achieve a flow state for harder development tasks that require an extensive skillset, yet a more mundane period of bug fixing is less challenging and so is unlikely to lead to flow.
Apple Watch – the new old watch
Apple have finally announced the Apple Watch. Based on the publicity photographs and rushed reviews that have been published so far, I’m a fan and will probably buy one. But it struck me that the grand new innovation, the Digital Crown, is hardly ground-breaking – my current Tissot watch has had it for ten years!


You see, the functions on my classic Tissot watch are entirely driven by the bezel. As well as the analogue time, it has a stopwatch, timer and digital date/time display.
The bezel acts in several modes:
- Rotate slowly to change hours
- Rotate quickly to change minutes
- Press to start/stop timer or stopwatch
- Pull out to change the time
What’s really clever is that, when the digital functions are hidden, the watch looks completely analogue. And the bezel reacts according to mode – it only bleeps when you press in stopwatch/timer mode, and ignores the press otherwise.
So whilst the Apple Watch is my next watch, my classic Tissot watch was there first.
Filed under Musing, Technology
Book Review: Rogue Male, Geoffrey Household
I picked up this book on holiday, a victim of the “suggested reading” table at Waterstones. Written in 1939, this novel follows the plight of an English gentleman who attempts to assassinate a leading political figure abroad (likely Hitler) and is caught. It’s a compelling read and I enjoyed the occasional humour about the gentleman and his class, alongside the grim reality of his plight whilst on the run. Apparently, a sequel has been written as if narrated by the gentleman’s friend Saul, to be published later this year – that makes me think this book was “suggested” for commercial reasons rather than its status as a classic book.
Filed under Book Review
Book Review: Flash Boys, Michael Lewis
Michael Lewis’s books seem to get better and better. Whilst Liar’s Poker is often cited as a classic, I think The Big Short and now Flash Boys are more interesting. Flash Boys is particularly impressive given that the topic of high-frequency trading is under so much scrutiny, yet Lewis brings to light some of the practices going on in the industry that are not widely known. On top of that, he has a gift for making heroes out of otherwise unremarkable characters.
Filed under Book Review





