Martin Hinshelwood's Blog

A Scottish dyslexic software developer: .NET architect, developer, evangelist, technology enthusiast and multi-dimensional free thinker


News

Disclaimer

The opinions expressed herein are my own personal opinions and do not represent my employer's view in any way.

Subscribe

Personal

Get Microsoft Silverlight

Accreditation

Stats

My Stats

  • Posts - 274
  • Comments - 313
  • Trackbacks - 67

Twitter












Tag Cloud


Recent Comments


Recent Posts


Article Categories


Archives


Post Categories


Image Galleries


Blogs I read


Blogs of Friends


Blogs on VSTS


Multi-Dimentional Free Thinking Bloggers


Personal


Projects



The reasons I think that VB.NET is better than C# are many, but I will try to put some of them down in a coherent manor unlike the usual C# developer that can only come up with "vb is a language for mediocre programmers...anyway looks ugly and smells ugly.." (Hmm, he must have thought long and hard to come up with that).

Reason 1 - Business sense

liviu is right that many mediocre programmers are VB programmers. This is because VB is easier to read and easier to code, thus there are actually many more VB.NET programmer than C# in the world, so ov course there are more mediocre ones, statistics demand that. But this is its advantage, you can have a superb developer produce your application, then have on of the mediocre programmers maintain it. This keeps costs down for the business, and frees up the superb programmers time to work on the next complex project.

Reason 2 - Visual sense

The readability of VB.NTE is what makes it more popular. Take these pieces of code for example:

or (thanks  for the timely translation)

NorthwindDataContext ctx = new NorthwindDataContext();


var query = from c in ctx.Customers
                  where c.Country == "UK"
                  select new { Name = c.ContactTitle + " " + c.ContactName };


foreach (var c in query.Skip(2).Take(3))
{
Console.WriteLine(c.Name);
}

Forget for a moment that the VB is nicely formatted, this looks pretty similar. There are the same number of lines. The same amount of text. But I find the VB version easier to read as it is more logical, it flows better and you can read it much more effectively.

But this is just personal preference.

Reason 3 - Disability friendly

VB.NET unlike C# is not case sensitive. I have always wondered why in this day and age that C# is still case sensitive. It seams to me that this is a historical thing, but it just avoids confusion and makes you code more readable if "variable" and "Variable" and "vaRiable" are the same thing and not different.

If you are  then this is very confusing as although "r" and "R" are difficult to confuse, "v" and "V" is the same letter, only slightly bigger. This means that you code is more accessible and disability friendly if you do not have case sensitivity.

Reason 4 - Intellisense

Oh how I love intellisense, the joy to have all of your code write itself. In effect this makes the argument of C# being more concise mute, as your code almost writes itself.

Reason 5 - Dynamic checking

Using VB.NET I do not need to wait till compile time to see if I have any typos or errors in my code and the "write-time" compiler for VB.NET checks my code as I type. As a dyslexic who can write the same work six times in the same object differently and not be able to see the difference you can imagine how helpfully this is.

Would you like Word to only check your spelling when you try to save, and refuse to save until you had fixed it? I think not...

Reason 6  - Personal

I don't know if it is a symptom of my dyslexia, but curly brackets ({ and }) give me the heebie jeebies and I find I am unable to see where one method, or loop ends and the others begin. If it is part of my dyslexia then that is an even better proponent of VB.NET over C# and should be added to reason 3.

Conclusion

Although the use of VB.NET over C# is a personal preference it also has many advantages. The more noted of which is Readability, disability friendly and 'write-time' code checking. With all this it is actually faster to write in VB than C#.

Lets all try to make our code more accessible and use VB.NET.

 

P.S. I don't know what I am doing wrong, I can't seems to 'smell' any of my code, neither VB.NET or C#. Hmm...

 


posted @ Monday, August 06, 2007 11:59 AM | Filed Under [ Microsoft .NET Framework Dyslexia ]

Comments

