Fixed Width Coding

No pro-programmer I know prefers a variable-width typeface to code. On first thought, a fixed-width typeface makes it easy to align statements and numbers. But one can get all that, and more, using tab-stops. So, on second thought, why do we prefer fixed-width typefaces to code? Well, in coding, things that are similar should look similar. Here are three similar lines of code, in fixed- and variable-width.

aap_noot[iii] := 4.1;
aap_noot[mmm] := 4.2;
aap_noot[jjj] := 4.3;
  aap_noot[iii] := 4.1;
aap_noot[mnm] := 4.2;
aap_noot[jjj] := 4.3;

The variable-with code, is more dense, but look how hard it is to spot the error in the variable-with code, where I hit the key left to the ‘M‘ by accident. This error would have been more obvious in the fixed-width typeface because it differentiates glyphs better. Non coders usually don’t understand why this is important. But than again, they never lost three days of work because the ‘I’ looked like an ‘l’. There are special coding-typefaces that provide good differentiation within the glyph groups 0Oo and 1liIL. There is much more to it, so if you are using whatever typeface came with your IDE, you might want to spend some time on this subject. For example read what Dan Benjamin has to say [Top 10 Programming Fonts].

  1. John says:

    Yes, fixed-width fonts are a must, but without syntax coloring it’s only half the battle.

  2. coder says:

    Ok, but if you had to pick either fixed-width or syntax highlighting, which one would you pick? Personally, I would pick fixed-width.

Leave a Reply