We can’t write expressive code

Ever since there are programming languages, good programmers have tried to write code that is expressive enough to be understood and maintained. However, put two good programmers face to face and chances are they might agree on what expressive mean but they won’t agree on how to do it.

haskel

Some think that less is better and prefer to use a language whose syntax is compact, preferably a functional language or similar. Some think that the temptation to write one-liners (or punches in the good o’ days of GFA Basic…) being too strong, the code will be compact but not readable.

Some think that comments are very important. Like Jef Raskin who would write its code embedded into a standard text processor (1). Some think that comments are by nature out of sync with the code, so dangerous, and prefer unit tests to express code behavior.

Some prefer to write long procedures you can read linearly, some prefer lots of classes and methods, some prefer OO/Aspect/Ioc/(any buzzword) oriented programming, some think this is dangerous dark magic that changes the code in your back.

Some think that code structure should be treated like GUIs structure, following the same rules to make it quickly usable by new developers. Some think that this is a lost crusade since programming languages tend to not follow Jef Raskin’s Monotony of design rule: there should be only one way to accomplish a certain task in an application.

I think that it’s impossible to write code that is understandable by every developer, even if you focus only on good developers. Every communication between human beings is ambiguous by nature.

We understood this some times ago about written specifications but not yet for written code. Understanding a piece of code is so linked to the context it is presented to you, to your knowledge of the programming language, to your level of expertise in this language…

One advice that XP teams teach us: agree on coding standards within your team. This is complex enough to not even try to convince people outside the team.

(1) Programmers at Work: Interviews With 19 Programmers Who Shaped the Computer Industry

3 thoughts on “We can’t write expressive code”

  1. “it’s impossible to write code that is understandable by every developer”

    I think you’ll agree that this sentence is better expressed as “it’s impossible to write code that is IMMEDIATELY understandable by every developer”
    The ‘immediately’ is key here, because it is impossible to write anything that can be understood immediately, if only because the very process of reading takes a while. This is important, as it means that you will always a degree of effort to do to understand the code, even by the person who wrote. All we can hope for is to reduce the effort for the majority of people that will read it now and in the future.

Comments are closed.