Gravatar # re: Why I think VB.NET is a better choice than C#
Posted by Justin on 8/6/2007 1:28 PM
Reason 3 - Disability friendly

I fail to see how case sensitivity is a bad thing. It forces correct code. I would hate to have to maintain a program you wrote if everything you wrote the variable name it hade different case. That my friend is confusing!

VB is more readable...for who? The experienced C++/practically every other language programmer or the new programmer?
Gravatar # re: Why I think VB.NET is a better choice than C#
Posted by Mark K on 8/6/2007 1:55 PM
I think VB encourages mediocre programmers, who write very procedural programming.
In itself, VB has evolved from the original BASIC language, and rarely demonstrates complexes business logic.

When people program in VB, they think in logical steps, and code in logical steps. Before you know it, you have a very complex form, full of business and data logic.

I know thats not always the case. But name some top developers that demonstrate TDD in VB? Jeremy Miller? No. Ayende Rein? No. Jean Paul Boodhoo? No
They all have a very object orientated approach, and they use C# to demonstrate this on their blogs.

Another example: go to a book store and look at VB books. They're nearly all to do with "binding a datasource to a grid", or "adding an icon to a combobox"

Now look at the C# books. There's a much more object orientated approach. They talk more about design patterns, and implmentation.

Why does C# seem more OO than VB? I dont know. Maybe its just an attitude or cultural difference.

(ps: working with objects doesnt mean your code is object orientated)



Gravatar # re: Why I think VB.NET is a better choice than C#
Posted by Martin Hinshelwood on 8/6/2007 2:10 PM
Hi aspnet_guy,

I can see where you are coming from, and I did not literally mean that I used a different case with every variable name.
In fact if, for example only, you use “objTeamFoundationServer” as the definition variable VB will convert every case you enter to the same case as the original definition.

What I meant was that if you created a variable called “objValueOfThing” I would find it difficult to transpose that between “objvalueOfThing” or “objValueofThing” and “objvalueofThing” as they all have the same letters of the same shape. If you read my post on “What is Dyslexia?” you will get a better idea of what I am getting at and why it is easier for a dyslexic person (min 15% of the population) if the programming language does not use case sensitivity. The thing that I regularly find in C# code is the internal variable called something like “valueOfThing” and the public property called “ValueOfThing” and this is what is where the difficulty is as they are different things in C#, where as VB would not allow this!

Martin

Gravatar # re: Why I think VB.NET is a better choice than C#
Posted by Martin Hinshelwood on 8/6/2007 2:19 PM
Hi Mark K,

All these thing you have mentioned are partly the virtue of there being far more VB developers than C# and partly because may VB programmers came from the old procedural days of "vbScript" and "VB6", and this only makes VB more accessible to a greater number of developers.
Yes, many VB developers are 'crap' at programming on OO, and a higher percentage of C# developer know OO and can implement it.
You will obviously find more 'trash' developer book, but that is because the 'trash' developers want them, so it is market driven. Many of the really good books on development are written in C# and VB...

Although mostly I have to buy the C# books and translate them in my head!

Martin

Gravatar # Why I think both VB.NET and C# have merit
Posted by Lorin Thwaits on 8/6/2007 3:03 PM
Glad you're excited about VB.NET. It's great that MSIL can cater to so many different dialects.

Please realize that there are many experienced folks out there that started with Java or C and find its syntax quite easy to read. Most of the folks who are big into object-oriented programming gravitate to C#, even though VB.NET offers very similar options for writing OO code. Without case sensitivity you have to get a little more creative in VB.NET when writing properties that expose private members, but it can be done. Although VB.NET optional parameters do smell, method overloading is supported, so you can still do the right thing from an OO perspective.

Something else to consider is performance. While VB.NET can be made to perform on-par with C# (within 5% anyway), by default the extra overflow checking and all the automatic type casting can really hamper performance. So a VB.NET application requiring better performance may take a little longer to tweak than a C# application.

