tags:

views:

1036

answers:

11

Background

I have decided to do my graduation project (yet to start) in .NET. Regarding it, I am bit confused about: what language should I learn: VB.NET or C#?

What I have learnt from those who know it that both VB.NET and C# have:

  • The same concepts
  • VB.NET is simpler as it is more like English statements but also C# is simple too if you already know C (Which I do know)

Question

So considering some factors, e.g. career point of view, newness, challenging and beneficial, etc., what language should I choose?

Please help me out. And clearly do justify your answer (whatever reason you have.)


References (Extra)

A little information about what project I am doing: It is a database file system. Technologies I'll be using are SQL Server, WPF, etc.

I just love the concept of Database file system.So those who want to know more about Database file system, here are the links


UPDATE1 : After some really good explained answers (actually all are good at their place), I have finally decided to go with C# for myself. Thank you all.

Still, you are requested to put your opinion (Once it is reopened,of course)

UPDATE2 : Question reopened and made community wiki.Thank you all.

+7  A: 

If you already know C, then learning C# may be a bit more easier.

Both languages are very close in what they allow you to do. Mostly, it is the class library that holds the power of .NET, but you can access it from either language.

Career perspectives depend very much on your region. You need to research it. Still, the general understanding is that C# developers can hope for a bit higher salary. Also some companies are phasing out VB.NET from their toolbox and doing C# in new projects. I'm not sure I ever saw one opening that declared the opposite course of action.

Developer Art
+1  A: 

Learn both! It's mostly a matter of personal preference and which syntax you prefer. With that said, from a career point view C# makes you more attractive to recruiters, according to this coding horror article, C# programmers are paid more than VB.NET programmers.

Whatever you choose to learn, make sure you know enough of the other language to be able to read its code samples. It's really not that hard to learn both of them and still use the one you like.

Firas Assaad
Right now I have to make only one choice.I can learn the other one later.
Ravi
A: 

I recently made that decision myself and decided on C#. The languages are very similar in capability but C# seemed to have more potential for learning skills I could then apply to other languages. It also seems that VB has an odd stigma that I find puzzling given the similarities of the languages in capability.

Mike B
What is VS? Do you mean "Visual Studio" by it?
Ravi
Yup! (15 chars)
RCIX
"C# have more potential for learning skills"?? I might be wrong, but what I learnt is if you know C then C# is not that difficult or challenging
Ravi
That's true for the basic syntax - but be careful, you don't want to be programming C# just as though it was C!
FinnNk
Doh VS was supposed to be VB. This is where the decision is so dependent upon the individuals past and plans. In my case I had a ton of BASIC experience, albeit from a long time ago
Mike B
+8  A: 

Regardless of which language you choose, make sure you learn what underlies them both - the .NET Framework.

For me personally, I find the C# syntax a lot cleaner to read. But of course that is a personal preference.

Andy
+5  A: 

If StackOverlow is anything to go by the following might help:

  • Questions tagged "c#" 45839
  • Questions tagged "vb.net" 4839

So there are way more C# questions asked/answered.

Interestingly enough there are only 25491 questions tagged ".NET", less than C#?

Matt Warren
Hmmm... Does this mean that people are having 10x more trouble with C#... :p
Arjan Einbu
No I read it to mean that C# topics/discussions are more active because more people are using it, but thats only a guess.
Matt Warren
Unfortunately, StackOverflow sucks as a platform for VB-related questions. Just look at the non-existence of syntax highlighting. That’s just unwelcoming.
Konrad Rudolph
+1  A: 

I'd highly recommend learning C#. It has a nice compact syntax (compared to VB) and is in my opinion easier to read (less words means your mental word parser doesn't have to work as hard). (Plus, in my opinion, VB just looks silly :D )

RCIX
'Silly' is a bit harsh Rick! :) I started with VB.Net as I had never had any experience with C/C++, only a bit of VBA, batch files code etc, plus ZX81 back in the olden days! So, it looked kind of familiar to a complete noob like me, and made for an easier introduction to .Net
Andy
Perhaps. The other points still stand though :)
RCIX
Yup, I agree totally.
Andy
+13  A: 

C# without a doubt. Why?

  • Cleaner as it is far less verbose.
  • Better from a career point of view.

Nuff said.

