DrDobbs posted another example of why you must have proper test coverage in order to avoid introducing regressions into software releases.
Flat Containers in Boost
Jon Kalb posted an article on flat containers in boost.
Alex Stepanov, the STL’s creator, has been quoted as saying, “Use vectors whenever you can. If you cannot use vectors, redesign your solution so that you can use vectors.”
The Boost Container library has a family of flat_* containers that have associative container interfaces and semantics, but are implemented as sorted vectors
Filed under C++, Programming
Floating Point representation
Searching for a neat data type that can represent either a double or an error (similar to a boost::optional but where the name suggests the possibility of error and the type could hold an error string. I came across this StackOverflow page with an excellent answer by Jon Skeet:
Decimal numbers can be represented exactly, if you have enough space – just not by floating binary point numbers. If you use a floating decimal point type (e.g. System.Decimal in .NET) then plenty of values which can’t be represented exactly in binary floating point can be exactly represented.
Let’s look at it another way – in base 10 which you’re likely to be comfortable with, you can’t express 1/3 exactly. It’s 0.3333333… (recurring). The reason you can’t represent 0.1 as a binary floating point number is for exactly the same reason. You can represent 3, and 9, and 27 exactly – but not 1/3, 1/9 or 1/27.
The problem is that 3 is a prime number which isn’t a factor of 10. That’s not an issue when you want to multiply a number by 3: you can always multiply by an integer without running into problems. But when you divide by a number which is prime and isn’t a factor of your base, you can run into trouble (and will do so if you try to divide 1 by that number).
Although 0.1 is usually used as the simplest example of an exact decimal number which can’t be represented exactly in binary floating point, arguably 0.2 is a simpler example as it’s 1/5 – and 5 is the prime that causes problems between decimal and binary.
Filed under Programming
Software as Design
A LinkedIn discussion included a link to this series of essays, written twenty years ago about software as an engineering discipline – lots of it remains true today.
Filed under C++, Programming
Big Software Projects
The BaseLineScenario has posted on ObamaCare. Interesting to that they stress the importance of good people:
Consulting firms, which bill by the hour, make money by staffing projects with lots of people at relatively low cost, which is absolutely the wrong way to develop software; the productivity differentials in software are so vast that you can often get ten times as much output (of quality software) for less than twice the price, while a bad developer will do more harm than good to a project.
Filed under Programming
Book Review: The Sleeping Doll, Jeffery Deaver
Jeffery Deaver has introduced a new character. Special Agent Kathryn Dance is the star of this thriller and, for me, it’s every bit as good as one of his Lincoln Rhyme books. There are massive parallels – Rhyme is an expert criminologist who can track the movements of a suspect by the merest grain of sand that falls from his trousers; Dance is an expert interrogator who can pry into the innermost thoughts of a suspect by spotting the tiniest signals from their body language. I was impressed at the technical depth the author shows in his knowledge of the Kinesics (he even includes a list of books for further reading). And I loved the passage when Dance phoned up Rhyme for advice in the middle of the book and talks to his assistant Amelia Sachs, the other star of those books – priceless. 
Filed under Book Review
Book Review: Foundation’s Fear, Gregory Benford
I picked up this book, the first of “The Second Foundation Trilogy, authorised by the Estate of Isaac Asimov” after enjoying Foundation and Earth. The author admits that he hasn’t tried to imitate the Asimov style – instead, his aim was to explore the character Hari Seldon and his early work on Psychohistory. I really enjoyed the passages concerning Seldon and his wife Dors – especially on the tourist planet when they were immersed into creatures called Pans. However, I couldn’t fathom the passages based on Joan of Arc and Voltaire and ended up skipping whole chapters, without noticeably losing the main thread. I wouldn’t rush to read another by Benford, but I’ll brave the next in this series at some point (it’s written by someone else!).

Filed under Book Review
Book Review: The Enemy, Lee Child
My Dad gave me a rather nice hard back edition of this book – I’d read it once before, but it’s one of the best Jack Reacher thrillers and I was happy to read it again. What makes it so good? Well, it’s a flash back to when Reacher was in the army, and it explains one of the mysteries of this series that’s often mentioned in other books – why did he suffer demotion back to Captain? It also touches on his family background and we see his strained relationship with his brother. It seems that everything and everyone is against him – his awful boss, the higher echelons of the army, his sick mother’s health. Being Reacher, he takes it on the chin, ignores the growing list of dangerous enemies, makes a valuable ally in fellow MP Summer, and stays true to his own code of justice.

Filed under Book Review
High-Performance without Managers
The BBC posted an article about Valve, who have a totally flat structure and leave their star developers to get on with it.
Filed under Soft skills
InterlockedIncrement
Raymond Chen blogged about the internals of InterlockedIncrement and InterlockedCompareExchange.
Filed under C++, Programming