A final thing I'd like to bring up is that all of the managed portion of the .NET Framework was written in C#, as is nearly all new managed code coming from Redmond. Not all of it, but most of it.

So I am not trying to sway your choice in language, but I would ask that you not turn your back entirely on C#, especially since you have an interest in software architecture. There's lots of quality C# code out there that can play very nicely with your VB.NET code.

Gravatar # re: Why I think VB.NET is a better choice than C#
Posted by Martin Hinshelwood on 8/6/2007 3:14 PM
Hi Lorin,

:) Fantastic, and constructive: Not only that, but I agree, which does not happen often!

Although I have been told that the performance difference between C# and VB.NET disappeared with .NET 2.0! Not sure of my facts though :)

Martin

Gravatar # re: Why I think VB.NET is a better choice than C#
Posted by Liviu on 8/6/2007 3:27 PM
I apologiaze for being so rude...but

Hi the example could be more VB-ish in c#:
[i]
var ctx = new NorthwindDataContext();
var query = from c in ctx.Customers
where c.Country == "UK"
select new { Name = c.ContactTitle + " " + c.ContactName };


foreach (var c in query.Skip(2).Take(3))
Console.WriteLine(c.Name);
[/i]
No need to write { if you do not need one. No need to define explicitly local variables in C# 3.0 ;)

1) I hate to must to put underscore just to be able to go on next line. I think also that it is a matter of taste, some feel confortabler without { other not.

2) visual sense, a matter of taste

3) Disability. Yes i understand your point. Case sensitivity is a curse for you, but could be a helper for me.
I can define x as private field and X as public prop and keep it simple, but outside coding guidlines from microsoft. but how i hate _x!

4) could you give me an example of better intellisense in vb?
5) dynamic checking.. hm, i have resharper and helps me better



Gravatar # re: Why I think VB.NET is a better choice than C#
Posted by Martin Hinshelwood on 8/6/2007 3:52 PM
First, can i draw everyones attention to the title of the post "Why I think...", just my opinion.

Liviu,

Thanks for being so constructive this time around :)

1) I completely agree

2) Defiantly a mater of taste

3) Although it is better for you, does that mean that you would put steps in front of your shop, or make all cash machines a minimum of four feet of the ground, or refuse to make left handed scissors. Just for thought...

4) I guess, just that it is not case sensitive either, which I always forget to do in C#

5) no argument, but needs an extra app: is it free?

Martin
Gravatar # re: Why I think VB.NET is a better choice than C#
Posted by thorkia on 8/6/2007 5:23 PM
I used to use VB.NET, but moved to C# for 4 reasons only.

1. I actually find C# code easier to read. Why? Becuase of the [] brackets used for arrays in C#. VB.NET uses () for both arrays and functions. That makes it difficult at a wuick glance to tell if you are looking at an array or function call. For example is this a function or an array I'm accessing:
Dim x as int;
x = SomeMath(2)
x = Number(2) 'Which is the function, and which is the array?
If it was in C#, I would know:
int x;
x = SomeMath(2); //Obviously a function
x = Number[2]; //Obviously an array

2. I can seem to find more examples on the net of C# code than VB.NET. Maybe I'm just looking the wrong places. But I got tired of converting them, and just swtiched my language of preference.

3. The whole sub and function thing. Subs are are functions that don't return variables, and functions do... Why is there a difference? Even when I did VB6 programming it drove me nuts.

4. The last one isn't really that big, and some would not a problem, but it could be. Zero based and non-zero based arrays. You can use both in VB.NET So this acutally declares and array of size 6, when I only asked for 5:
Dim Numbers(5) as int
Maybe this has chnaged since VS 2003 and .Net 1.1 (That was when I switched).

Now, one thing I do miss from VB.NET is the nifty ability to automatically create my properties get/set methods. Why do I have to buy resharper for this in C# when VB.NET already has it?
Gravatar # re: Why I think VB.NET is a better choice than C#
Posted by Alan Clark on 8/8/2007 8:47 PM
Case sensitivity in a programming language makes no sense to me. I can't imagine why a programmer would name two variables the same, in the case of private fields for a property they should be prefixed with an underscore to make them clearly different.

