views:

2264

answers:

32

I'm looking to pick up either C# or VB.Net. I'd done a fair bit of VB6 programming in the past.

I'm looking at getting the book, Visual Basic .NET or C#, Which to Choose? but I'm hoping that someone has read it, or used both languages and can offer advice.

Should I just RTFB?


Edit: Anders Sandvig raised a valid question. I'm intending to develop ActiveX applications that will be served through IE.


Edit: Given that the functionality is pretty close and my favored approach to learning is to "just build it" and solve problems by looking it up on the internet, I've decided that the choice of language will be based on how easy it is to learn it. I looked around and found sites like C# Corner that supports my approach. Personal note: I wish I could also select Seb Nilsson's response as an accepted answer as well.

Thanks guys for your input!


Alright, then! I admit, theoretically, this topic is subjective; but a quick tally of answers seems to skew votes heavily in C#'s favor. Anyway, I'm really after experiences like what Keith's alluding to. I'm hoping he'll return to this topic and drop us a few more gems.

A: 

This is much too subjective. It really depends on what your background is. You can pretty much do the same in both. Each langugae has a few special features, like VB.NET having inline XML in code.. I prefer C# though as I have better familiarity with C style languages.

EDIT: And of course you will get lots of biased answers with this question which DOESNT HELP you one little bit.

mattlant
I have some background in VB6. Question is: is VB.net and C# exactly the same? The fact that there's a book out there says that it probably isn't. I'm hoping that practitioners who have experience in both can offer some insight.
magius
I you have backgound in VB6 i would suggest starting with VB.NEt, you will feel more comfortable in it, although thre is still a learning curve involved as a lot changed.
mattlant
You can always learn C# at a later time. Like someone else here said, once you know the framework, it makes it much easier.
mattlant
+4  A: 

Once you learn the framework, it really does not matter what language you choose. Initially you will probably be more comfortable in VB. It still heavily caters to newer developers and developers "just trying to get the job done."

I personally develop my class libraries and frameworks in C#, and do all my UI development in VB. It takes some getting used to, but I enjoy the freedoms both languages offer.

While you are trying to learn the framework, use what is most comfortable and then extend your knowledge with the other syntax.

Nescio
+2  A: 

This is a pretty subjective topic. If you feel comfortable with VB, you might want to stick with VB.NET. If you want to try out another language, try C#. C# is also highly productive like VB.

I have used VB6 in the past but chose to code in C++ for speed. C++ was horrible for UI though. Then came C#, which made me enjoy writing windows apps as well as keeping familiarity to C++.

It's all down to your preferences imho. If you're looking for a kick, I suggest you try a bit of both to see which suits you best.

Statement
I'm trying to put my preferences aside and see if the community has experiences I can use.
magius
+37  A: 

The main reason would be that C# is very similar to other languages, such as C++, Java and even JavaScript. So if you know any of those languages you'll already have a bonus and if you don't, you can probably learn those languages easier.

C# is a bit more compact, has a few more easy-accessible features, such as Extension Methods and Attributes, which are a bit cumbersome in VB.NET.

VB.NET got XML literals, which C# doesn't. Otherwise, I can't see any other advantage to VB.NET.

Personal answer: I started out in VB.NET, but that felt like I was coding... But going to C# felt more like I was developing. Went from copying and changing gaps of code, to actually understanding the concept of developing. Again strictly personal.

Seb Nilsson
+16  A: 

I agree with everybody else when they say this is a subjective topic. You can do .NET with either language. Here is what nobody seems to tell newcomers:

Knowing C# will pay more than VB.NET!

I had about 5 years experience with VB, before I moved to VB.NET. I learned C# while on a contract fixing some legacy VB6 code. My salary and contract rates jumped quite a bit since then.

So on paper both look good, but in the market place, you will get more money by knowing C#.

