Originally published by Robert Beisert at fortcollinsprogram.robert-beisert.com

What You See Is All You Get (WYSIAYG)

I’ve spent a number of years refining my arguments against modern object oriented programming languages. While I support and admire the principles upon which object oriented programming rest, the complications inherent to modern languages produce shoddier and increasingly difficult to maintain code.

It turns out that the key principle that underlines my philosophy of programming was enumerated by Kernighan over 40 years ago:

What you see is ALL you get

This is the beauty of the C programming language (and the other languages on which Kernighan labored). If your code doesn’t do something you wanted it to do, it’s because you didn’t write it. If your code does something you didn’t expect it to do, it’s because that’s what you told it to do.

There are very few rules for C programming, and this is the cornerstone.

My chief concern with C++, Java, Python, and the hundreds of other languages that have come and gone is that they require the author to keep hundreds of unrelated rules in focus at any given time. This is largely due to the much-touted feature of polymorphism – the ability to assign multiple meanings to the same name.

Polymorphism in its modern form allows us to write an entire program using only the + symbol and the semicolon. If we were to ask a C++ programmer what the following means:

a = b + c;

he would have to confess that it could mean everything from arithmetic addition to “send a threatening email to Afghanistan using the Tor browser and my Yahoo email account”. In such a language, only the truly genius can ever fully comprehend what the code is doing at any given time.

This is a major violation of the WYSIAYG principle, which makes it extremely difficult to read and maintain code. However, the bigger violation exists in the concept of templates.

Template classes are written in a way that explicitly prohibits comprehension and reduces the value of hundreds of useful programming tools. In these cases, we use a dialect that defies grep and ctags to produce a “factory” that “creates” classes and functions when referenced. This means that the final program contains hundreds of operations that are completely absent from the original sources. Debugging template-generated code is a pain-and-a-half.

The Joy of Knowing What’s Going On

When you have code that does exactly what it says on the page (no more, no less), you eliminate the computer from your programming efforts. All the operations of the program rely solely on the programmers, and it is in their best interest to produce code that they can read and maintain easily. The WYSIAYG principle reduces the time spent checking rules and referencing objects, allowing programmers to spend more time generating valuable code.

This means that we can write code without the thousands of features contained in modern IDEs. We do not need code completion to figure out what things do and how they work. We don’t need namespace-checking features to ensure that our objects operate as expected. We don’t need complicated debuggers to strip horribly mangled names down to readable variables.

Most importantly, we are never at the mercy of the computer to interpret what we meant to do. This eliminates a highly unstable element in our code, allowing us to produce more reliable code faster.

photo by: