The Programmed

One thing that amazes me is the way that if someone has determined the way that a programming language must be written, it must be done in one and only one way. Take, for example, function naming. If I want to read a document from a file in C, I would name the function read_from_file. In C++ and Java, that’s readFromFile, and in C# it is written ReadFromFile. Nothing about any of the languages dictates this notation, but if something isn’t written this way, it just feels wrong.

Now, take braces as another example. A simple if-then-else construct in C looks like:

if (i == 1) {
      i++;
} else {
      i--;
}

In C++, you don’t use braces unless you have do. Otherwise, you’re not elite.

if (i == 1)
      i++;
 else
      i--;

In Java, you don’t end a code segment and start another on the same line:

if (i == 1) {
      i++;
}
else {
      i--;
}

In C#, it’s nice to be extra verbose:

if (i == 1)
{
      i++;
}
else
{
      i--;
}

Notice that none of the actual syntax changed in any of these examples. Why do languages strive to be different like this? How is it that the programming languages program the humans? It’s true that brace conventions are less universally accepted, and often used as a way to add a sense of “style” to one’s code without changing readability terribly, but such conventions are usually followed for whaetever reason. In Python, however, indendation matters to the point that it changes program flow, so braces aren’t such an issue.

While anyone could just write what they wish the way that they personally like it and the compiler wouldn’t think any different, I always feel wierd when I don’t match certain pointless conventions to the language that I’m writing in.

One Response to “The Programmed”

  1. Beth Says:

    You think too much sometimes….

Leave a Reply



Warning: fsockopen() [function.fsockopen]: unable to connect to twitter.com:80 (Connection timed out) in /home/.chat/jsheldahl/worus.net/wp-includes/class-snoopy.php on line 1150