hectorsosajr
In my defense, it would be a subjective topic if I knew both languages already. But I'm voting you up because of the intere$ting fact you raised.
magius
Ahh, I see what you are saying. Well, learn .NET with VB.NET. That will make your transition easier. The learning curve will still be fairly big though. Then switch to C# once you feel comfortable with the framework. There's no substitute for getting your hands "dirty" with code. :)
hectorsosajr
+11  A: 

I've used both.

They are practically exactly the same to use, with VB.NET slightly more catered to a more novice audience (due to the verbose nature of the language), and C# slightly more catered to a more mature developer (due to the syntax similarities to Java and the C/C++ languages). Apart from that there is no discernible difference, although C# will get slightly more money out in the industry.

As has already been mentioned (and this is the most important point), they use the same underlying framework, so you will be able to switch between the two with minimal fuss. So for all intents and purposes, just choose whichever you feel the most comfortable with.

jacko
Language aside, is it equally easy to create "paint" the GUI?
magius
Well, they both use the same toolkits in Visual Studio, so I would answer yes.
jacko
I've seen no difference when creating GUIs in either language. I've created Winforms, Webforms, Win32 API calls, and Windows Services with both. I didn't see any difference with that either.
hectorsosajr
Right, once you learn well learning the only is maybe a one week process. I like C# more personally because i was brought up on C/C++/Java but just flip a coin and start with that one.
diadem
A: 

If you want to get up and running as quickly as possible, choose VB.net. You already know VB and that will help you greatly.

However, if you want to be more flexible, choose C#. This language is closer to other popular programming languages (such as Java) while VB.Net is more a "dead-end". I would also claim that it is easier to get good jobs if you know C# and easier to get help on sites such as StackOverflow.

Also, if you learn C# and already know VB, you will more or less dominate VB.Net as well without further effort.

Finally, remember that the big decision you've made isn't to learn a new language; it's to learn a new API/framework. I think you will find that to be a wise and productive choice.

Good luck!

Magnus Akselvoll
Which actually comes first? The language or the framework? I bought a book on the framework ... I found it a waste of time and money.
magius
+10  A: 

Yes it's subject, but it seems like many people are afraid to give their opinion to the question. I don't think we are being helpful by simply saying "it's subjective" and closing the door on the question.

So here's my take...

There's no correct answer but if I were in that situation today I would choose C#

I've had to do projects in both and VB.Net seem a little to wordy for me, but with no benefit that I can discern.

They both use the same exact libraries and compile to very similar bytecode/MSIL. They both are built using the same processes in the same environment. So yes, the differences aren't much.

Another small point is that I tend to see more examples and literature in general in C# than VB.Net. Again, this is a single person's point of view. If anyone has experienced differently I'd like to hear.

Wikipedia is a good resource to start with on this topic. It has an extensive article on The Comparison Between C# and VB.Net. An interesting read at least.

In the end, whatever you choose, you'll be able to switch in the future.

kervin
good post. When i said biased in my post i didnt mean anything like what you said, but rather the commnets like: VB Sucksorz. etc.
mattlant
Well, I'd love to be able to master both. But for now, there're only so many hours to the day. By the way, I did google for comparisons on C# and VB.Net. They essentially compares the language. I'm looking for a comparison of how they fare in projects.
magius
Well, go look at at DOTNET NUKe. It is a HUGE project written in VB.
mattlant
+5  A: 

I know this will be viewed as heretical to acknowledge, but deep down, VB.NET and C# are really the same language. The differences are almost entirely syntactical, and unless you are involved in a bizarre edge case, you can get the job done just as efficiently in one as another. Translating between them is trivial, and there are plenty of mechanical translators out there to prove how easy it is.

So, the choice really comes down to syntactic preference. You say that you come from VB6; this would suggest that in your case, VB.NET would be the easy choice. On the other hand, if you are comfortable reading "curly-brace" languages like C or Java, then C# is a good choice.

Personally, I like VB.NET, as I think the verbosity makes programmer intent a bit clearer.

