VB#

I’ve been a Visual Basic programmer since ‘98 - actually earning money programming in VB6 that is. I dabbled a bit with similar concept previously although they were called Access Basic or later Visual Basic for Applications. Then one day Microsoft decided to join the object oriented crowd. They claimed that VB6 was an object oriented language or at least could be used at such but few ever figured out how. Along came the .Net Framework and C#. Woohoo!

I managed to get involved in a few C# projects at work - the learning by doing kind. And when things started getting interesting I got to create applications for PocketPCs using .Net Compact Framework. You were hampered by the fact that several neat features in the full framework didn’t make it to the compact version but there where workarounds that still made it enjoyable albeit frustrating at times. My last C# project actually landed me in the fullframework version 2.0 with some new recruits who actually knew what they were doing. Oh joy, now I managed to learn how it really should be done or at least learn some alternative ways to solve problems using the tools at hand. I evolved from using a hammer and a nail since that was all I knew to using the whole toolbox. Did you know that a screwdriver was more than just a drink?

Which brings me back to the title and the reason for my rant. I’m currently in new project at a goverment agency. The first time outside the office for an extended period which is great. And this agency’s IT-policy is that all projects shall be developed in Visual Basic. I’m back to square one, sort of. We get to use .Net Framework 2.0 and Visual Studio 2005 which is a great tool to work with compared to previous versions. And Microsoft has forced Visual Basic into the object oriented universe. They had to if it was going to comply with .Net since the framework is built using an object oriented paradigm. But (A) why couldn’t they do it right? And (B) why can’t I get my brain to revert back to Visual Basic syntax?

Why the (A) you might ask and rightly so. If I tell you that AndAlso and OrElse actually are valid keywords you start to get the picture. In previous versions of Visual Basic the logical operands And and Or evaluated all expressions which meant that you couldn’t check for the existance of a value and it’s validity in the same If statement. In most other language the logical statements shortcircuit, by which I mean that And evaluates from left to right and at the first False the evaluation terminates. Likewise for Or except that it terminates at the first True statement since the the entire statement must be true. When they gave Visual Basic CPR and transformed it into VB.Net they didn’t alter the behaviour of And or Or instead they added shortcircuiting equivalents and named them … Yes, you guessed it! AndAlso and OrElse. WTF!

The (B) is because I have been spoiled using C# and somehow everything I write now is a mix of the two. In C# you declare an object by it’s type and then it’s name. In VB it’s the other way around. In VB there is no end of statement character, each statement is on one line and one line only. Well not entirely true but true enough compared to C# where each statement is terminated by a semicolon so that a statement can be formatted for readability and still compile. I’ve gotten so far that I actually manage to get the basic method declarations correct with qualifiers before the name and the return type at the end but I still write the actual parameters in the C# way using type and then name; hence VB# the bastard offspring of a deranged VB/C# programmer.

7 Responses to “VB#”

Gravatar
Sweden

Hehe, I’m sooo glad that I’m not working with VB! AndAlso, OrElse. *Brrrrrrrr*

Gravatar
Sweden

I have not had the pleasure(?) of using VB, unless it is VB that you can use to “program” Access with. Because in that case I have touched it and actually felt dirty for days. Or at least dirty enough to realize I was better of just rewriting the whole thing with something better ;)

C# seems nice though, will definetly try it if I get any reason to. I mean, it is possible to run .NET on Linux too :)

Gravatar
Sweden

Yupp, .Net and C# is pretty nice. I recently read Martin Fowlers book about refactoring and was well into chapter two before I realized that his examples were written in java and not C#. :-)

I’m probably going to get ostracaized by the Microsoft community for saying this but the .Net Framework is very close to being a rip off of java. An intermediate byte code between source code and machine code, a common base class library, a virtual machine or runtime to interpret the intermediate byte code and so on.

Gravatar
Sweden

Hmm, yeah, but I guess that goes for Python as well, which is my current language of choice. It’s far less talkative than Java and C#, but requires a bit of caution since it is loosely typed.
But you have to love languages where a HelloWorld program consists of only one line:

print “Hello World!”

;)

Gravatar
Sweden

Oh, I don’t know if being able to write a Hello World program on one line necessary is a good thing. I give you BrainFuck [http://en.wikipedia.org/wiki/Brainfuck].

++++++++++[>+++++++>++++++++++>+++>+< <<<-]>++.>+.+++++++..+++.>++.< <+++++++++++++++.>.+++.——.——–.>+.>.

Well, the entire line is a bit to long for my blog but you can always look at the wikipedia entry. :-)

Gravatar
Sweden

Well, yeah, I consider Python to be a bit more readable :P
I knew about Brainfuck, but I have not seen any code written in it. Looks… fucked up, yes…

Then there is always the International Obfuscated C Code Contest (http://www.ioccc.org/) if you want to see code that is really really obscure, but still beutiful in a weird way.

Gravatar
Sweden

Pfft! Brainf*ck is for children! Real programmers use INTERCAL!

DO .1

Something to say?