C# permits the definition of identical variable names, differing only in case which can lead to accidentally using the wrong one. Why? What is the advantage of case-sensitivity? IMHO, this was done just because C++ programmers were used to it and expected it, regardless of the merits of it.
Gravatar # re: Why I think VB.NET is a better choice than C#
Posted by Kenny on 8/13/2007 10:00 PM
Just my 2 cents:
.NET comes purely down to personal preference.
As far as performance, if you choose to program in .NET "Option Strict" is a must! One thing does really bother me in VB.NET. When working with arrays or strings some commands assume/return 0 based and some 1. It’s a shame when people choose to rate others intelligence on the language of choice. I am a self taught programmer and have been programming for almost 14 years. Someone who understands programming well can pick up a new language and move along pretty quickly. I have to say it’s getting harder to find good programmers period. I see a lot of VB.NET bashing on the net from the C# community. If you want real performance why would you move to .NET? The CLR is not the fastest thing in the world by far! I’m not trying to take sides but it seems there are quite a few “developers” taking the side of C# purely due to is boasting as a superior language. I currently develop in VB.NET and have been programming for over 14 years all the way back to Assembler in DOS. It’s crazy to put one .NET language above the other. I guess I would be above them all for using IL Assembler?? Not really.

Gravatar # re: Why I think VB.NET is a better choice than C#
Posted by AB on 8/14/2007 4:11 PM
Visual basic is a much more laborious language, even with intellisense.

IF "Fred" = sName THEN
return True
ELSE
sName = "Not Fred"
ENDIF

if ("Fred" == sName)
return true;
else
sName = "Not Fred";

There's no need for curly braces, or closing statements that are more prone to syntax errors (line EndIf, End Sub, End Function etc)

a Curly brace for a function declaration is cleaner and quicker to type

private int getAccount(){
return iAccount;
}

takes less effort and arguably more readable than

Private Function getAccount() As Integer
return iAccount
End Function

Writing out VB code takes more time than C#, even with variable declarations. Overall, this can add up to a significant amount of time.

Loops are very common routines in applications. Loop variables are often disposable and unused when the loop has completed. In VB, to use a loop variable, you must first declare the variable (assuming option explicit) then use it in a loop.

Dim I as Integer
For I = 1 to 100 Step 2
something = something + I
Next I

in C#: -
for (int i=1; i < 101; i += 2)
something += i;

A lot less useless things to type in C#. No declaration of the variable, like you are explaining it to a child "DIM" ... "As Integer"
Declaring the variable in line
More control in the loop (the increment can be an algorithm instead of just a step)

Even the increment of something is less long winded, using += instead of something = something + i

Also, C# supports compiler preprocessors like #define, which are great for debugging and writing cross platform applications.

There are nice shortcuts too. Most notably, the if/else/endif block.

Where VB.net has: -

If sName = "Fred" Then
sColor = "Blue"
Else
sColor = "Green"
End IF

C# can use: -

sColor = ("Fred" == sName)?"Blue":"Green";


I especially like the differentiation C# makes between assignment operators and comparison operators.

It is easy to make the mistake of using the assignment operator instead of the comparison, setting a variables contents instead of comparing them, but it can be difficult to see in the code, because in VB: -

Assignment: A = B
Comparison: A = B


in C#: -

Assignment: A = B
Comparison: A == B

So :-

If A = B Then
' Something
End If

C#

if (A == B) // something ;

But C# can also make us of this to reduce coding yet further

VB
B = B + 1
A = B
If B = 10 Then
'Something
End If

C#
if (A = ++B == 10) // Something ;

So C# reduces the long winded coding that VB demands. It's less readable to the novice, but to an experienced developer, it's clear and more importantly, takes 1 or 2 lines of code instead of 5. That makes a function more readable because it doesn't take up 10 pages of scrolling

