Archive for April, 2004

javac Is Not Universal

Friday, April 30th, 2004

The project presentation went well. The professor didn’t really seem that excited about what we had done, not that he did about anyone that he was looking at that day. It kind of seems like it would be a good idea to pretend to be interested or enthusiastic about student’s semester projects. It kind of fosters learning.

There was a horrible state of confusion ten minutes before the presentation where things wouldn’t work in the GUI, but would work on the command line. No one had any idea why. That was an incredibly stressful ten minutes.

I wrote so much Java this week that when trying to figure out how to use vectors of pointers in C++ this week with an example program, I tried to compile my C++ with javac. Oksana made fun of me.

It’s Beth’s birthday tomorrow. Word to that.

The Programmed

Thursday, April 22nd, 2004

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.