Michael Dorfman
"I think the verbosity makes programmer intent a bit clearer" VB has the wrong kind of verbosity! Its plain and simple noise which does not add anything to the information content of the message/program. If you like verbose, write comments instead.
SDX2000
+1  A: 

Since you had a little bit of VB background I would say go for VB .NET, it Will be easier to learn...

RWendi

RWendi
A: 

I've also used both. I started out using VB6 for many years, before moving on to VB.net. Once I'd gotten used to using VB.net for about a year, I decided to try out C#. Since then I haven't looked back.

My favourite part about using C#, is of course the for loops. In C#, they are much more powerful, with the same syntax as C, Java, et cetera. In VB.net, one is pretty much limited to doing things like

For i = 0 To 9 Step 2
  ...
Next
For i = 9 to 0 Step -1
  ...
Next

Whereas in C#, one can do something along the lines of

for(i = 1; i < 129; i*= 2) {
  ...
}

Which allows a sequence: 1, 2, 4, 8, 16, which is quite neat. In VB one would have to do something like

i = 1
While i < 129 : i *= 2
  ...
End While

Which is a bit more verbose, and harder to follow.

There are a lot of niceties like that in C style language.

I've also found, after a few years of using C#, that it is a lot easier to follow a page of code. Because it is less verbose and more compact, I can scan, and understand lines a lot faster than I could in VB.

It's also useful for the reason that there are a lot more code samples available in C# than there are in VB.net. This was also one of my factors in switching. I used to find examples in C#, then I'd translate them into VB, which did give me a bit of experience in using two different languages, and after having to do that for a while, it was fairly easy to switch over.

As for actually benefits in what kind of program could be produced, I found there to be little difference. They are both just as powerful, but these days I simply prefer C#, because it's easier to read, and I can do a lot of things with less typing. Things that annoyed me, such as the lack of nice VB shortcuts such as

text = InputBox("Enter some text")

In C#, it required me to make my own InputBox class. Alternatively I could have imported the VB library, and done it that way.

Also, VB had nice things like

text = Left(Value, 3)

In C# one would have to write

text = value.SubString(0, 3);

But that didn't take too much getting used to.

Anyway, my personal recommendation would be to try out C# at first, and if you don't like it, you can always switch to VB.net without much effort.