The semi-colon line terminator is great too, to also compress the lines of code to make it more readable without scrolling, or lets you break up 1 line without having to insert an underscore


a++;if (a<10) return true; doFunction(); showMessage(A);
b++;if (b<10) return true; doBFunction(); showMessage(B);

More readable than

A = A + 1
If A < 10 Then return true End If
doFunction()
ShowMessage(A)
B = B + 1
If B < 10 Then return true End If
doFunction()
ShowMessage(B)

VB is simply an inefficient language with too much unnecessary typing and no more readable than C#, but with less functionality.

Gravatar # re: Why I think VB.NET is a better choice than C#
Posted by Martin Hinshelwood on 8/15/2007 9:52 AM
I think from your examples you have demonstrated that VB is infact more readable!

This:

If sName = "Fred" Then
sColor = "Blue"
Else
sColor = "Green"
End IF

is way more readable than:

sColor = ("Fred" == sName)?"Blue":"Green";

So what if you have to type a little more, software development is not a race, andit compiles down to the same thing anyway! Yes, C# is more consise but that is not the same a readable or mangable.

If you are using notepad I can see that C# would be less prone to erros, but if you are using VS then you can see the errors as you are typing and it fills out half of your code anyway!

If you type:

If x=1

and hit space you automaticly get:

If x=1 Then

End If

So you should never have to type End If or End Sub or End Function anyway!

Gravatar # re: Why I think VB.NET is a better choice than C#
Posted by Christian on 8/16/2007 5:12 PM
Most of your arguments are wrong, AB.

Argument 1, VB is laborious:
To enter the code you wrote in VB 2005 Express I simply type
if "Fred"=sname<enter>return t<enter>else<enter>sname="Not Fred"
if ("Fred" == sName)<enter>return true;<enter>else<enter>sName = "Not Fred";

VB is 12 chars shorter, possibly less if C# supports more auto formating than I remember

AND

The only time I have to press two keys at once is to enter the strings, a total of 7 (+ 2 for =) times
The C# version also requires this for the () and the sName identifier, a total of 11 (+ 5 for = and ;)
Values in () are for a scandinavian keyboard

AND

if you want more lines per block you need to add the curly braces, wich will take 2 more double

keypress total (using ugly AltGr combination on my scandinavian keyboard)

