Just Because You Can

by Tim Cull

Every language I’ve ever learned contains at least one (usually more) warts on it that are left over from the predominate language before it, mostly to avoid turning off people who would otherwise not migrate.

These warts are usually bad to use. The classic example is GoTo, leftover in many languages to keep the attention of assembly language programmers. In a high-level language, you just shouldn’t use GoTo.

In Java, you can create a one-line ‘if’ statement without any braces just like you can in C. That doesn’t mean it’s a good idea.

In Visual Basic (pre-.Net) you have the Variant datatype that can be almost anything. You can also declare arrays to start with any index (not just zero).

Many web browsers will accept paragraph tags in HTML that don’t have any closing tag. Or any number of other tags that don’t have closing tags, even thought it means you don’t have a well-formed XHTML document.

In perl, you can write an entire program on one line.

All of these things are examples of why just because you can do something in a language doesn’t mean you should. And I think learning the difference between what you can do and what you should do is one of the things that differentiates a hacker from a real software craftsman.

Bookmark and Share


Comments are closed.