views:

2361

answers:

27

I'd spent several years in the day job with VB.net. Out of work I'd flick between it and C# for different projects/hobbies.

Now that the day job is almost fully C#, VB.net is starting to look foreign and a little removed. Does any beg to differ?

Should I keep my delve back to VB.net for any particular scenarios? I mean, does it win over C# in any departments?

+7  A: 

there are still a few language features that vb.net has that C# lacks, and vice-versa. It doesn't hurt to keep your hand in, but if you're more comfortable in C# there's no compelling reason to switch back and forth

Steven A. Lowe
+23  A: 

VB.NET is better in a few cases at the moment:

  • If you want to include an XML literal
  • If you don't like case sensitivity
  • If you need late binding

C# 4 will fix the last one, but I doubt it'll ever change with respect to the first two :)

There may be other significant differences, but if there are I'm not aware of them.

Jon Skeet
Exception filters, maybe? Never really needed that, though.
Alan
Why would C# never include xml literals?
Quibblesome
@Quarrelsome: They're a very specific technology, and C# doesn't tend to do those. It prefers to be a smaller language than VB - look at how many of the LINQ operators are supported directly in query expressions in VB vs C#, for example. C# has a very high bar when it comes to feature inclusion.
Jon Skeet
What I *could* imagine is some language construct which could be used to easily build XML - but could equally be used to easily build other data structures.
Jon Skeet
Ah I see, thank you! I'd certainly appreciate such a feature seeing that any unit tests on custom xml parsing requires an additional deployment object or painful entry of escaped \" in an xml literal.
Quibblesome
Late binding? All of the VB.NET I've ever written uses Option Strict On :)
Juliet
I have always felt that late binding is a significant differentiator, and yet Option Strict On is the norm when it comes to VB.Net code. At this point in the evolution of VB, I would think that its proponents would be shouting this out from the highest elevation possible. It seems that most folks that care about this have capitulated...it will be in the next rev of C#. On a sad note, I suspect that many VB.Net programmers never realized this power was available to them long before C# "got around to it"
Todd Stout
Why is it that VB folks accept Option Strict On as a "Best Practice"?
Todd Stout
Most of the time dynamic typing doesn't add much value (in my view) and VB isn't a *fully* dynamic language: it can *call* members dynamically, but it can't *react* dynamically as far as I'm aware (before the DLR, this is). When you don't really *need* dynamic typing, static typing has a lot of benefits, principally performance, Intellisense and compile-time error detection.
Jon Skeet
+3  A: 

I started using VB about 10 years ago and at some point switched to VB.Net. Since switching to C# I haven't really wanted to go back. I haven't had a need to use any of the VB features that C# doesn't have.

I still do go back to VB sometimes because we do have some code written in it. I find thought the more I use solely C# the harder time I have going back to VB.Net. The bigger problem thought is when I have to look at VB 6.0 code, then I just miss .Net C# or VB.

I do agree that the more C# I do the more foreign VB looks to me.

wonderchook
+4  A: 

If your day-to-day work uses programming languages X and Y, and the number of months since you last used Z is gradually increasing, then Z will gradually look more foreign. In your case Z is VB. At least it is this month.

If writing new apps that target systems where .Net is installed or will easily be installed, I prefer C#. If writing new apps but who knows if target systems will easily have .Net, I prefer C++. Sometimes I have to write a combination even if .Net is assumed.

If modifying old apps, it's almost always better to keep them in the language(s) they're already using.

Windows programmer
+2  A: 

I went the same route as you, and now I can't even imagine going back to VB. The main thing I prefer now about C# is the same thing that kept me from trying it initially: the rigidity of the type system. Once I got used to having to explicity cast things all the time, an entire category of errors that I used to make all the time (thanks to Visual Basic's core apathy towards whatever the type of a variable happened to be) vanished.

Plus I just feel more like a real programmer if I'm typing lots of brackets.

