Is VB.Net better or C#.net? Or is .Net a .Net either way?

As a .net programmer at some point in your life, you probably have gotten into a discussion or at least faced a choice between VB.net and C#.net. Though the argument is never ending on both sides, how do programmer that are bilingual or someone who is just learning feel? What long term productivity impact does this have in development shop or team in general?

Well for me, I clearly have choice in mind, but instead of presenting my views today, I will publish the following list our good friend Jeff Lanning compiled from various sources few years back. Though some of the points have changed with new version of .Net, I hope it provides a good reference for anyone dealing with such a choice. Here it goes; don't forget to put in your two cents:

Reasons to Choose C# over VB.NET:

C# was designed expressly for the .NET platform and Microsoft is standardizing their company on it, which means they have a much deeper investment in C# technologies (language features, compilers, dev tools, etc) than they do in VB.NET. In fact, both Visual Studio and the .NET Framework where written in C# (using C++ as a backend). Furthermore, C# was submitted to, and standardized by, the ECMA group as an open standard while VB remains proprietary.

The C# language is very similar to the other major languages (like Java, JavaScript, C/C++, PHP, and Perl) and shares many of the same concepts, keywords, and syntactical elements. These similarities means a C# programmer will be more able to read, write, and borrow code from those other languages. Most programming books not specific to any one programming language (e.g., books on UML, data structures, OOP concepts, etc.) are likely to include examples in Java.

Outside of the endless language features debate, C# has become the defacto standard for .NET development. A majority of third-party and open source components are written in C#. A majority of advanced programming articles are written in C#. Microsoft's application blocks and other development resources are also provided first in C#, and later converted to VB.NET. If anything, .NET developers owe it to themselves to learn C# for that reason alone (even if they think VB is still the greatest thing since the Apple IIe). As long as they never have to modify or inspect anyone else's .NET code, it may be fine to ignore C# for the time being, but chances are that isn't going to be the case for very long if they want to take advantage of the rapidly growing .NET community's resources.

Most students coming out of college have experience with Java and/or C++, making the transaction to C# quite natural. In addition, these young professionals will likely see VB.NET in the same light as COBOL with its legacy-ridden, verbose BASIC syntax, and be drawn to C# as the best long-term choice for professional grown.

The learning curve going from VB6 to either VB.NET or C# is about the same given that 95% of the effort will be spent learning the object model of the .NET Framework, the new development tools, new OOP concepts, and all the new techniques involved in developing Windows or Web applications in .NET. While VB.NET might seem to be just an improved version of VB6, they are really two languages that are eerily similar, but perversely different. In fact, many experienced VB developers may find C# easier to learn (although a bit more uncomfortable at first) because it helps draw a clean distinction between the two development platforms and avoids many pitfalls associated with bringing a VB6 mindset into the .NET world (like using "On Error GoTo"). There is much to be said for starting with a clean slate.

VB.NET does not have native support for XML embedded documentation, which is used by IntelliSense and to auto-generate class reference documentation directly from the code (with tools like NDoc, DocGen, and many others). The absence of this feature alone is a strong reason to avoid VB.NET on large development projects. This limitation will be fixed in the VS2005 release.

Over the next few years, Microsoft will be differentiating the VB.NET and C# product lines. VB.NET will diverge to provide a better RAD (Rapid Application Development) experience, while C# will diverge to provide a better experience building complicated business frameworks, backend services, application architecture, and reusable object-oriented components. For smaller projects, either language will be a fine choice, but as the size and complexity of applications increase, the productivity gain from C# will likely outweigh that of VB.NET.

Language-specific reasons C# is a better choice…

- less verbosity (e.g., easier to find the "important" words in the code)

- assignment operator is not the same as the comparison operator

- Native XML code documentation (which drives IntelliSense notes)

- does not hide "Advanced Members" of classes

- simplified type casting syntax (instead of directcast(), ctype(), cbool(), etc...)

- case-sensitivity (allowing for better variable names in many cases)

- 'OnError GoTo' is impossible

- option explicit by default (enforces correct type usage)

- cleaner null test expressions ("obj != null" rather than "not obj is nothing")

- better variable scope containment in loops and code blocks

- automatic logic short circuiting (streamlining common test/use logic)

- 'using' blocks for clean/safe resource management

- continue / break statements supported in loops

- embed special string characters ('\n', '\r', '\t', etc…)

- string escaping ('@')

- comment support is just better (multiline comments, XML comments, single-line comments, etc…)

- as operator (string s = obj as string)

- native increment/decrement supported ('--' and '++' )

- intellisense is much less interfering

- arrays are defined with number of elements, not the upper bounded index

- hierarchical constructor calling (ctor() : ctor("defaultValue"))

- array/collection indexer is not the same as a function call ('[0]' vs '(0)')

- 'ByVal' is very misleading (it passes a pointer (ie reference), not a value; whereas 'ByRef' passes a pointer to a pointer)

- unsigned values (uint, ulong)

- P/Invoke makes much more sense, and is uberly easier to figure out

- doesn't hide delegate usage (AddressOf)

- more optimized MSIL generation

- operator overloading

- pointers

- event syntax

- delegate syntax

- unmanaged/unsafe code supported

- 'Default Namespace' doesn't just prefix your classes namespace

- EntryPoint isn't hidden ([STATThread] static void Main(string[] args))

 

From a discussion thread:

Actually I'm little concerned about VB's future with the graduating generation of programmers. Most of today's universities are teaching Java as a primary learning tool. And usually the academics view VB as a clumsy language for lazy programmers. Decades ago the most supreme business language was COBOL. Those who had a chance working with it know it is an outstanding language that is dead meat, not because it is not used anymore (70% of World's applications remain bounded by it) but because the new generations learned from their teachers that computer science is science, COBOL is for business and C is for math (math is science). Some may argue that there is COBOL.Net, however, seniors can't stand OO way of thinking, juniors can't stand OLD language stigma so it is also dead before it is born. Having C language culture and nowadays Java transferred from teachers to students, what do you think IT managers will prefer for their departments growing potentials if they choose to acquire .NET?

 

If I was a manager I would surely choose C# for several reasons:

1) So I can get the brightest of new (low paid) grads up and running in no time.

2) So I can get to that C++ like language fame surrounding my projects and yet get it RAD.

3) So I can leave infamous VB lazy clumsy programmers gossips roam as they wish without feeling their sting.

 

But I am a developer so I choose C# for:

1- No job is secure, so I'd better get used to curly brackets and once I learn most of XML, web services, SOAP, etc., then I am empowered to switch easily to that other half of corporate world that is using J2EE.

2- It's more stylish and attractive (yes it does matter if you are going to spend most of your day on something then better love it).

3- Because VB's parents Bill and Mic seem to undermarket it in favor of C# (could it be they are trying to abandon the ship?).

 

From a discussion thread:

We chose VB.NET a year ago and we regret it. We have 25 very bright developers and a substantial ecommerce web site with plenty of traffic. One year ago we kicked off our port to .NET and we chose VB6 because our existing code base was VB6 and ASP. A few of us here had significant C# expertise from previous jobs and warned the bosses that the "advantages" of VB.NET were a mirage and that there were some clear disadvantages. They actually thought the "automatic conversion" tools were going to buy us some time. The pointy-haired contingent won out and not a day goes by that we don't curse them for forcing VB.NET on us.

As other's have said, you take a big hit moving to .NET at all. The tiny additional hit of moving talented VB6 developers to C# is more than offset (IMHO) by the increased developer productivity achieved over the medium to long term in C#. (If your team is not very talented -- or not talented in that way -- YMMV.)

Why do I think I am more productive in C# than in VB.NET? Here are a few reasons:

1. VB.NET has abysmal static code analysis: functions that don't return values, uninitialized variables, unused variable declarations, etc... This is what a compiler is *for*. I wish VB.NET had an "Option ReallyStrict On" so it would check things as thoroughly as the C# compiler does. You can spend hours trying to track down which uninitialized variable or non-returning pathway in a function is the source of a bug, when the compiler could just tell you.

2. VB.NET has more aggressive background compilation that you can't turn off or control in any way and which is buggy! We have solutions for our web site with 30 projects and some projects with hundreds of files. You can't add a method to a class without taking a coffee break while intellisense chews up a CPU. We're reduced to having to buy double cpu machines for developers so that they can just type at full speed. And even then all that CPU is wasted because the background compilation just can't keep up. I wish there were an option for intellisense so that you could *tell* VB.NET when to recompile and when to just chill out because I'm typing a raft of code.

3. VB.NET (still) has lurking intellisense bugs whether you use project dependencies or file dependencies. Whichever you choose, you're stuck with a different set of problems ("can't copy dll X [v1.1.3000.1] over dll X [v1.1.3000.2]" or "dll A requires a reference to dll B" or "can't copy dll Y to c:\foo\bar\y.dll because it is locked")

4. VB.NET has no "using" directive. I know it's just syntactic sugar... but I want more sugar. The truth is that interacting with non-managed resources (ie. the OS or the database) in .NET sucks even in C#. But having to write "Dim x ... Try ... Finally .... x.dispose EndTry" all the time is just pouring salt in the wound.

5. VB.NET has no multiline comment syntax

6. VB.NET has no within-the-line comment syntax

7. VB.NET has no multiline string syntax

8. VB.NET has a limit on line continuations (what is it, like 10 lines)?

9. VB.NET projects cannot have pre-build or post-build steps (large, real-world projects inevitably need them)

10. VB.NET has no built-in comment->documentation generator

 

And in case anyone is still reading... it's hard to think of any advantage we've seen in using VB.NET. Maybe one: it made some COM coding easier because we could use late binding. I'd say if you are doing lots of COM interop especially if you need late binding, VB.NET is necessary. But I don't recommend doing any more COM interop than you absolutely have to and late binding is worse than evil.

 

I think that pointy-haired types think that VB.NET will make it "faster". That the learning curve will be less steep or that fewer changes will need to be made to the code. It just doesn't work that way. Your project will take 2 or 3 times as long as you anticipated, even if you pick VB.NET. And when you choose VB.NET you may get started faster but you'll be paying a tax forever, because the language and tools just aren't as good as C#. I'm crossing my fingers for VB improvements in 2005, but I'm not holding my breath. Doubtless something else will be "missed" (like multi-language projects were this time) and we'll still be stuck in a VB.NET ghetto.

Print | posted on Thursday, February 07, 2008 10:45 PM

Feedback

# re: Is VB.Net better or C#.net? Or is .Net a .Net either way?

Left by Rodrigo at 2/8/2008 5:52 AM
Gravatar I couldn't agree with you more.. I worked with C# for the last three years and now I am forced to use vb.net ..man that sucks big time !!
And I am an ex vb6 developer..but C# is just more productive...thats it...

# re: Is VB.Net better or C#.net? Or is .Net a .Net either way?

Left by Jim Arthur at 2/8/2008 7:32 AM
Gravatar Seems like the answer to the question creates an answer rather than a discussion. Seems a shame to have such a one sided approach in an article that starts out suggesting this was to be a comparison, not a sales pitch. I suspect most self-made programmers over 25 started out in basic rather than a college language, so your Visual Basic support base is as large, if not larger, than your Java / C++ base and the crowd at the starting line is about equal.

# re: Is VB.Net better or C#.net? Or is .Net a .Net either way?

Left by Robert S. Robbins at 2/8/2008 8:09 AM
Gravatar In an ASP.NET project, you can use both C# and VB.NET in your App_Code directory. I'm contemplating throwing in some J# just to make life interesting for anyone who inherits my project.

# re: Is VB.Net better or C#.net? Or is .Net a .Net either way?

Left by Bigyan Rajbhandari at 2/8/2008 9:02 AM
Gravatar Jim, I couldn't agree with you more that VB has been around since long time. Well, when I first started programming 14-15 years ago, I started with Basic. But the case, I am trying to present deals with question of being productive after being bilingual? Though the tone seems little bias, I think it presents a good reference for anyone who is trying to pursuade a client, collegue or anyone else.

# re: Is VB.Net better or C#.net? Or is .Net a .Net either way?

Left by Wayne at 2/9/2008 1:18 AM
Gravatar I started with Basic and VB, ASP and finally VB.Net. Then I began to realize that all the beta documentation referred to C#. Well it just never ends. I made the switch from VB to C# during 1.1 days and it was pretty hard. During those times I was maintaining several apps that were written in vb.net.

heh, I had an app that I started writing a collection of web services in vb.net, but the client portion was all C# that I wrote while I translated and learned C#. Worked out well, but I hated having to explain to the receiving developer why it was half and half. It would have taken too much time to re-write the VB side.

# re: Is VB.Net better or C#.net? Or is .Net a .Net either way?

Left by Kevin at 3/12/2008 6:16 AM
Gravatar I also moved over to c# because of better documentation in 1.0 and 1.1 days. The problem is that I can't go back to VB. I think microsoft made the mistake of not marketing and promoting VB properly in the beginning.
VB is simply dead, throw it out and let's concentrate on C#, accept, adapt and move on.

# re: Is VB.Net better or C#.net? Or is .Net a .Net either way?

Left by Steve at 3/12/2008 6:52 AM
Gravatar This is a very one-sided article. I've been a developer for over 20 years. Started writing C on a PCs and mainframe computers. I then moved on to C++ on various Unix systems and later started writing VB (from version 1) on PCs again.
I moved on to .NET with everyone else and like everyone else just used the .NET language that what closest to the one I had been using - for me VB.NET . I have done a couple of client projects in C# but to be honest there ain't much difference between the two.
Each has it's quirks.
C++/C# code is visually much cleaner than VB/VB.NET making it easier to see the logic flow of larger chunks of code.
On the other hand I've found it easier to maintain VB code written by someone else. C# programmers tend tend to comment less and give less meaningful variable names.
The verbosity of VB always kills me when I switch back to it. The case-sensitivity of C# has me pulling my hair out.
If they added a case-insensitivity/'pick up the case of the variable' option to Visual Studio for writing C# then this would definity swing it for me.

