This site will look much better in a browser that supports web standards, but is accessible to any browser or Internet device.

Anomaly ~ G. Wade Johnson Anomaly Home G. Wade Home

December 11, 2004

On Programming Languages

I find that I have a different viewpoint about programming languages than many programmers I've met. I feel that a programming language embodies three different things:

  • a tool for solving problems
  • an approach to thinking about solutions
  • a notation

I don't believe that there is any language that is the best or most powerful in all situations. Trying to say one language is better than another is like saying a screwdriver is better than a hammer. Without knowing what problems you want to solve, the conclusion is meaningless. Each language has strengths and weaknesses. Although you can write any program in any language, some programs are easier to write in one language than another. That is one reason why learning multiple languages is a good thing, more tools for your toolbox.

More importantly, I think that learning many different kinds of programming languages helps improve your programming by making your mind more flexible. I believe that knowing more than one different kind of programming language makes you a better programmer than knowing any particular language.

Many people in the programming field who are more experienced and probably smarter than I am have recommended learning multiple different kinds of languages to make yourself a better programmer. In many cases, I have seen people discard this advice based on the conclusion that all you need is to pick the best language and use it for everything. This approach falls apart when you realize that part of the purpose of using different languages is to improve how you think.

In my mind, it's the multiple kinds of languages that is important, not the particular language. The corollary is that knowing one language is does not really improve your programming ability no matter what language it is. Knowing only Java is not much better than knowing only Fortran 77. In both cases, you are limited to only one view of the world.

This is one of the disagreements that I had with Paul Graham's book Hackers & Painters. He argues that since Eric Raymond says that learning Lisp will make you a better programmer, you should always use Lisp since it is the best tool for the job. I did learn Lisp and found it to be extremely enlightening. Not because I was more effective in Lisp, because I wasn't. But, learning to program well in Lisp gave me a new perspective on approaching problems that I could take back to whichever language I am using.

The useful thing about Lisp is that it approaches problems from such a different direction that you are forced to see problems and solutions in a completely new light. This new approach drastically improved my ability to solve problems in both Perl and C++, since both of these languages provided the appropriate tools to allow me to exploit this new viewpoint. Amusingly enough the macros concept that Graham makes such a big deal about in his book was not new to me. I'm an old Forth programmer and that sort of approach is standard fare in Forth.

So programming languages are tools that we use and different languages encourage different ways of looking at problems and solutions. The third face of a programming language is notation. The language provides a way of expressing a solution. Not all notations, or ways of expressing a solution, are equivalent.

When you are doing massive amounts of text processing, regular expressions are a wonderful thing. Although the regular expressions may look somewhat arcane, they are an extremely succinct and (sometimes) readable way to express a search for an arbitrary string in a piece of text. It's not that you couldn't code the same search without regular expressions. you could write large amounts of special-purpose code to search for a particular string, but the regular expression syntax will almost always beat the handcrafted code in usefulness because the notation is expressive and succinct.

You should learn multiple programming languages, and use each one enough to really understand it. There are three major reasons to do this.

  1. Multiple tools allow you to select the best tool for a job.
  2. Different languages encourage different approaches to problems and solutions.
  3. Different notations help you express different solutions clearly.

The second two, of course, explain the first. All programming languages would be equal if the provided neither differing viewpoints or different notations.

Posted by GWade at December 11, 2004 11:24 PM. Email comments
Comments