MusiGenesis
So why not use `Option Strict`?
Konrad Rudolph
As I told the consultant who had been brought in to review my work: "Because I can code faster without it!"
MusiGenesis
+2  A: 

Regrettably, I have been forced to several times. VB is still extremely popular among business programmers, and many do not want to learn C#. Many will insist on VB because they are monolinqual, and they don't want to become bilinqual to figure out what you are doing.

My main complaint about VB is the culture of Option sloppy. Option sloppy is defined as: Option Strict Off Option Explicit Off Option Compare Text

It is very unfortunate that so many VB programmers like coding in this manner.

However, VB.NET is the clear cut solution if you need to do heavy-duty XML processing and generation. XML Literals are the one utterly killer feature of the system.

+50  A: 

Does any beg to differ?

Well I do, of sorts. I develop in both VB and C# on a regular basis, most of my money-making has involved C#. Personally, I prefer VB for most (but not all … lambdas!) work. I can't really name any hard advantages apart from those outlined by Jon. Actually, Herfried has collected a few on his web site (in German!) but they are rather technical.

The thing that really bugs me about all C-related language is the stupid syntax. This is purely cultural but as someone who does most of his professional work in C++, and being quite proficient at it, I still absolutely hate the syntax. And not just C++' cute little quirks. No, the whole package. Why braces? Why semicolons (perhaps the stupidest decision in all of programming history)? Why the stupid C-style cast syntax? Why is there no keyword for variable declaration (actually, this is the stupidest decision)?

There are just so many things that really make me sad and angry. VB is no saint, its language has huge drawbacks. But nothing compared to what I've said above.

I realize that most of these statements need justification but I put forward that this is only because we have become so used to them. Additionally, here isn't the right place. Suffice to say that C#'s syntax, while being its main advantage over VB, is also its main disadvantage.

I don't prefer VB because of the My namespace, I don't prefer it because of XML literals, I don't prefer it because of weak typing, I don't prefer it because of optional parameters, or because of the much better switch statement. No, I prefer it because of the syntax.

Whew. Now someone please hand me the “subjective” tag.

Konrad Rudolph
@Konrad Rudolph good rant, just ran out of votes but i would have voted more times than than a texan republican if i could. subjective yes but also particular to how you might program. i mean has anyone been talking about vb.net goodies coming in new releases?
dove
I totally agree with you. You got my up vote.
Eric Haskins
I for one absolutely love the braces and semi-colons and although I can operate without them in other languages, its always easier to open up some well braced and formatted C-like code and read it than it is to open up a 'well-formatted' script for Python.
Dalin Seivewright
+1 I programmed in C# for years, then I moved to VB.NET for work and I totally agree with you
marco.ragogna
+1 You are so right about the braces. Code Complete (the bible) says VB has perfect block formatting, but braces are flawed.
MarkJ
Well, that's just a question of taste... I for one hate VB.NET syntax, it makes it look like a "toy" language. Braces make the code structure clearer, and semi-columns clearly separate instructions, even if you split them on several lines (in VB.NET you have to add an underscore at the end of the line, which I find awful). VB.NET indexers look like method calls. VB.NET keywords are too verbose. Wow, I really hate that language ;)
Thomas Levesque
C-style languages also show great influence by the US keyboard layout. Nearly every special character is easily accessible there, but in other languages—not so much. I started programming with BASIC and that language was definitely easier to *type* alone on a German keyboard without finger-breaking acrobatics with AltGr+7 to type `{`. By now I'm using US International but I do partially put the blame for that on languages that over-use braces and other things that are simply hard to reach on any non-US keyboard layout (C, C# and LaTeX were probably the languages that drove me to that).
Joey
@Thomas, for your information, VB10 has no more _ read http://blogs.msdn.com/vbteam/archive/2009/03/27/implicit-line-continuation-in-vb-10-tyler-whitney.aspx
Shimmy
+3  A: 

I'm interested in seeing what the new VB.net 10.0 is going to be like. Removal of the ugly "_" line continuation character looks quite welcome.