Wim Hollebrandse
The “less verbose” part isn’t actually true (for the most part). That is because humans don’t actually read on a character level (again, for the most part). Instead, they more often read on a word level. As a consequence, `}` is just as verbose as `End`, etc.
Konrad Rudolph
Your right, Konrad. However, it is far easier to distinguish a `{` from an `End` when they are surrounded by a dense block of other words. Non word constructs give structure and actually make the code easier to read. I look at VB and just see an essay, where as C# you can see all the loops/methods/properties straight away from a wider perspective.
Callum Rogers
In terms of interpreting it when reading, perhaps so, though it FACTUALLY *is* more verbose. Also, it's more verbose when you're writing code! You have to type more. It's obvious really.
Wim Hollebrandse
By the way, why you are playing with "enough" and "nuff"?
Ravi
+1  A: 

My first .NET language was VB.NET. Any time I wanted to learn about something non-trivial (patterns, unit testing, mocking, etc) I'd be translating code samples from books and blogs from C# (or even Java) into the language I was using. In a twisted sort of way that was good as it meant I was thinking about was I was doing - but if you have the option to choose save yourself the hassle and learn C#. VB.NET certainly has its uses and it's a decent language - but learn it when you have a need to otherwise you're swimming upstream against the bulk of the .NET community that has got past "Hello World".

The longer your experience is with something the better you will be provided you build your skills as you go, so the choice you make now will matter.

Learning multiple languages is definitely a good idea, but I'd go for something different like a functional or dynamic language such as Python, Ruby, F# etc for that rather than one where the biggest difference is syntax.

FinnNk
+1  A: 

Most of the rated answers are the meat of your answer, but since I can't comment I'll add my two cents here.

You should learn C#, why?

  • C# is becoming more popular as pointed out by Matt
  • C# developers are paid more as pointed out by numerous users
  • C# is syntactically very similar to Java (and so some companies that are looking for intro level Java developers may take someone who knows Java or C#, where as VB.NET would be a long shot)

As stated by another user, you should really learn the Framework if your goal is to follow the .NET path, but if you're just learning it because you have to learn one of the two then even that is unnecessary.

Mark
+25  A: 

I’m an all-out VB enthusiast. So perhaps my answer might carry a little weight, because I actually advise against starting with it.

The optimal solution, as someone has already suggested, would be to learn both languages. This is because both languages have shaped the architecture of the .NET framework considerably. In particular, attempts to preserve compatibility to VB6 have contributed a few odd quirks to the framework.

I also find the C# syntax fundamentally flawed because it inherited the C premise of using largely nonsensical semi-colons, braces and other ASCII trash where keywords would have been more appropriate (e.g. conditional operator, lack of keyword to introduce methods and variable declarations …). You don’t need to agree with this claim/opinion; its purpose here is just to show that I’m not biased in favour of C#, quite the contrary.

That said, C# does have a much larger share of examples on the web, and support tends to be easier to get (just look at StackOverflow). VB also still encourages some bad practices if you don’t pay attention, in particular because Microsoft has irresponsibly decided to make Option Strict Off the default setting, encouraging dangerous loose typing in some places (if you ever touch VB: never use Option Strict Off … except for COM interop scenarios, but in future versions of VB not even there).

Another thing is that they have simply botched lambda support. Both VB and C# offer a very elegant means to express high-level structures in code using queries over data (Linq …). And both use so-called lambdas (anonymous methods, which are declared at the point of usage rather than elsewhere) to express this.

But while the C# syntax for this is concise and very readable, and tries to treat functions like first-class objects, the VB syntax is clunky and impairs readability for no good reason.1) Despite my aversion for ASCII art, keywords are actually the worse choice here.

Consider the two following code samples:

First, C#:

var items = Enumerable.Range(0, 10); // = 0, 1, 2, 3, 4, 5, 6, 7, 8, 9
var x = items.Select(x => x * 2);    // = 0, 2, 4, 6, 8, 10, 12, 14, 16, 18
var y = items.Where(Number.IsOdd);   // = 1, 3, 5, 7, 9

(for a given definition of Number.IsOdd as a static method.)

Now, consider the equivalent VB code:

Dim items = = Enumerable.Range(0, 10)
Dim x = items.Select(Function (x) x * 2)
Dim y = items.Where(AddressOf Number.IsOdd).

FAIL!

I’m sorry to say it, but everything in VB’s design of these features has gone wrong. Since they have become an integral part of .NET programming (even more so in the upcoming version), VB has now a serious disadvantage.

