Alfred VS Clint: C# versus VB debate

Disclaimer:  I respect everyone’s right to use their own programming language.  I also respect the accomplishments of certain languages and realize not one language can suite all the needs in the world.  That is why we have functional languages and SQL and so forth.  This is my opinion and my opinion only.

Sir Alfred has challenged me to a nerd off. On twitter, (http://twitter.com/crutkas), I smarted off about my love for C style languages and my coworker, Alfred Thompson(http://blogs.msdn.com/alfredth/), responded in his always well thought out, respectful manner disagreeing with me.

Long story short, I ran into a code translation issue that caused a CLS error when I translated working, non-erroring C# to VB.Net and it got me worked up again on why I dislike VB.

So let us go into why C style languages are the bomb.  Here is some c#

void foo()
{
    if(bar() == 10)
    {
        return;
    }
    else
        doMoreWork();
}
VB:
Sub foo()
    If bar() = 10 Then
        Return
    Else
        doMoreWork()
    End If
End Sub

Very quickly looking at this pseudo code, we know clearly where it ends and starts due to brackets.  If I wanted to make the code tighter, I can move the brackets up (this is another coding style war debate).  I don’t need the brackets if I choose to in the example of doMoreWork().  My source isn’t cluttered with “EndFor” and “EndIf”.  I see a bracket, I know I’m at the end.  No “if () then endif”. 

By enforcing things like parenthesis for if statements, you get a clear reading for what is inside.  I know (bar() == 10) is the whole statement.  I can’t misread it since I know that there will be a ) then a {.

Also, by being more “airy”, I can read it quicker.  It doesn’t read like the Tale of Two Cities.  I can skim and poke, rather than put on my reading glasses and think “it was the best of times, it was the worst of times” and then want to fall asleep no mater how many Dr. Peppers I drank.

When I do run across VB only examples, I transcode them using a few different converters.  Right now I think the Telerik convertor is one of the better ones out there.  http://converter.telerik.com/

While I know Alfred will respond since he won’t let a young whipper snapper like myself off the hook but if anyone does agree or disagree, feel free to comment.

Jeff C Sep 11, 2008 @ 5:33 PM

# re: Alfred VS Clint: C# versus VB debate
I'm with you on this one. One thing your programming language should NOT be is verbose. I suppose if you rely heavily on auto-completion (which in my opinion makes for sloppier code by fostering weaker programming skills) then I suppose a really verbose language is just fine for you. You don't have to actually type all the extra garbage, you just depend on a robust editor application to do it for you.
...And then when the time comes that you're forced to make a quick emergency fix with, let's say Vi, you're slow and encumbered trying to make sure you spell out End If and double-check that your extra whitespace isn't breaking things.

There's a very good reason why C and C-style languages are the dominant, and dare I say de-facto syntax standard. It's efficient, it's methods and style are easily understood across any other C-style langauge, and it fosters a uniform understanding of how to read, adapt to and quickly modify languages based on it. Once you learn one of these, you've learned 80% of them all. This isn't the case with VB.

And to hit Alfred's point from his rebuttal blog post... the Obfuscated C Contest is hardly a good argument for why C-style coding is inferior to VB. There are obfuscated VB contests as well. None of these contests are intended to illustrate the language's complexity, but to showcase methods for obfuscating source code to protect it from thievery and exploits, along with just having some fun. In fact, MSDN has an article about doing precicely that with C#, VB and .NET: http://msdn.microsoft.com/en-us/magazine/cc164058.aspx

One's favorite programming language is obviously subjective, and is usually the result of which syntax the programmer learned first. If you're used to VB then sure, C-style languages will feel odd. That doesn't make them inferior by any means.

Jeff C Sep 11, 2008 @ 5:36 PM

# re: Alfred VS Clint: C# versus VB debate
Oh, and one more thing to add:

Semi-colons are not always required in C-style languages (I believe they are in C# though?), and the curly brace is enough to designate an end of line. This also means statements like:

if (condition) {
do stuff
}

can be truncated to:
if (condition) { dostuff }

Try that with VB.

sam stokes Sep 11, 2008 @ 6:21 PM

# re: Alfred VS Clint: C# versus VB debate
I am switching to Popfly drag and drop. :) Just kidding. The BASIC syntax is older than the C structures. Language battles and comparisons are interesting, I like this one. However, lets take a look at issues with C versus Visual Basic: C languages are more difficult to read by the more casual person doing programming. That's it. If I just want to jam out a program, VB use to me my choice. Now I am leaning toward F#, but don't get me wrong, C has it's places.

Clint Rutkas Sep 11, 2008 @ 7:05 PM

# re: Alfred VS Clint: C# versus VB debate
Drag and drop is too restrictive. Functional languages are too academic for my tastes. They have great application uses but for every day code slinging, ...

int19h Sep 15, 2008 @ 7:22 AM

# re: Alfred VS Clint: C# versus VB debate
If you seriously think that C/C++ syntax is the pinnacle of readability, it only shows that you haven't seen much else (or maybe that acquired habits are hard to get rid of). Give me something Ada-like any day! (but note that, while VB is slightly closer to that, it also has its own share of quirks)

Clint Rutkas Sep 15, 2008 @ 8:21 PM

# re: Alfred VS Clint: C# versus VB debate
One reason why I think it is very readable is so many languages have that syntax!

I have very minimal Ada knowledge, pretty much what I saw on http://en.wikipedia.org/wiki/Ada_(programming_language) and a few quick searches. Do I think this is really readable: http://sandbox.mc.edu/~bennet/ada/examples/calc_adb.html ... Very VB and Pascal like.

NewToC++ Sep 25, 2008 @ 6:58 PM

# re: Alfred VS Clint: C# versus VB debate

Essentially, a French person would make the same argument why French is better than English.

There wasn't a concrete piece of evidence in the entire post.

Clint Rutkas Sep 25, 2008 @ 7:41 PM

# re: Alfred VS Clint: C# versus VB debate
@NewToC++: It is all preference to language. I like C#, you like VB. There are tons of pro's and con's to each language. You can't provide concrete evidence on why a language is better than another since it is a preference. I may hate a feature you love.

Clint Rutkas Sep 30, 2008 @ 4:09 PM

# re: Alfred VS Clint: C# versus VB debate
@NewToC++ IMO, C# requires you to type less. Yes vb has auto complete but that can only get you so far.

I will say I do love the optional statement for VB params though.

Christopher Lewis Oct 8, 2008 @ 10:52 AM

# re: Alfred VS Clint: C# versus VB debate
Jeff C -

VB has always supported single line IF statments

If True Then MessageBox.Show("Here") Else MessageBox.Show("There")

Multiple line IFs are only reqired for if you have multiple statements.

BTW - I'm language agnostic - I write both, and enjoy both. I don't feel VB is better or worse then C#.

Clint Rutkas Oct 8, 2008 @ 10:58 AM

# re: Alfred VS Clint: C# versus VB debate
So many things I've learned about Visual Basic from deciding it was a good idea to hit a bee hive of a topic!

Thanks Chris, I had no clue that VB could do that syntaxitically. The one thing I do like is the optional keyword in parameters. That reduces by so much how many overloads you need to do!

Post a Comment

Please add 6 and 3 and type the answer here: