Why I think c# is better than VB – Part 2

So as expected, Alfred responded to my first post on why I think c# is better.  As always, I will point out I openly respect people’s opinion for programming languages and that each language has excellent uses for different things.

So with the disclaimer out of the way so I won’t have an angry mob attacking me, on to why I love c# so much.

Alfred brought up the need for the semi colon to terminate a line.  I think this the best idea ever.  We do it in our written, why is it such a big deal?  More so, I can do this:

updated after Erik yelled at me to provide a more legit example:

isUserPrepped = (angle < safeAngle && angle > -safeAngle)
    && (gyro < safeGyro && gyro > -safeGyro)
    && userIsOnBoard;

while VB has to do this:

isUserPrepped = (angle < safeAngle AndAlso angle > -safeAngle) _
    AndAlso (gyro < safeGyro AndAlso gyro > -safeGyro) _
    AndAlso userIsOnBoard

I can have 1 line of code expand out multiple physical lines.  VB I have to use a _ to say it is an extra line!  That is an extra thing I have to worry about when coding with meaningful variable names (sorry, X, Y, and Z only count if I’m doing something in 3D).

As Jeff pointed out in a comment also, C style languages allow me to do this

functionFoo(); functionBar(value); stringBuilder.Append("Clint Rutkas is awesome");

while in VB it would be this:

functionFoo()
functionBar(value)
stringBuilder.Append("Clint Rutkas is awesome")

This is a poor example due to the functions, but there are multiple times where you’ll want everything on one line.

Another great feature of c# is how close it is to other languages.  If you run across something in Java, C, C++, Perl, PHP or JavaScript, there is an excellent chance you can reverse engineer what they did with very little effort.  With VB, unless it is c# where you’ll be able to use a transcoder, you have to manually go and do a line by line correction.  This could directly lead to introducing an error in the code!

Erik Porter Sep 12, 2008 @ 6:31 PM

# re: Why I think c# is better than VB – Part 2
Just curious...do you really write day to day code like that? Yuck! If it's one statement and doesn't take up much space, leave it on one line! :P I bring it up because using _ isn't that big of a deal if you don't actually do multi-line statements very often. I think VB went with the 95% route. 95% of the time code is one line so really you end up typing more in C# than you do in VB (for line endings and line continuations).

P.S. I used to be a VB MVP before joining Microsoft where I now write C# all day every day and enjoy both languages.

Bengan Sep 15, 2008 @ 5:41 AM

# re: Why I think c# is better than VB – Part 2
Multiple statements on a single row are indeed possible in VB (though they are arguably less readable than their C-style equivalents):

functionFoo() : functionBar(value) : stringBuilder.Append("Clint Rutkas is awesome")

Clint Rutkas Sep 15, 2008 @ 8:10 PM

# re: Why I think c# is better than VB – Part 2
@Bengan: Someone pointed that out to me. I didn't know about that until a few days ago, however my issue with this is c# keeps the termination the same. VB doesn't BUT I think it is great it has that ability!

Matt Sep 16, 2008 @ 4:08 PM

# re: Why I think c# is better than VB – Part 2
OK, so you like C# better then VB, fair enough. But why C# over Visual C++? Both are in Visual Suite, no? Is there some major distinction?

Clint Rutkas Sep 18, 2008 @ 2:07 PM

# re: Why I think c# is better than VB – Part 2
@Matt: C++ and C# have a lot of things in common but at the same time, a lot of things are different. A lot of the complexity in c++ has been simplified and streamlined.

http://blogs.msdn.com/coding4fun/archive/2008/08/07/8835237.aspx has a quick snap shot of some c#.

Matthew Oct 3, 2008 @ 1:21 PM

# re: Why I think c# is better than VB – Part 2
I'm totally with you on the first example, however the second... bleh. For more VB.NET insanity, check out Justin Etheredge's post at: http://www.codethinked.com/post/2008/03/VBnet2c-oh-how-I-hate-thee2c-let-me-count-the-ways.aspx BTW, it's good to see you doing so well, Clint. Congrats on your successes.

Post a Comment

Please add 5 and 2 and type the answer here: