tags:

views:

2204

answers:

21

When .NET was first introduced, it was common (and an obvious choice) for people coming from a VB6 background to jump into the .NET world with VB.NET rather than C#. Today, we use C# for over 90% of our projects, but occasionally we will provide support or services to organizations that have standardized on VB.NET.

Today, there several tools that can alert developers to certain problems and inconsistencies when developing with C# (StyleCop and ReSharper come to mind). However, VB.NET does not seem to enjoy the same level of support in the .NET ecosystem these days. Even looking at the tags on StackOverflow seems to show almost a 10-to-1 lead for C#.

Has anyone ever seen any sort of usage statistics comparing C# development to VB.NET development? If you were starting development on a new .NET project today, which of those two languages are you more likely to choose and why?

+3  A: 

Would always choose C#. That's just my own preference. I've always preferred the C-style languages over more English-like languages like VB and Delphi. There's no practical reason for either choice at all. Either language is capable of exactly the same things as the other (though some things may require a bit more work to use in one than the other).

It may be undeserved, but C# seems like a more "professional" language than Visual Basic (any version), which seems more like a "toy" language, even now.

DannySmurf
What defines a "professional" language? I can code solutions much faster in VB.NET than C#. Period. Therefore, in my opinion, C# is the "toy" language.
AMissico
+2  A: 

The reason for the 10-1 tag count is that vb programmers dont need as much help =)

I use VB but prefer c# because it looks 'cleaner'.

StingyJack
This is a very true statement. I believe VB.NET forces a person to think about the solution. Whereas, C# forces a person to think about the language. Therefore, the C# will look for specific help quicker when they cannot see past the "language".
AMissico
+8  A: 

I suspect that your data is bad.

First, SO is more likely to attract C# developers than VB developers. There's a difference in how each tend to think about themselves, and that is reflected in how much time they spend here on SO.

Before C#, there were about 10x as many VB developers as C++ developers. As they came to .NET, VB developers were more likely to choose VB.NET. So, that starts you off with a LOT of VB developers.

You mention ReSharper, but consider that VB 2005 shipped with Refactor! in the box: http://msdn.microsoft.com/en-us/vbasic/ms789084.aspx.

You mention StyleCop, but consider that the built-in VB editor does more to manipulate the appearance of your code than C#.

In both cases, it seems that a stock Visual Studio gives you more for VB than C#.

Jay Bazuzi
I want to add that the typical C# developer will add "C#" to their searches. (Note the high instance of .NET SO questions tags with C# instead of .NET.) In my opinion, a VB developer is looking for .NET, C#, and VB.NET, so they will search for .NET instead of the specific C# and VB.NET. This point is illustrated on the numerous articles, charts, and other "stuff" that compare C# and VB.NET using keywords, phrases, tags, and so on.
AMissico
A: 

C# books outsell VB.NET books 3 to 1). VB code may be used more often, but it seems like C# developers taking coding and code quality more seriously.

EDIT: Link to the quote about C# outselling VB.

Jim
Or maybe C# is harder to understand than VB.NET, so more books are needed. Ok, I'm just kidding...put the flamethrowers away. But seriously, to me anyway, MustOverride and NotOverridable really do state their meaning much more clearly than abstract and sealed.
JeffK
+1 "C# is harder to understand than VB.NET, so more books are needed." Moreover, the book needs to be C# to avoid the "toy" language stigma and appeal to a broader market. It just makes business sense. VB.NET programmers do not care if the book is C#, VB.NET, or some other human-readable language.
AMissico
+1  A: 

With the negative perception of VB developers it is possible that they ask their questions in C# to avoid any harassment. Just a thought...

Hugoware
I really don't feel there should be a negative connotation to VB.NET. VB.NET and C# use the same .NET framework classes and compile down to almost the exact same IL.
stephenbayer
True, but unfortunately VB people can't seem to shake the "bad developer" label...
Hugoware
or to put that another way, a C# dev is just a VB dev with a superiority complex :)
gbjbaanb
-10 to @Hugoware and @gbjbaanb
AMissico
A: 