I believe with the current version (9.0 + 3.5 SP1) implicit typing has removed a lot of the "Sloppiness" that lazy VB programmers are slapped for.

I'm a VB programmer who started by learning C and C++. Needless to say when I discovered VB inside of Access I found it very hard to go back to C. Reason being vb in access had a better development IDE ( I was using some borland IDE for C++ which left much to be desired) and this was in 1997 and "Visual" IDE's where only hinted at.

Sadly i'd be quite lost without intellisense when trying to explorer the .Net libraries.

Would I like to learn C#? sure. Generally speaking I can read it without any problems, so i'm sure it would only take a month or two to become fluent.

Maybe next project I will take the plunge!

What does C# have that VB doesn't? Much better refactoring tools!

Harry
Took a while, but I have taken the plunge! (CCR and Yield being the tipping point) No regrets yet
Harry
VB has a better thing for yield, the Static keyword.Read http://stackoverflow.com/questions/97381/yield-in-vb-net.
Shimmy
+12  A: 

I work mostly in VB.NET in Visual Studio 2008, but I'm reasonably conversant with C#, having started out in .NET with the latter.

Recently I worked on a contract using VS 2008 and C#. It was easy enough to switch languages.

But I was horrified at the poor pre-compile support and intellisense.

People often argue that C# is superior to VB because it is less verbose. With the advanced intellisense you get with the VS08 VB IDE, however, the amount of typing is greatly reduced.

And reading code is a lot easier, since the verbosity makes the difference between different code-block types (End If, End Select, Next, etc) very obvious. You don't have to look up through a bunch of nested brackets (whose nesting is likely to be broken if there are any syntax errors) to work out what's going on.

Feature for feature, VB and C# have been converging. With Intellisense, the amount of typing you have to do with each has also been converging, so it's very much more simply a style choice nowadays.

ChrisA
Precompiling and Intellisense has gotten better in each version of C#. But it's true, in VB those two things are still ahead, and will probably remain ahead in each version. C# finally got precompiling in VS 2008, but VB jumped ahead again with Intellisense filtering.
Kyralessa
+2  A: 

I have recently had a requirement to encrypt data, push that data into an excel file and then decrypt the contents using vba.

It was FAR easier to write equivalent Encryption/Decryption methods using VB.NET/VBA than C#/VBA

I would assume many functions that need VBA equivalents would be easier to write in vb.net

Causas
Presumably it was the "Push into Excel" which was actually easier - the encryption/decryption should be just as easy in C# as VB.
Jon Skeet
+9  A: 

COM Interop (for example with Office) would be one thing where I'd see VB.net at an advantage over C#.

Clarification: That is true at least when comparing VB9 to C# 3.0. C# 4.0 will introduce some new features to make COM a bit "nicer" to use (Optional Parameters, something only VB supports so far and that causes C# Interop to make use of Type.Missing more than desired...)

Michael Stum
Somebody's been watching the PDC2008 videos :)
tsilb
+11  A: 

I switch back and forth daily. Because of this, I don't find one language looking more "foreign" than the other.

What does catch me out sometimes is the IDE behaving differently. For example, Visual Studio with C# doesn't have a background compiler that displays Intellisense errors in real-time.

I also find that the VB "good enough" programming culture is different to the C# culture, and this can sometimes lead to surprises when reading somebody else's code.

As for your question about where VB "wins" over C#, here are some VB features that I found useful, and that are not present in C#. I don't think these are actually "wins" as such, just useful in some circumstances:

  • Background compiler that displays Intellisense errors in real-time in the code editor.
  • XML literals.
  • Late binding.
  • Ease-of-use of the WithEvents keyword.
  • Ease-of-use of the Handles keyword when handling multiple events in a single method.
  • Ability to map an interface method to an arbitrary method.
  • Support for optional parameters when automating MS Office.