Vincent McNabb
Like I commented before, I'd love to master both ... but I'm not sleeping enough as it is. :(
magius
Don't forget the CInt CByte Now, the My namespace and all the gazillion VB functions and constants etc etc etc
Shimmy
+21  A: 

I use both a lot. I massively prefer C#, but VB.Net has some good points.

If you're working with COM VB.Net has some real advantages. Otherwise C# gives more 'precise' control - it has fewer implicit conversions and the like. C# is also more terse and is regarded by many as the more professional language - while that view is not accurate enough people hold it for C# to be worth more on your CV.

To be honest it doesn't really matter - the syntax of either is a day or two to learn. All the important stuff is common to both of them. Learn C# and you can pick up VB.Net in a day or two, and vice versa.

Don't waste your money on an entire book on the topic - it's gotta be mostly filler.

Keith
Alright, you got me intrigued. As I'm intending to build ActiveX to run in browsers, what advantages does VB.Net offer? Thanks heaps.
magius
There's more backwards compatible tweaks in VB.Net. For instance optional parameters on external DLL calls. Also VB.Net's implicit late binding makes lots of COM coding a little simpler - it's all doable in C#, but VB is better suited to it.
Keith
C#4 is adding optional and named parameters. This will make C#4 as good as VB for interop.
Keith
Implicit conversions can be switched off in VB.NET
MarkJ
That was probably one of the most objective comparisons between the two languages I have ever read.
Anax
Agreed - awesome objective comparison. Additionally C# allows an unmanaged mode (http://msdn.microsoft.com/en-us/library/aa288474(v=VS.71).aspx ) that VB.NET doesn't and that you're not likely to use when learning. The C# syntax also closely parallels itself with C, C++, Java, JavaScript and others whereas VB.NET syntax doesn't give you a lot of ability to jump to other languages.
John K
+1  A: 

If I were you, I'd pick up a language that's as radically different from what I already know as possible. A second language should, IMO, be a break, not a continuation, from the first - or you'll get way too stuck up on your habits as a programmer.

Try Erlang or Ruby or Assembler, perhaps.

Then, with new perspective, return to the question.

Can you give more details about those ActiveX apps? How urgent are they, who are they for, what do they do?

Aur Saraf
+3  A: 

Do not forget that there are free versions of both C# and VB available from Microsoft (Visual Studio Express) so it is easy to run sample code and see how each language works.

topcat
+1  A: 

Learn C#. You need a clean break from VB6, otherwise you'll be tempted to keep using the legacy functions. That's not to say that they don't work, but that a lot of VB6's functions fell into the pit of failure - they tended to perform peculiarly in the face of changing circumstances, or just have weird semantics generally.

Once you get all of VB.NET's Option Strict options turned on, to make VB predictable rather than a mass of surprising implicit conversions, it becomes very verbose.

Mike Dimmick
+1  A: 

I had VB 3,4,5,6 experience, but when I switched to .NET, I sticked with C#. I never looked back. I don't like the verbosity of VB.

But in terms of features, in the end there's almost nothing you can't do in either, albeit with some small differences.

If you want my opinion (and you asked for it), I'd say go for C#. In the future, if you need to change to Java, C, C++, etc., you might find that code easier to understand.

But the truth behind .NET is not C# or VB, but .NET Libraries. Learn how to move in those and you'll be ok.

Martín Marconcini
+4  A: 

If possible, both :)

If just one, then I'd go with C# myself. If you use the feature that Visual Studio 2008 added to be able to download the source for reference, you'll notice that it is written in C#. There isn't anything that you won't be able to do in C# that you can't do in VB.NET.

That being said...

As of today, there are features in C# that take more work to do in VB.NET. They do not have parity on one to one features.

For example, C#'s support for lambdas and anonymous delegates is currently far better than VB.NET's.

As of today, the two below statements are impossible to do in VB.NET:

List<string> vals = new List<string>();
vals.ForEach(val => 
{
   val = val.ToUpper();
   Console.WriteLine(val);
});

Or simply:

vals.ForEach(val => Console.WriteLine(val));

The reason for this is that the first lambda has multiple statements which isn't supported in VB.NET yet. The second is not possible in VB.NET yet because all lambdas must return a value. Also, VB.NET doesn't yet support iterators via a yield statement.

Now, that being said, VB.NET has the XML Literals support that C# doesn't have either. Let me tell you, if you work with XML, the XML Literals support might make me sway back to VB.NET over C# :)

Consider also that Paul Vick has posted articles (see here or here) that make it look like VB.NET will be adding features to bring VB.NET back to feature parity with C#.

And... if you don't care about any of these functional features... well, flip a coin then :)

David Mohundro
Not anymore, both are possible in VB.NET, besides, XML Literals is not possible in C#, And that's just one of the missing features of C#... ;)
Shimmy
A: 

As stated already, it is very subjective.

Since you have worked with VB6 you will have an easier time with syntax in VB.Net. However, they had to make changes between VB6 and VB.Net to make it work as a .Net language and play nice with C#.

I have used both and always prefer to work with C#, but I came to .Net from Java.

The biggest reason I would suggest C# is the similarity to other languages, this isn't an advantage just when you already know one of the other languages, but if you decide to expand beyond C#.

ManiacZX
+1  A: 

Learn both.

In their current (.NET 3.5) incarnations, VB .NET is better for working with XML, whereas C# is better for working with lambda expressions. You can use an assembly built with one in an assembly built with the other. So you can use both in the same overall solution.

Why not, then, use the best language for the job? Plus, speaking of jobs, you'll have access to more jobs if you know both languages.