private function getAccount as inte<enter>return iaccount
private int getAccount() {<enter>return iAccount;

VB is indeed 8 chars longer, howewer it takes only 1 use of Shift key, versus 4 (+ 3 + AltGr!!!) for C#. To me this makes VB faster to type, as I don't have to clutter my tuch typing with shft combinations.


Argument 2, Loop variables can't be declared only in loop context
How do you explain this VB code then?

For I As Integer = 1 To 100 Step 2
something += I
Next I


Argument 3, More control in the loop
If you need the increment to be a complicated algorithm you should have stayed away from the use of

for-loop for improved readability, as it is normal to assume it is simply counting.


Argument 4, Increment is less long winded in C#
see teh for loop above for an example


Argument 5, C# supports #define
VB supports #Const instead


Argument 6, C# has nice shortcuts
What about trying this?

sColor = Iif("Fred" = sName, "Blue", "Green")

Which by the way is not much readable in any language and should probably be avoided


Argument 7, differentiation between assignment and comparision operator
I'd like to see this differentiation in VB myself, but it is not there and it still works fine.

Anyway if (A = ++B == 10) does not look very readable to me. Too much is happening at once here, both increment, assignment and comparision at the same time.

But I'd like to see the possibility of assigning one value to multiple variables, for instance

like

A, B = B + 1


Argument 8, semi-colon is great
No it's horrible. I have to press Shift + , to type it on my keyboard!!!
Your code just don't look readable at all, to much happen in too few lines. But if you want to you

could always do that in VB too:

a += 1 : If a < 10 Then : Return True : End If : doFunction() : showMessage(CapitalA)
b += 1 : If b < 10 Then : Return True : End If : doFunction() : showMessage(CapitalB)

I assume you know that a is not A in C#, so i fixed that in the code by translating A to CapitalA and B to CapitalB. Or maybe you use identifiers differentiated by case? You want get build errors for that you know, just some hours of debugging until you finally find the mistake.


I see that there are a lot of experienced C/C++ programmers who find it easier to migrate to C#, because of the closer similarities in syntax. But VB also have reputation for not being OO (my C/C++ teacher said that VB.NET was not OO at all at my first lesson, I hated him ever since...). In my head VB.NET is far superior to C#, but still could use some improvements.
Gravatar # re: Why I think VB.NET is a better choice than C#
Posted by Martin Hinshelwood on 8/17/2007 3:19 PM
Christian, thanks for the support on this. I was getting swamped by C# fanboys…
Gravatar # re: Why I think VB.NET is a better choice than C#
Posted by David Silverlight on 8/19/2007 8:29 PM
I could not agree more with your points. I have lost count of the number of discussions that I have had with colleagues over the vb vs C# topic. I came from a VB, then ASP background so I am naturally more comfortable with VB.NET than I am C#. I also like it for all of the reasons that you outlined in this post.

One downside of VB that I would like to point out is irrelevant of the language itself, but instead has to do with all of the examples out there. For some reason that I have never figured out, it seems that about 80% of all examples out there are written in C#. So, this makes it a bit painful to implement code snippets that you find in your VB apps. Seems like a C# conpiracy to me :)


Gravatar # re: Why I think VB.NET is a better choice than C#
Posted by christopher stapleton on 9/10/2007 1:55 AM
why are you guys fighting c# vs vb.net ? although Microsoft says both languages are first class equivalent languages, I think Microsoft made it clear that c# is superior to vb.net, when they used it to build the .net framework.

it is like those CEO's of big corporations, who in their annual message to the shareholders, say everything is fine with the company and then who sneaked out behind the scenes to sell and get rid of all the shares they hold.

watch what they do instead of listening to what they say... this is the best test.

I have moved from vb6 to c# and now I am moving to java. this is to punish microsoft for causing all this mess. they did the same thing with vb script and jscript in the past.

the reason is very simple .net is 50% of the market, JEE is another 50% of the market. however by learning one language name java, I can cover 50% of the job market.

whereas if I pick either vb.net or c#, I can cover only 25% of the job market. the only way you can cover 50% of the .net market, is by learning 2 languages !!! is it worth the money? I don't think so. I just hope a lot of the microsoft developers like I used to be, moves to java to punish Microsoft for their divisive policies that impact our ability to put bread on our table.


Gravatar # re: Why I think VB.NET is a better choice than C#
Posted by Dan Bambling on 4/19/2008 10:11 AM
I started out programming in vb.net. I love the language. I currently manage both c# and vb.net applications and on a basic level they are very much the same.

VB is a great language to get going with however, I do like c# and its close syntax with javascript.

Writing websites these days, one must know AJAX and SQL as well as a programming language and the chosen framework. It is quite a feat to remember all that code. If you have developed business critical web or win applications you should be very proud of yourself.

I guess the bottom line is this; In order to get the most out of your career and achive the best result in creating a solution you need to have a firm grip on the .Net framework. Your language choice needs to be one your happiest with but ultimately (as christopher stapleton said above) BOTH languages need to be understood. Knowing the framework means the syntax will follow, what ever language it is in.
Gravatar # re: Why I think VB.NET is a better choice than C#
Posted by aspfun on 7/21/2008 7:56 PM
If you check job market you will find more company need C# than VB. Why?
Gravatar # re: Why I think VB.NET is a better choice than C#
Posted by vbcoder on 8/12/2008 4:23 AM
Disagree with this article.
I use both vb.net & C# for my work. The syntax of vb.net is ugly & clumpsy. It is more difficult to read & code.
Post a comment





 

Please add 1 and 7 and type the answer here: