I’m going to use Ayende’s blog post here as a basis for a bit of a rant. Ayende points out that Ruby doesn’t have increment or decrement operators and ponders their continued usefulness in languages like C#.

In C# the major use for the post increment/decrement operator is in a for loop, for example:

  1 for (int i = 0; i < something; i++)
  2 {
  3 }

The increment/decrement operators compliment this syntax nicely and its hard to imagine it going away. But Ayende also contends that the following code is more readable as a free standing statement:

  1 i += 1;

I’m not going go out here and say that he is wrong – instead I am going to say – only in your mind. Thats not an insult, its realisation that everyone reads code differently.

Lately I’ve been doing a lot of reading around how the human brain learns and essentially we are just a huge pattern recognition machine. In order to recognise and interpret patterns we need to be trained. What Ayende is picking up on here is that his brain has been trained to recognise i += 1 as an increment and i++ goes against the wiring of his brain – stimulating him to take corrective action.

I’ve been wired differently so I definately use i++ in for loops and its not uncommon for me to use one in a while loop either. We are just wired differently.

The danger of adding and removing syntactical elements (removing in particular) is that you force people to discard a whole set of neural pathways that potentially make them a more effective programmer.

Aren’t things interesting when you look at them at the biological level?!?