I'd definitely always use C# unless there was a compelling reason to not to. Everyone in my shop comes from a C and C++ background and the C# language is similar enough in look and feel to C++ that none of us would probably take the time to work through the VB syntax. From a productivity standpoint, it would just slow us down.

Now, if VB brought something to the table that C# didn't do without considerable hurdles, we might consider it. We'll write our solutions in whatever is most appropriate from among the languages we are familiar with first. If they don't provide an easy solution, then it is likely time to add a language to the toolbox. Case in point - I had some Mac work to do some time ago and it was infinitely faster for me to write it using the Qt library in C++ than to try to ramp up to speed with Objective-C. The client didn't care and in the end wanted a solution quick.

There are a lot of VB folks in the world but I haven't had the need to really use it (other than for playing around) up to this point.

itsmatt
actually I find it the other way round - C# looks so much like C++ that my brain treats it like C++. When I do VB though, its obviously different, so I get better code out of it. There are some serious good features in VB though - search SO for details.
gbjbaanb
I find that C/C++ programmers make terrible .NET programmers. Even if the language is C#.
AMissico
A: 

I would use C# in a new project just because I come from a C background. But if there were more VB than C# developers in the project I would had no problem using VB. It might even be a fun thing to learn.

Artur Carvalho
A: 

I use mainly C# due to the fact that vb.net seems to be more verbose and usually requires more typing to accomplish the same thing in C#. I'm not opposed to either, but I just personally prefer C#. I don't look down on those that prefer other languages though. Some of the statistics that I do know is that in the industry, those developers hired in as C# developers have higher average salaries than those hired in as VB.NET developers. I believe both languages can achieve the same end product though, so I have no idea why anyone would have a disdain for either.

As a side note, my familiarity and comfort with C# probably stems from the fact that I've come up the C style language track. I used C back in the 70s, C++ in the 90s, a lot of perl, and some java. Those all share the same sort of format as C#, Java being the absolutely closest, but all in all, it's all C'ish.

stephenbayer
I did C style (some C++, lots of PHP) for a long time before getting into a .NET shop using VB.NET. I know C# as well, and though the syntax for VB is longer, visualstudio helps out a lot more, and I find I actually end up typing LESS because it completes so much for me.
gregmac
I can't cite any statistics, but you can't possibly type that much more in VB as opposed to C# if you're in an IDE. With the exception of creating new names for methods and variables, you rarely have to type more than two or three letters before you just hit TAB to finish the rest of the word.
Hugoware
+1  A: 

It's about 50/50 in my shop. Most of us have one of the two that we prefer, but seem to be willing to work with either. I try to use C# when I can, the syntax just looks cleaner to me. Very often though I will end up creating a C# project with a single VB assembly (to take advantage of xml literals recently) or vice versa.

A: 

I think a really good gauge is to look at job listings online. You'll usually find there is a lot more demand for C# developers. Therefore, if you're looking to use best practices as well as provide a work-environment that enables career development, you should use C# for the majority of your projects. Even so, you may wish to use VB.NET 10% of the time just to keep things well-rounded.

alord1689
A: 

I'm a VB.Net developer mainly, but I'm considering switching to C# just because the lambda expressions are so messed up. And I have a feeling they can't really solve it anytime soon. Or they would have to make it a breaking change. Who came up with the idea to make a lambda a function anyway?

chrissie1
Lambdas have been around for a long time.http://en.wikipedia.org/wiki/Lambda_calculus
Justice
I know that, but in VB.Net 9 an C# they are kinda new. And in VB.Net a lambda expression has to be a function, you can't have a void/sub which is annoying because it can be done in C#.
chrissie1
Just return Nothing in your VB.NET lambda expression. There is no requirement that you have to return a valid value.
AMissico
+6  A: 

I can work in either language but prefer VB. VB has alot going for it:

  • Better LINQ support via more language keywords
  • Easy access to the My namespace
  • declare and initialize in a smaller number of characters

For example:

Dim client as New SmtpClient()

vs

SmtpClient client = new SmtpClient();
  • I prefer the "*/End *" paradigm to curly braces. It's easier to match up mentally.