Now here's the stupid part. If you're applying for a VB .NET job, put both languages on your resume. But if you're applying for a C# job, leave the VB .NET off. I've actually been rejected occasionally for a C# job simply for knowing VB .NET; the company seemed to think it'd be better to know only C# than to know both. VB .NET still has the stigma.

On the other hand, maybe it's just as well not to work at a place like that.

Kyralessa
Being rejected from a job by knowing more then what the need was probably a good thing.
Matthew Whited
A: 

It's completely subjective, but in the realm of career enhancement, C# is the better to learn. On average, the salaries of C# developers are slightly higher than those of VB.NET developers. On just that fact along C# is a bit higher on the scale of things to learn. VB.NET tends to be a bit more verbose, but I think it's not very difficult to learn both. And flexibility in the languages you know would be even more helpful. Besides, they use the same framework, so it's not that big of a stretch to gain knowledge and understanding of both languages.

stephenbayer
A: 

I think this would be a good opportunity to switch to c#! There are many sites that will help you get up and running pretty quickly with it.

pdavis
A: 

If you are concerned with backwards compatibility you might want to consider VB.Net. Though personally I would recommend switching to c#!

pdavis
A: 

C#

The change from VB6 to VB.NET is not a minor one anyway. If you now learn C#, you will be able to ick up VB.NET "on the fly". Diverse skills = better.

+1  A: 

I'd recommend both. Start with whichever you have a solid background with. I've got a few years of VB.NET under my belt, and find it a little annoying that when I go to look up help topics for .NET or ASP.NET, just about everything is in C#, so you end up having to learn a bit about C# regardless. I found this wonderful conversion tool from Developerfusion to be very useful. It isn't always correct, but it's very handy.

MadMAxJr
A: 

The language you choose honestly does not matter as long as you understand the logic behind programming. If you understand the logic, you can use pretty much any language. It really comes down to what you need out of the programming language; VB.Net has better uses for some applications, where C# is better used for others.

If you are looking for an easy transition that I would stick with VB.net because you already have VB experience. If you are looking to broaden your horizons though C# may be better to learn.

Hope this helps you, but it really does not matter what language you learn as long as you learn the logic behind programming.

Matt Pascoe
+1  A: 

One thing to consider is the available community support.

The arguments either way all make sense. However, issue I don't see mentioned here is the level of community support. In my very subjective personal experience, I would say that there is probably at least twice as much advice/examples/blogging/etc for C# than there is for VB.NET.

I started with VB.NET, but found myself forced to start picking up the C# syntax, etc, because so much of the sample code I saw was in C#. Eventually, I moved (evolved?) to 100% C# for writing .NET-based code. I couldn't/wouldn't go back though VB.NET does still have some nice conveniences that I miss.

AR
+2  A: 

I've been using VB and VB.NET for almost 12 years. Check out the job market. I see there are about two to three times more jobs available coding C# over VB.NET. VB has seen a steady decline over the years and C# is starting to become the norm for .NET development. I hate to part with VB, but the job market is making the choice for me.

A: 

i would say go with C#, it's syntax closely resembles that of other languages like PHP and Java.

+1  A: 

Being primarily a VB.Net programmer, I hate to say it...but, the industry, in terms of job openings is strongly tilted toward C#. Unless you came from a VB background and want something with similar syntax I would suggest C#.

OK, now that honesty has taken its toll, I would add that IMHO VB.Net is easier to read, especially for someone working on another person's code. It is a bit less cryptic and a little more verbose. I find these to be good traits in a language.

From a functional/performance standpoint it makes little, if any, difference.

Flip a coin...then start coding

Best of Luck

Karl - http://designlunacy.blogspot.com

Karl
+1 for the coin flipping idea!
Shimmy
A: 

Language choice, in the absence of other factors, should be dominated by the following:

  • does the compiler/interpreter easily and correctly identify syntax/type errors in your code
  • does the language support local variable scope so that the software principle of low coupling

