Why Microsoft Programming Is Easy

The venerable computer scientist Donald Knuth invented the phrase "Literate Programming" to promote good style. He believed that programs should be written to be read by humans, not computers. Such advice might lead you astray when you begin to program with Microsoft development tools.

Have you tried to read the code produced by a Microsoft wizard? Many strings are in uppercase, suggesting that they are probably macros. Global typedefs, functions, and variables are everywhere. Strange keywords and syntax appear. Will this ever make sense to you, or must you learn to read code like a computer?

Think of code from Visual C++ as a persistent record of your mouse clicks, not a substitute for typed code. There are similarities, but it isn't really C++ anyway. (Just try compiling it somewhere else.) In your "project" you find other strange subscripts on new files that are just as important for your compilation. Do they bother you as much? Do you feel bad about not understanding a binary Excel file?

Use tools like Visual Studio to solve problems that exist only on the Microsoft platform. If you're lucky, you won't have to insert more than a few lines by hand in this generated code. Think of such modifications as hacking, and you'll have more fun.

Any reusable and portable code, such as numerical algorithms, should be written in the old-fashioned literate manner, then linked with a few hooks you have inserted in the Microsoft code. Approach your unportable Microsoft coding like a casual user of Excel or Powerpoint. If you're spending too much time on it, then you're trying too hard.

Would you rather build upon the rules of good style you have painfully acquired over the years? Forget it, at least when you are hacking unportable code. This is the programming environment of your childhood. Write as if your system, your compiler, and your hardware will never change.

Your unportable code will not break immediately, because Microsoft maintains backward compatibility for at least one major upgrade of the OS. By that time, you'll want to rewrite anyway. Their programming frameworks, patterns, and paradigms change continuously, so you'll never master anything approaching "good style." Don't try. Microsoft must worry whether code written by their development tools breaks or not. Good style only matters for code that you have to maintain.

Just remember that if you have an algorithm you ever want to use again, then write it yourself. Don't involve the system, unportable libraries, or development tool syntax. Just do it the way you learned back when you took programming seriously.

Bill Harlan, 1998


Return to parent directory.