Tuesday, February 20, 2007

Some thoughts on programming

In the last several months I've had the "pleasure" of working with several different programming languages for the software I'm developing for my thesis. In a given day I may spend time working with Java, Visual Basic (and VBA), SQL, and XSLT (for XML manipulation).

Sometimes I need to call a Java program from a Visual Basic program, or use Visual Basic to perform XSLT functions. In the near future I'm also going to be working with CLIPS, which rounds out the 5 programming "languages" I've used in my thesis. In past projects I've also worked with SWI-Prolog, LISP, Python, and of course C. The different languages all have their utility, some moreso than others.

A language like Java is great because it makes building off other people's code a snap (assuming it's well documented), and using abstraction and interfaces makes things so much better when trying to manage a complex system (why they don't stress this stuff in CS here at Windsor blows my mind...it was all crammed into the last 2-3 lectures, when it deserves it own course).

A language like XSLT is great at doing XML transformations, but not much else. Having to write all of your code in XML format is really annoying, but it does its job and does it well.

To me, these are the two ways that programming languages should exist. A language should either be general purpose enough to do most things rather well, or specific enough to do a couple of things very well. Bridges between languages are getting better and better, so working in a multiple language framework is becoming less of an issue. This way we can use the broad languages (Java, C, etc.) for most things, then make use of specific technologies like SQL and XSLT when we have a task that suits them.

So what's my point in all of this? Well, it's a roundabout way of me saying this:

Visual Basic 6 sucks, and it sucks hard.

VB is a broad language, designed to be able to do everything. And granted, it does do pretty much anything you ask it to do, but it does it in a way that lends itself to bad code. Everything from the smallest details to big obvious things fail me on a daily basis. And the thing that annoys me is that these things happen by design.

Here are some examples:

You can't comment out multiple lines at once using a block comment (like /* ... */ in C/Java), you can only comment out individual lines at a time...this is insanely annoying while trying to debug your code or do any major documentation

The Visual Studio editor is the worst IDE I've ever used. Notepad is more useful as a programming tool. It does so many little things that bother me. For example, if you're in the middle of typing a line of code, and you try to move the cursor off of that line before the line is done, it gives you a warning message that you have to dismiss before you can continue. It happens all the time where I'll be writing a line, then realize I can just cut and paste a long variable name, or I notice a mistake in another part of the code that I want to go and fix. And invariably the damn thing will bark at me.

Brackets? Who needs brackets? Look through some VB code and the first thing you'll notice (especially if you're used to Java/C style code) is the lack of brackets used in the code. They're used in method signatures, and are sometimes used when you call functions. There is nothing worse in a programming language than having it behave differently in situations that are seemingly the same. When you call a function in VB, you generally don't need to include brackets around the arguments, unless you want to do something like have access to the function's return value. If you want to call a function you can just ignore the return value by not using brackets, even though the function explicitly returns a value.

And of course, Visual Basic does not include any ability to do abstraction or interfaces. Pretty much the most powerful feature of object-oriented programming is left out of visual basic. This is just plain obnoxious.

I think the idea is that VB is designed to be more of an entry-level programming environment, and I tend to get annoyed because I know there are a bunch of way better alternatives out there that I'd prefer to use. But since I'm working with a system that was built on Visual Basic, I'm forced to toil away in it.

Damn, that felt good to moan about :)

6 comments:

Zutroy said...

If you're going to toil away in notepad, away from any IDE, I recommend you at least get notepad2:

http://www.flos-freeware.ch/notepad2.html

It's your nice, clean notepad, but with some programmer friendly enchancements, like syntax highlighting, inserting tabs as multiple spaces, guidelines for tabs, brace matching, numbered lines, and so on.

GET IT! :)

James said...

The only problem with using Notepad for VB is that some of the work I do is UI based, and frankly I'm scared to try and run anything VB related in a non-VB environment (I just don't trust MS).

For most of the other stuff I do, Eclipse works great. Obviously it's best for Java, but with plugins you can do lots more. It also has CVS access built in which is a nice feature.

Thanks for the tip about notepad2 though. I've been looking for a notepad replacement, but couldn't be bothered to learn vi.

Have you tried Emacs before? There are times when it's the greatest thing in the world, but there's so much additional customization that needs to be done beyond the base install to make it really useful that it just seems like a pain. Of course I know someone who used it to write his thesis, so what do I know? :)

Zutroy said...

Actually somehow I've managed to all this time without ever touching emacs. I still don't see a reason why I should

James said...

Emacs is neat if you're willing to put in the time to learn all the keyboard shortcuts and to customize the hell out of it, but that's about it. And for me, it just hasn't been worth the effort.

The only time I've really used it is for LISP, since "LISP in a box" is basically a LISP implementation built into Emacs. It was neat to do all your editing and compiling and have your interactive prompt all rolled into one, but then again that's basically what an IDE is for anyway.

Medieval said...

Thank god my thesis work doesn't really involve programming :)

I like programming: but only small programs :)

Scott McCarthy said...

Have you tried VB.net? I pretty much use nothing but. The software I am working on uses everything from 3D directx rendering, xml databases and data analysis and fitting. I much prefer it to previous versions of VB.
In the .net environment the line between C and VB is blurring.
Microsofts goal is to eventually have one language with the ease of VB but the power of C.