In conclusion, my advise is to start with C# and perhaps try to learn a bit of VB by and by, to get more perspective on .NET. By the way, the same is true for other .NET languages such as F#.


1) In fact, there are reasons for that. Alas, they are not good enough (for me). For the technically interested:

  • AddressOf is required because otherwise there would be an ambiguity since parentheses are not required in VB on parameterless function calls, and method calls. However, AddressOf is simply inadequate of we were to treat functions as first-class citizens of the language. Furthermore, the IDE automatically adds the unnecessary parentheses in all other places (except parameterless functions and constructors) already. Why not there as well? That way, the ambiguity would go away, at the cost of a trivial refactoring of legacy code (remember: every old project must be upgraded anyway, when imported in a new version of Visual Studio).
  • => cannot be used for lambdas because in VB it’s actually the same as >=. The IDE converts the former into the latter upon typing. Of course, there are several solutions to this dilemma, ranging from finding another symbol for lambdas to just abolishing the auto-correction of => into >=. I would even like a Python-like solution, resulting in almost the same code that is there today, but still being much more readable:

    Dim x = items.Select(Function (x) x * 2) ' Old code '
    Dim x = items.Select(Function x : x * 4)  ' New code '
    

The colon does wonders for readability: suddenly, the function forms a flow. Or we could now use => instead of the colon, since it’s now unambiguous (which then would read nicely as “function where x maps to x times two”.

Konrad Rudolph
Good answer, I agree that the VB lambda syntax is not ideal, but you get used to it... Also can you elaborate on this: "… except for COM interop scenarios, but in future versions of VB not even there". What will be done in future versions of VB to ease COM interop scenarios?
Meta-Knight
@Meta-Knight: future VB versions have the `dynamic` typing and DLR API which is far superior to `Option Strict Off` since it allows a very fine-grained usage of loose typing. As far as I know, COM can be accessed via this API. The resulting code will read like conventional `Option Strict Off` code but will be more type safe.
Konrad Rudolph
So you have left the decision up to me ha?
Ravi
@Ravi: well, technically it *is* yours. But no, not really. I advise against starting with VB, as I’ve written in my answer, and for the reasons given in the answer.
Konrad Rudolph
Great! I actually decided on C# on first 4 or 5 answers only.But was kinda expecting a well justified answer (as yours).Well explained.Thanks.
Ravi
IF you don't mind can you have a look at another question of mine?http://stackoverflow.com/questions/1590405/distinguishing-extra-element-from-two-arrays
Ravi
Thanks for efforts and time.
Ravi
I don't agree that C# has "inherited the C premise of using largely nonsensical semi-colons, braces and other ASCII trash where keywords would have been more appropriate", I'd say that vb.net has overly verbose keywords and that reading a class definition is like reading a novel. However both these opinions are highly subjective and shouldn't be in an otherwise objective post like yours.
Blindy
@Blindy: I agree that I haven’t offered arguments to support this point (although I contend that there *are* arguments for it). However, I didn’t intend these points to form an argument at all, I just wanted to show that I am not biased in favour of C#, and a subjective opinion works just as well to show this. Supporting this claim with arguments would have detracted from the gist of my answer. Since you’re (at least!) the second person to kind of misunderstand the purpose of this paragraph I might need to clarify.
Konrad Rudolph
+2  A: 

For some reason, VB.NET has always carried the image of a "simple language for beginners" (and MS often presents it as such), which IMHO is misleading : it's actually easier... to write bad code ! (of course you can also write bad code in C#, but in VB.NET you're almost encouraged to)

The IDE also behaves differently : in VB.NET it hides some of the complexity to the developer. In some cases it can be annoying because you have less control over what you do.

Also, the fact that it is less strict than C#, although it makes it look easier, often causes bugs which could have been detected at compile time in C#.

So, for all these reasons, I strongly recommend C# over VB.NET. It's also for personal preference, as I don't like the VB.NET syntax, which I find too verbose.

Thomas Levesque
Two things: when does the IDE give you less control? Simply not true. Second, about being less strict: `Using Strict On` makes it as strict as C#. VB code should *always* use this switch so it’s really just as strict as C#.
Konrad Rudolph
@Konrad: for instance, when you create a custom WinForms control, the base class declaration is in the designer file, which is hidden by defaut ; if you want to change it you need to edit the designer file. In C# it's in the user file. Regarding Option Strict: it makes things better, but there are still some things that should be more explicit, for instance ref or out parameters
Thomas Levesque