RoadWarrior
@RoadWarrior background compiler is nice. rest are good but not shakers. btw, do you use resharper? might make those intellisense errors go and even think it is coming for c# in 2010
dove
I haven't got to grips with Resharper yet, though I've seen a demo. It's on my list of stuff to test soon.
RoadWarrior
@RoadWarrior i'd highly recommend though it is not free
dove
Isn't there a background compiler in C#?
configurator
Not in VS2005. Maybe in VS2008, I haven't tried it yet.
RoadWarrior
Ah, optional parameters - I knew there was something else :)
Jon Skeet
There's no real background compiler in VS2008 either. The service pack did add some additional semantic checking for richer error messages without the need to compile in C# but as far as I know, no real compilation is done.
Konrad Rudolph
@RoadWarrior, you mensioned •Ability to map an interface method to an arbitrary method. Can you elaborate? I thought it's a C# feature that VB lacks, what do I miss?
Shimmy
+3  A: 

I was a long time VB developer before moving to C++ then i 've started using C# and i will never look back to VB again.

My PERSONAL opinion is that Microsoft pushes C# a little more than everything else. All managed code i 've seen coming from Microsoft, excluding examples/tutorials, is C# and only C#.

I haven't found a Visual Basic .Net feature that C# lacks, up until now. I find VB somewhat verbose and syntax a little loose.

As mention before the only good reason i would use VB is if i don't want case sensitivity. Visual Basic is geared more towards being as easy as possible after all don't forget that Basic stands for Beginner's All-purpose Symbolic Instruction Code. Being easier isn't necesserly a good or a bad thing.

PS. My opinion maybe kinda biased because i really prefer the C styled syntax than VB.

For better or worse, c# is the golden child. This will soon be c# / WCF as Microsoft moves towards WCF as the standard.
Scott P
+2  A: 

I also started with VB for several years, and then move on to C#. I can switch in between them without problem. But I'd choose C# every time I can.

All the cool people uses C# anyway. ScottGu, Hanselman, Haack, I see they mostly use C# in their code samples.

Ikhwan
+1  A: 

We focused on C/C++ in school, but my first 'real' development job outside of University focused on VB. I'm now working in C#, and would not think of going back due to my initial affinity to the C-style syntax.

Whytespot
A: 

I absolutely detest VB. I think it's too verbose and unnecessarily redundant. I'm not one of those guys that tries to fit everything in a single line of code, but honestly, do I really need to type END SUB at the end of every function? I personally love the braces and semicolons.

Chris
“but honestly, do I really need to type END SUB at the end of every function?” – no, of course not. That's what the IDE is there for. So no extra typing but still a huge readability benefit.
Konrad Rudolph
It's not the typing that bothers me - it's the clutter in my code. A single like with a closing brace is far more terse and unimposing, to my eyes.
Chris
A: 

Absolutely wont back to VB.NET. I feel C# more flexible for me. I no need to type "End Sub" instead of "}"

Ervin Ter
+2  A: 

They are the same to me. The important factor is the .net runtime and the fact that they both evolve to something better and more productive.

Furthermore I live with the philosophy to learn a new programming language every year. So don't be religious.

bovium
+3  A: 

I recently attempted my first C# project. First thing that really struck home? lack of 'snippets' - sure C# has snippets, but no where near the extent of VB.

I wanted to write to the eventlog, being a lazy VB programmer (well not really) I just right-clicked... um... i don't see anything too helpful here.

Sadly, I stopped and switched back to the comfort of VB

Harry
Uh, snippet support is actually much better in C# than it is in VB.
Konrad Rudolph
Really? It is surprising how different they were, I didn't find the functionality i was expecting
Harry
I have since converted to C# is my primary language. Very hard to go back and work in VB.net!Still believe in my point though - I don't even use the snippets other than the for and foreach and property shortcuts
Harry
@Konrad, in VB, the snippets are built in, you don't have to press TAB, start writing a property and see.
Shimmy
A: 

I feel sorry for all of you! You should learn C++

+4  A: 