For example:

If someCondition Then
    DoSomething()
End If

vs

if (someCondition)
{
    DoSomething();
}
  • AddHandler is more immediately readable than += to assign delegates

That said, C# does some have something going for it, like

  • unsafe
  • anonymous methods (I know VB's got lambdas, but only single statement lambdas :-()

It all boils down to preference, but I can't stand the elitism that C# tends to come with.

Bob King
Re the "Dim", see "var" in C# 3.0
Marc Gravell
except that var is strong-typed
Joachim Kerschbaumer
Dim is strongly typed as well, assuming Option Strict is On
Bob King
Re the more keywords: I don't know if it's a real advantage. The Linq syntaxis for VB is really odd at times, like the group by + projection stuff... it's just not consistent.
Frans Bouma
I know I keep banging on about this, but auto-complete, intellisense and the pre-compile processing actually work in the VB IDE too. Totally agree with all this.
ChrisA
wow, I disagree with *all* your arguments... I guess we couldn't have more different opinions ;)
Thomas Levesque
@MarcGravell "var" doesn't work for class members, whereas "dim as new" does.
Strilanc
"var" is abused by C# programmers!
AMissico
+2  A: 

C# and VB.Net are not that different, proof being that there are some automated conversions utilities that do a very good job of translating one into the other. VB.Net as a BASIC derivative has a lower barrier of entry, making it easier for self-taught or those who are just interested in programming as a job to get a living to get started and productive.

On the other hand, C# developers would usually arrive at C# from a previous history of studying C-language syntax, probably because they were educated in the C/C++ way, which usually denotes a formal education in software development.

That being said, there are good programmers and bad programmers regardless of the chosen language and a good programmer will know more than one and use the most appropriate for the task at hand.

Language wars only develop when people know too few languages and believe they have to fight to justify their -lack of- choice (my language is better than yours).
Knowing more than a handful programming languages is really mandatory: you can't solve all problems with a single tool and adapting to various ways of thinking always give perspective and a lot more choices when presented with a problem to solve.

So in essence, statistics about which language people use is not that relevant (unless you're looking for a job in a particular one).

Renaud Bompuis
+1: Good answer.
AMissico
+2  A: 

In VB you can invoke a method or function without even using the ()...stuff like:

astring.ToString //invoked without the brackets :o !

For me, that is a really really bad practice to code with, and this is because in most programming languages that are in the C-Familty, a clear distinction is made between invoking a method or passing a reference to it!

Thus, if you use VB.Net and then move on to other languages such as C# or Javascript, you will find the concept of references versus invoking a bit harder to grasp

Andreas Grech
This is an example of the language interrupting the programmer. The language should NOT force you to code in specific ways. What difference does it matter if it is ToString or ToString()?
AMissico
@AMissico - What he is saying is that someone who learns VB first may have a more difficult time adopting C#, because they have not had to remember very common things like perens when calling a method.
StingyJack
A: 

Whenever i make a post on SO i always make sure my question is language agnostic (in a .net sense) as i can then tag it as c# and vb.net and get the extra exposure that the c# tag gives my question.

Another statistic you could look at would be a list of open source .net projects. How many are written in vb.net? Hardly any. Maybe they are like me and just use C# as it gives them more exposure and avoids the anti-vb elitism completely.

Pondidum
A: 

What I liked about C# is that it enforced static typing. VB.NET let you get away with this kind of things:

Dim a = 1, b = 2, c = a + b
' Q: How does the compiler know that operator +
' can be applied to a and b if they are Objects?
' A: It doesn't, the program relies on late binding.

And, whenever you wanted to enforce static typing, VB.NET had these long stupid keywords:

Dim drv As DataRowView = DirectCast( _
    MyBindingSource.Current, DataRowView)
' I would usually fall asleep before finishing reading.

But now that C# is another dynamic language, I can go back to C++ happily.

Eduardo León
There is no late binding in .NET. You can change this behavior by turning on Option Strict.
AMissico
`Option Strict` on enforces static typing, but it doesn't make it any less painful for the programmer. `DirectCast`, whose syntax is awful, is still the only way to downcast.
Eduardo León
+1  A: 

For a very long time, I coded in VB as my primary language. I've made the transition to C#, and I'm very glad I did. When I ported some VB.NET code to C#, I was alarmed by some of the things that VB.NET's compiler would let me get away with that I wasn't even really aware that I was doing.

Here are a few examples (kindly ignore the crappy code, since it's purely for educational purposes):

Imports System.Diagnostics
Dim log As New EventLog("Application", Environment.MachineName, "MyApp")
log.WriteEntry("MyApp", "Message Text", EventLogEntryType.Information)

The C# compiler balks at this whereas VB just smiles and nods. The problem is that I'm invoking a static method (WriteEntry) on an instance variable.

Then there's this:

If CInt(txtQuantity.Text) Then
   ' Do something spectactular
End If

Visual Basic helpfully converts the result of CInt to a Boolean to help evaluate the If...Then statement. If it’s nonzero, you get True and something spectacular happens. In C#, you get a lovely compiler error about not being able to cast an int to a bool. Why? Because an int isn’t a bool, stupid!

In Visual Basic, you can do this for days and the compiler will pat you on the back while you do it:

Public Function FooBar() As Integer
   Dim result As Integer
   Return result   
   REM Do some more real work--that's unreachable
   Return result
End Function

Does the compiler care? Nope. Not a peep. C#, on the other hand, gives you this nifty warning: “Unreachable code detected.” Then it gives you the file name and line number where it’s at. It’s like your best friend saying, “Hey man, you really don’t want to do that.”

What I found was that I was doing a lot of things that were just plain sloppy; things that I'd been doing for a long time and not even thinking about it. C# enforces better habits. It makes me think about what I'm doing, which naturally results in fewer defects. So I vastly prefer it over VB.

Mike Hofer
have you tried with 'option strict' on?
gbjbaanb
Oh, yes. But that doesn't eliminate many of the other lazy habits that Visual Basic instills in programmers by virtue of the very nature of the language, and its target audience. It was designed for business users with little or no programming experience.
Mike Hofer
"The C# compiler balks at this whereas VB just smiles and nods. The problem is that I'm invoking a static method (WriteEntry) on an instance variable." Not true in Visual Studio 2005/2008/2010./
AMissico
"you can do this for days and the compiler will pat you on the back while you do it". Again, not true.
AMissico
A: 

I LOVE C#!!! Makes you feel more professional. Makes you feel an advance and intelligent person. Makes you feel great. VB.Net carries the shame of being BASIC hahaha. C# = adulthood; VB.Net = babies hehehe. Kidding aside really, it's personal preference. And I LOVE C#!!! Shout it out! Woohoo!

secretoparabibo
Stack Overflow is not the place for these kinds of answers. Programmer = Professional.
AMissico
+2  A: 

Subjective discussion. Technically there is very little difference between the two languages. However there seems to be a trend that C# is gaining popularity where VB.Net is declining. Here are a few numbers/trends to back up that claim.

jeroenh
As noted in my other comment: "The typical C# developer will add "C#" to their searches...In my opinion, a VB developer is looking for .NET, C#, and VB.NET, so they will search for .NET instead of the specific C# and VB.NET. This point is illustrated on the numerous articles, charts, and other "stuff" that compare C# and VB.NET using keywords, phrases, tags, and so on
AMissico
+2  A: 

A good developer knows both and can write professional code with either or.

Edward
Rubbish. There are plenty of excellent developers who use only one, or neither of these 2 languages.
Steve Haigh
A: 

C# seems to be quite a bit more popular than VB.Net (see http://www.telerikwatch.com/2009/06/survey-says-c-still-more-popular-than.html for a usage statistic survey).

As a contractor, I just match the client preference, but about 8/10 contracts use C# not VB.net in my experience.

I'm not aware of any technical reason to choose C# over VB. It is cleaner to read (and requires a bit less typing!)

I'm also finding that a lot of books are now providing examples in C# in preference to VB.Net.

jimasp