Pride and revulsion

Here's a bug that bit me recently. I wrote a very small quick and dirty TDD header for C in my CyberDojo. It has a macro called CHECK_EQ which you use as follows:
CHECK_EQ(int, 42, 9*6);
Part of the macro looks like this:
#define CHECK_EQ(type, expected, actual) \
    ... \
    type e = expected; \
    type a = actual; \
    ... \
Can you see the problem? Well, suppose it's used like this:
    int e = 42;
    CHECK_EQ(int, e, 9*6);
Can you see it now? The problem is that this line in the macro
    type e = expected; \
gets expanded into this line:
    type e = e; \
Ooops. I thought about choosing a very cryptic name instead of x. Perhaps incorporating __LINE__ as a suffix. But I felt there had to be a solution that would always work. After some thought I came up with this. Brace yourself...
#define CHECK_EQ(type, expected, actual) \
   if (#expected[0] != 'x') \
   { \
       type x0 = expected; \
       type x1 = actual; \
       ... \
   } \
   else \
   { \
       type y0 = expected; \
       type y1 = actual; \
       ... \
   } \
Like Tom Duff, I feel a mixture of pride and revulsion at this discovery.

The war of art

is an excellent book by Steven Pressfield (isbn 0-446-69143-7). As usual I'm going to quote from a few pages:
Every sun casts a shadow, and genius's shadow is Resistance.
The enemy is a very good teacher [Dalai Lama]
The human being isn't wired to function as an individual.
The truly free individual is free only to the extent of his own self-mastery.
Rationalization is Resistance's spin doctor.
Nothing is as empowering as real-world validation, even if it's for failure.
That's when I realized I had become a pro. I had not yet had a success. But I had had a real failure.
The professional knows that by toiling beside the front door of technique, he leaves room for genius to enter by the back.
Whatever you can do, or dream you can, begin it. Boldness has genius, magic, and power in it. Begin it now. [Goethe]
The Self wishes to create, to evolve. The Ego likes things just the way they are.
We humans seem to have been wired by our evolutionary past to function most comfortably in a tribe of twenty to, say, eight hundred.


is an excellent book by Gary Marcus (isbn 978-0-571-23652-7). As usual I'm going to quote from a few pages:
The best science, like the best engineering, often comes from understanding not just how things are, but how else they could have been.
One molecule of DNA polymerase does its job in a perfectly straight-forward fashion, but the other does so in a back-and-forth, herky-jerky way that would drive any rational engineer insane. Nature is prone to making kluges because it doesn't "care" whether its products are perfect or elegant. If something works, it spreads. If it doesn't, it dies out.
What can evolve at any given point in time is heavily constrained by what has evolved before.
The vast majority of our genetic material evolved in the context of creatures who didn't have language, didn't have culture, and didn't reason deliberately.
What is recent is rarely fully debugged.
Our memory is organized to focus primarily on our own experiences.
Other studies have showed that people are more likely to accept falsehoods if they are distracted or put under time pressure.
Organisms tend to value the present far more than the future.
That which is clumsy is rarely reliable.
In physics, they have laws; in biology, we have gadgets [Francis Crick]
The value of imperfections extends far beyond simple balance, however. Scientifically, every kluge contains a clue to our past; wherever there is a cumbersome solution, there is insight into how nature layered our brain together; it is no exaggeration to say that the history of evolution is a history of overlaid technologies, and kluges help expose the seams.

How do you make toast?

I'm doing two days consultancy in Cornwall. Yesterday for the folks at Research Instruments in Falmouth and today for the folks at Absolute Software in Redruth. Both are really great places to work and it's a joy visiting them.

I'm staying at the Penventon hotel. My usual breakfast routine is tea, porridge, and toast. They have a big silver toaster. You put your slices of bread into the front, it pulls them in slowly, applies a lot of heat, and then drops them down a shute.

Yesterday they came out mostly black.

I tried scraping them with a knife. I won't bother next time. They never taste good when you do that. All I did was create black dust for someone to waste time cleaning up. They didn't taste good. I didn't eat them.

I was reminded of the joke:

How do you make toast?

You burn bread and scrape the burn off.

Today I put my toast in the same as before. The toaster slowly pulled them in, applied heat, and dropped them down the chute. The slices were under toasted this time. So I put the slices in again. The toaster pulled them in again, applied heat again, and dropped them down the chute again. Just right. No knives. No scraping. No black dust. No cleaning up. I added marmalade. I ate them. Lovely.


is an excellent book by Chris Anderson (isbn 978-1-9052-1148-7). As usual I'm going to quote from a few pages:
The internet is the first distribution system in history that is as well suited for the niche as for the mass, for the obscure as well as the mainstream.
Just as Moore's Law dictates that a unit of computer processing power halves in price every two years, the price of bandwidth and storage is dropping even faster.
For most of human history manure has determined how much food we had... Historians often look at the great civilizations of the ancient world through the lens of three grains: rice, wheat, and corn. Rice is protein rich but extremely hard to grow. Wheat is easy to grow but protein poor. Only corn is both easy to grow and plump with protein.
Humans are wired to understand scarcity better than abundance.
At some point in your life, you may wake up and realize that you have more money than time.
What [Alan] Kay realized was that a technologist's job is not to figure out what technology is good for. Instead it is to make technology so cheap, easy to use, and ubiquitous that anybody can use it.
Abundant information wants to be free. Scarce information wants to be expensive.
Paradoxes are the opposite of contradictions. Contradictions shut themselves down, but paradoxes keep themselves going, because every time you acknowledge the truth of one side you're going to get caught from behind by the truth on the other side.
Information is what British anthropologist Gregory Bateson described as "a difference that makes a difference."
The electricity consumed by a server now costs more over the life of that server than the server itself.
Rather than depriving life of purpose, material abundance created a scarcity of meaning.


is an excellent book by Matthew Syed, subtitled The myth of talent and the power of practice (isbn 978-0-00-73505404). As usual I'm going to quote from a few pages:
Ericsson also found that there were no exceptions to this pattern: nobody who had reached the elite group without copious practice, and nobody who had worked their socks off but failed to excel.
It is the quality and quantity of practice, not genes, that is driving progress.
The ascendency of the mental and the acquired over the physical and the innate has been confirmed again and again.
My dad never asked me to play golf. I asked him. [Tiger Woods]
Child prodigies do not have unusual genes; they have unusual upbringings.
Top skaters fall over more during their practice sessions.
But while the adaptability of the human body is impressive, it is the plasticity of the brain that has astonished researchers.
If you don't know what you are doing wrong, you can never know what you are doing right.
These were some of the clearest findings I've ever seen. Praising children's intelligence harms their motivation, and it harms their performance. [Carol Dweck]
Lowering standards just leads to poorly educated students who feel entitled to easy work and lavish praise. [Carol Dweck]
Many of the contemporaries of Galileo (inventor of the modern telescope) really did think there was something morally dubious about the telescope; that it was taking humanity beyond the powers expressly sanctioned by God.

JavaScript: The Good Parts

is an excellent book by Douglas Crockford (isbn 978-0-596-51774-8). As usual I'm going to quote from a few pages:
This is not a book for beginners... This book is small but it is dense. There is a lot of material packed into it. Don't be discouraged if it takes multiple readings to get it. Your efforts will be rewarded.
JavaScript's popularity is almost completely independent of its qualities as a programming language.
JavaScript is the first lambda language to go mainstream. Deep down, JavaScript has more in common with Lisp and Scheme than with Java.
strong typing does not eliminate the need for careful testing.
despite its deficiencies, JavaScript is really good.
Unlike many other languages, blocks in JavaScript do not create a new scope, so variables should be defined at the top of the function, not in blocks.
An object is a container of properties, where a property has a name and a value. A property name can be any string, including the empty string. A property value can be any JavaScript value except for undefined.
An inner function also enjoys access to the parameters and variables of the functions it is nested within... This is called closure. This is the source of enormous expressive power.
That act of nothingness gives us confidence that the function does not recurse forever.
What matters about an object is what it can do, not what it is descended from. JavaScript provides a much richer set of code reuse patterns.
Much of the complexity of class hierarchies is motivated by the constraints of static type checking.
var memoizer = function(memo, formula) {
    var recur = function(n) {
        var result = memo[n];
        if (typeof result !== 'number') {
            result = formula(recur, n);
            memo[n] = result;
        return result;
    return recur;

var fibonacci = memoizer([0, 1], function(recur, n) {
    return recur(n - 1) + recur(n - 2);

Simple and Usable

is an excellent book by Giles Colborne (isbn 0-321-70354-5). As usual I'm going to quote from a few pages:
If you ask people they'll say everything is important and anything is feasible.
We tend to keep things, even when they're broken.
Your first design may seem like a solution, but it's usually just an early definition of the problem you are trying to solve. [Luke Wroblewski]
Broken gets fixed. Shoddy lasts forever. [Jack Moffett]
Feature lists sell so as long customers don't get a chance to use the product.
Mainstreamers want "good enough quickly;" experts want "perfect in as long as it takes."
People prefer to be pilots, not passengers.
"Seven plus or minus two." Many psychologists now believe short-term memory may be rather smaller - perhaps just four items.
Simple organization is about what feels good as you're using the software, not what looks logical in a plan.
Designing simple user experiences often turns out not to be about "How can I make this simple?" but rather "Where should I move the complexity?"
The secret to creating a simple user experience is to shift complexity into the right place, so that each moment feels simple.
Don't try to fill your user's mind with your design.


is an excellent book by Richard Thaler and Cass Sunstein (isbn 978-0-141-04001-1). As usual I'm going to quote from a few pages:
School children, like adults, can be greatly influenced by small changes in the context.
There is no such things as a 'neutral design.'
Roughly speaking, losing something makes you twice as miserable as gaining the same same thing makes you happy. In more technical language, people are 'loss averse'... Loss aversion helps produce inertia.
Most teachers know that students tend to sit in the same seats in class, even without a seating chart.
Eating turns out to be one of the most mindless activities we do. Many of us simply eat what is put in front of us.
Social scientists generally find less conformity, in the same basic circumstances as Asch's experiments, when people are asked to give anonymous answers.
On average, those who eat with one other person eat about 35 percent more than they do when they are alone; members of a group of four eat about 75 percent more; those in groups of seven or more eat 96 percent more.
Self-control issues are most likely to arise when choices and their consequences are separated in time.
Even hard problems become easier with practice.
The best way to help Humans improve their performance is to provide feedback.
For most of their time on earth, Humans did not have to worry much about saving for retirement, because most people did not live long enough to have much of a retirement period.

public: footpath

You know you know C++ when you see a sign like this and you think, "there's a colon missing after public."

rules of thumb

don't rush

I don't think I can put it any better than Jerry Weinberg did when I interviewed him:

Things take the time they take, not the time you hope they will take. Pushing for half-time produces half-baked.

As a self-employed software coach/consultant I get to travel a lot and visit a lot of companies. At the best companies there is a palpable sense of not rushing.

think team

Software development is all about collaborative learning. I think one of the weakest points of the Agile Manifesto is it's lack of emphasis on teams. The very first word of the four "X over Y" statements is Individuals :-( XP at least takes a firm step beyond programming as an individual activity by mandating pair programming. I look at Sit Together, a practice from XP1 and I think s/Sit/X/. In other words, whatever X is, X Together.

increase visibility

Software and the process of developing it can be, to paraphrase Douglas Adams, mostly invisible. You think more clearly when you have something concrete to tie your thinking to. You manage things better when you can see them and see them constantly changing. It's no accident that Kanban boards are as popular as they are.