This is personal preference but I did C# and VB.NET, I feel a constant pain while coding in C#. Beside of common glitches pissing me off (such as case sensitivity) VS.NET for C# feels so much worse with lack of background-compiling etc. (don't know if this is been fixed/added).

Although I wish I'd love C# because almost rest of the .NET world coding on it, there so many more examples and well supported by lots of the tools.

dr. evil
A: 

I never got VB

devio
+1  A: 

I prefer C-like syntax but I'll develop in anything that is needed for the project or application I am working on.

Coentje
A: 

Something i forgot to mention is that the the father of C# is a BEST OF THE BEST language designer that i really respect. He has designed TurboPascal and Delphi that made Borland have a chance against Microsoft, back in the days. I have read some articles lately stating that he was influenced by the best parts of turbopascal/delphi, visual basic, C++ and Java before he come up with C#, if you think that he combined all the top languages and that he is consider by most to be the best language designer ever you can understand why C# is so clean and simple.

Thank you Mr. Anders Hejlsberg for such a beautiful language.

PS. Sorry for posting again but i had to tell everybody something about my last thoughts on this subject.

Sorry for the comment but I am obliged to object. Particularly to the “clean and simple” because from a language designing point of view, C# is neither.
Konrad Rudolph
(But then, neither is VB. I'm really just arguing for argument's sake.)
Konrad Rudolph
@Konrad: Well, how do you define clean and simple? Perhaps it was my introduction to programming via C/C++, but I found C# syntax much easier to learn.
Adam Lassek
A: 

Mainly using VB.NET now, though in the past its been VB6 (ouch) and C++.

Right now i'd be rusty goin back to C++ or learning C#, but i think there comes a time in your working life where you get to a certain skill level where picking up a new language, or revisiting an old one comes a hell of a lot easier.

I suppose you have to ask yourself how long you think it would take you to switch to another language and become good at it again. If its a few days or less, then maybe you dont need to delve as much into those lanaguages as you will be able to pick it up very easily further down the line.

kevchadders
+3  A: 

As someone who learned in an utterly un-typed language (PICK BASIC), I have found the rigid typing of C languages to be a royal pain in the ass. I know it depends on what you're used to, but I've written very large apps in VB and never made the types of data typing errors that others opine about so much. Maybe as a PICK programmer, I learned to keep the typing of all the variables 'in my mind' or some such thing.

Let's face it, in terms of utility and functionality, C# and VB are indeed converging. There are small differences, but by and large one can do whatever one needs to do in either language for general applications.

It's really a 'cultural' or perhaps left brain/right brain difference.

I cannot stand the syntax of C languages, and, early on (1984, Macintosh) hated the low-level memory heap crap I had to tend to with C. No programming language should force me to worry about internals unless I need to, as far as I'm concerned. And if I really am concerned, I might as well use assembler.

I like the easy readability of VB vs. C (3 pages of braces - yuck!). Of course, a well-written c program is quite readable, but it is easier to make opaque code in C, IMHO.

A language that's too verbose? Let me have it! Verbosity leads to clarity, most often, and with intellisense, it doesn't lead to carpal tunnel.

I also like Ruby on Rails, which is another language that promotes clear English-like code. C is more left brain, I think - abstruse, compact, highly symbolic. Basic is more schematic and, for lack of a better word, 'linear' to me, while also seeming more right-brain and intuitive.

I am left-handed, and would be very curious to see if there is any correlation between handedness and which language is preferred.

Samuel
A: 

I started with VB.NET 6 years ago. About 4 years ago I learned C# as well.

I need them both for work. But I love VB way more than C#; VB is a cool language, c# is too strict. coding in C# takes me much more time, and it's not because I don't know it, it's just that I have to write more code.

Besides VB has many crazy features that cs lacks like xml literals (!!), With keyword, better Select (C# switch), COM (now c# is going to have the dynamic keyword, but with all due respect, in VB it's at home) and others.

So personally I prefer VB way more, and would encourage people to go and learn it.

Shimmy