Learning a computer language is the easy bit. The tough part is maintaining code.

I don't know the specifics about C# or VB.net but I would presume C# offers the best of both.

PP
A: 

Both have pros and cons.

I think C# is the more common language as it's syntax looks very similar to other popular languages including C++, Java, and many more so when searching for code examples it will be easier for you to find and understand even code from a language you're not fluent with.

Also, in today market there are many more C# jobs than VB.NET.

Now ask me personally,
I like VB.NET (VB10) way more than C#, it covers all the C# features and has some crucial features C# doesn't have (XML literals, Strict Off, type cast built in the language and more).

Even I have more experience with C# than with VB, and even vb is indeed more verbost with its syntax, it's not strict as C#, in VB, for example, you could write (don't! never!):

Dim x As Integer = "5"
Dim b As Boolean = 0
Dim s As String = b

And many more, and it's OK with the compiler (and remember that this is not a cast but a conversion!), in common VB syntax you don't specify type and you rely on type inference (Dim x = "String", no "As String") and many more examples that is caused by C#'s strictness, which by the end makes VB even less robust, maybe some wouldn't agree with me, and maybe I am not 100% right, but think about it, there is a point.
And I am telling you all that as an experienced C# and VB dev, for me, both are just the same language, you can do with each one the same in either way.
But again, that's my personal POV.

So bottom line, if you want to develop your own projects or if you're a lazy programer that wants the code do more for you (casting?), consider VB.NET (also then consider that the code-examples), otherwise (if you wanna get hired) learn C#.

You might also want to take a look at Comparison of C# and VB.NET at Wikipedia.

Anyway, for COM and interoperability, VB is way better, for example consider these two lines (each line is amazing for itself):

Dim xlApp = CreateObject("Excel.Application", "\\MyServer") 'Returns Object
Dim appVersion = xlApp.Version 'Note that there is no need for reflection!

Although in the new C# this can be done with dynamic, it's still much more robust.

Shimmy
A: 

(Dissenting opinion)

Case for VB.NET

- The code window dropdowns

Lists every control on your page and allows you to generate an event handler. No such construct in C#.

- Handles [Event]

Instead of putting a reference to a method in some remote place, you can place a "Handles" on an event handler sub.

Private Sub btnOne_Click(...) Handles btnOne.Click

This helps greatly with code maintenance, as you can see at a glance what objects are referencing an event handler.

In C#, you have to either add a reference in an initialization function or change your handler to protected and add a reference in your page.

- Partial namespaces

If C#, if you want to use an object in a namespace, you either have to type it out fully, starting with "System." or you have to add a "using" statement at the top for every full namespace you want to use.

In VB, the "imports" statement gives you more control over how your code looks.

For example, if I want to use the Page object in C#, my only choices are to type the entire namespace System.Web.UI.Page, or add a using statement for System.Web.UI. In VB I could use Web.UI.Page, or I could add an Imports for System.Web and then just use UI.Page.

With more control over namespaces, I can improve the portability of my code by leaving just the right amount of namespace information to properly identify objects.

See this great article about it here.

- Option Infer

When declaring a variable, you have to list the datatype twice in C# vs once in VB.

VB Example...

Dim dr = DirectCast(sender, System.Web.UI.HtmlControls.HtmlGenericControl)

C# Equivalent...

System.Web.UI.HtmlControls.HtmlGenericControl dr = (System.Web.UI.HtmlControls.HtmlGenericControl)sender;

Both versions are strongly typed with no runtime late binding.

Conclusion

I would recommend starting with VB. You only need to know enough C# to convert your code back and forth, and put it on your resume if you have to. You can always use a code-converter like this one (Developer Fusion) to convert samples. DO NOT use VB-Only classes and methods. Anything from the Microsoft.VisualBasic namespace should be off limits). Instead use System classes. You want your code to translate easily.

Carter