The C# snobbery that some people have is just plain ignorance. It reminds me of arguments I used to have with people who 'think Vi is the best editor'/'say Oracle is a proper database unlike SQL Server'/'Apple Macs are better than PCs'/'Unix is better than Windows'. Having a false superiority complex does not make you right.



# re: Is VB.Net better or C#.net? Or is .Net a .Net either way?

Left by Mark Wisecarver at 3/19/2008 7:34 AM
Gravatar Please write a "part 2" where you stick to the advantages of VB 9.0 and C# 3.0, pretty please.

# re: Is VB.Net better or C#.net? Or is .Net a .Net either way?

Left by Yugiro Fuma at 4/6/2008 9:23 AM
Gravatar Good talk everyone!

Do anyone know what programming language is used to control a Satellite?

# re: Is VB.Net better or C#.net? Or is .Net a .Net either way?

Left by Thomas Worvo at 6/9/2008 6:57 AM
Gravatar Having 5 years of VB6 experience and 3 years of VB.NET, I found the C# transition difficult. Firstly, it was very intimidating. I think that's the core problem most vb'ers face when switching. Second, I wasn't very agile. Monolingual programmers get stuck in ruts very easy, and adjusting to the syntax change took a few weeks.
The transition made me a better programmer, though - I've since expanded my repertoire to include about 10 more languages. Most modern languages are curly-brace, so learning C# makes the transition to Javascript and Actionscript easier.

At this point in time, I'd rather walk in bare feet over a pile of rusty nails than have to touch VB.NET with a 10-foot pole. I can't believe how long I endured the verbose, and non-nonsensical syntax.

I feel very sorry for those who still haven't made the switch. My last co-worker finally switched a few months ago, and he's now a C# addict.

Switch now, not later. The less VB.NET code you write, the better - you'll despise maintaining it after you switch to C#.

# re: Is VB.Net better or C#.net? Or is .Net a .Net either way?

Left by jl at 6/17/2008 11:21 AM
Gravatar I am an MCT and, though I now serve in an I.T. Director level capacity for a healthcare company, I have faced this question in class settings. There a devSnob in EVERY room who has some argument (usually nearsighted or, worse, hearsay) as to why C# is better than VB. I offer the following analogy...

If I want to want to find out the specials at my favorite local Mexican restaurant, I would be best equipped if I asked in Spanish...

If I want to make sure my shirts DON'T get starch (Dang it!!!), It would really be helpful if I could speak Korean...

If I want to go driving on the Autobahn, it sure would be helpful if I could read German roadsigns...

thus...

Which language is best depends on what you want to accomplish; what your intent is. You could get by with either though each has strengths. It's true and no small thing that C# has a much larger community of dev's out there and it's the primary language used at MS. In my personal experience, VB tends to be easier for RAD situations and even has a few syntactical elements that are better than the C# equivalents (such as the simple "Handles" keyword for event wiring).

The bottom line, going back to the (off the cuff) analogy is that one may be BETTER than the other "here" and the other BETTER "there" but it's always BEST to be acquainted with BOTH! They both compile down to the very same MSIL code therefore they are going to execute at the same speed and have the same runtime resources to utilize (can you say "COMMON" language runtime (i.e. CLR)?

I personally find people who are C# zealots to be as simple minded, near-sighted, and obnoxious as the masses of MAC end users who feed on the the MAC guy/PC guy propaganda and then turn around and assert MAC's supremacy over PC publicly while privately knowing little more about the technology than how to open Safari and browse eBay listings. On the other hand, I offer my respect to those expert developers who know how to best leverage the benefits of the language, whether VB or C#, in ways that make it shine for what it shines best for.

# re: Is VB.Net better or C#.net? Or is .Net a .Net either way?

Left by Bigyan at 6/18/2008 1:27 PM
Gravatar Well, I guess I should be more clear that my intention here is not the spread the propaganda on VB.NET or C#. I couldn't be more happy with tons of choices in terms of programming languages that are available in IT currently. All in all, the variety helps to make our lives easier as a IT workers. May I should have worded the title differently as to why someone may find more productivity on one language vs other.

Your comment:





 
Please add 6 and 5 and type the answer here:

Copyright © Bigyan Rajbhandari