28
votes

To me, Visual Basic seems clumsy, ugly, error-prone, and difficult to read. I'll let others explain why. While VB.net has clearly been a huge leap forward for the language in terms of features, I still don't understand why anyone would choose to code in VB over, say, C#.

However, I still see (what seems to be) the vast majority of commercial web apps from "MS shops" are built in VB. I could stand corrected on this, but VB still seems more popular than it deserves.

Can anyone help answer any (or all) of these questions:

  • Am I missing something with VB? Is it easier to learn, or "friendlier" than C#? Are there features I don't know about?
  • Why is VB/VB.net so frequently used today, especially in web projects?
10
  • 4
    How do you know what commercial Microsoft web sites were built with?
    – samjudson
    May 26, 2009 at 8:58
  • 30
    "Why is VB/VB.net so frequently used today," This is a bit like asking "Why are mules/trucks so frequently used today in transportation?" May 26, 2009 at 9:04
  • 2
    Just for posterity, I stand (sheepishly) corrected. VB has a community of very loyal users, which says an awful lot.
    – aaaidan
    Sep 2, 2009 at 3:34
  • 5
    this question should be deleted.
    – AMissico
    Sep 14, 2009 at 12:46
  • 25
    Do not delete this question. It’s bad and prejudiced and subjective but it quite often occurs and can serve as a reference. May 25, 2010 at 16:33

22 Answers 22

46
votes

VB can be used to make GUI's (pronounced gooey) to track IP addresses. This is often used in crime solving.

7
  • 1
  • 4
    Wow. Just. Wow. That just made my day totally awesome.
    – aaaidan
    May 28, 2009 at 14:22
  • 1
    omg wow...omg wow.
    – Jeremy Child
    Feb 16, 2010 at 9:49
  • 2
    I'll never look at CSI the same way again. May 25, 2010 at 21:56
  • 3
    Zoom in.......ok enhance.
    – user6791
    Mar 17, 2011 at 13:28
42
votes

I think that it depends on where you come from. When starting out as a programmer, I think that VB might be easier to read than C# for instance, since it relies more on words than symbols, which makes it easier to take in for regular people.

I was a VB programmer for many years and when .NET came I still worked in VB.NET for the first couple of years (didn't really see the point with C#). Now I have a few years of C# behind me and I sometimes find that VB.NET code takes a bit longer for me to "decode" than C# code does. Possibly because it relies more on words than symbols for some contructs...

5
  • 5
    You are describing my situation exactly as well.
    – Ruben
    May 26, 2009 at 9:23
  • 6
    Same here - VB.NET code is full of "noise" when you look at it from a C-style syntax perspective. No offense to any VB-developers. Just the way it feels when you go from C# to VB.
    – Glytzhkof
    Oct 13, 2009 at 19:45
  • 2
    agreed, I cannot stand VB.NET - the syntax is like a story... and yes I have had to use it constantly for months, it drove me crazy, I love C# syntax. May 25, 2010 at 16:32
  • 2
    C# programmers aren't regular people?
    – user4595
    Sep 13, 2011 at 14:11
  • @rightfold Nope. VB.net programmers are also not normal. VB.net programmers are more awesome than regular people and for C#... no comment. =D VB.net RULES!!!!!!! Jul 15, 2013 at 20:17
27
votes

Below I've just copied my answer to another thread:

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.


That said, I've got to admit that VB becomes more and more encumbered by its syntax. The latest hype seems to be Linq queries parametrized with lambda functions and I readily admit that this makes many things simpler. Unfortunately, VB's syntax for lambdas is simply too cumbersome to compete with C#. Just consider how bloated a call to Parallel.For looks like in VB – compared to C#, where it looks natural. IMHO, the VB design team has gone in the wrong direction here, favouring conservative consistency over readability.


To answer your subjective accusation:

To me, Visual Basic seems clumsy, ugly, error-prone, and difficult to read.

You're certainly entitled to think so but as Marc has said below, you'll find it difficult to argue this objectively. I definitely can cite a number of C syntax elements which are objectively more error-prone than anything existing in VB. In fact, VB syntax has been developed to prevent such sitations explicitly.

“Clumsy, ugly … and difficult to read” are all qualifiers that can be tagged on to nearly all languages that you're unfamiliar with. Simply put: the uglyness is a direct consequence of your unfamiliarity to the language.

Knowing a language well means recognizing patterns in code. Well-written code will by virtuel of practice appear elegant, while bad (slow, error-prone) code will appear ugly. It's as simple as that.


One last remark: The articles cited by you contain several inaccuracies and outdated information. As sole justification for a highly subjective and emotional discussion they aren't very well suited.

12
  • 4
    Blake: yes, full points for Ruby. Finally a language doing it right. Python also scores highly with me. Still, I'm partially dissatisfied by all existing syntaxes. May 26, 2009 at 9:15
  • 2
    Ruby sucks :P ... now that I have that out of the way... the real reason for the majoy syntax differences between the keyword based the braces comes down to the easy of writing the parser. I used to be a huge VB (BASIC in general) fan but since I have moved to C# I find it much easier and faster to work in. May 26, 2009 at 17:45
  • 4
    Why braces? Because they visually demarcate a block of code, if used properly. Yes, I realize indentation in VB does this too, but braces do this with greater clarity IMO. Semicolons make things easier for the compiler (just ask the VB compiler team about this). I find casting in C# highly intuitive and compact. And there is a variable declaration keyword: var May 25, 2010 at 18:33
  • 1
    @Robert Harvey: 1) VB uses keywords to denote blocks, not indentation. So much for clarity. 2) About casting, C++ correctly chose to deprecate C-style casting a long time ago because it’s too visually inconspicuous (not a good thing; a cast should stand out, as it introduces changed semantics and potential weaknesses of the type usage). 3) No. I meant a syntactical hint preceding every declaration. var int x comes to mind. All other statements and blocks are introduced by dedicated keywords, why not declarations of variables and methods? Fie. Inconsistent and ugly. May 25, 2010 at 19:06
  • 4
    @Konrad: I will admit it took a little getting used to at first. Part of the philosophical difference may be that I no longer think of my programming language as a variant of English, like I did when I used to program in VB. Moving to C# has made the programming language I use somewhat more symbolic (and succinct), without being too opaque. That symbolism has allowed me the mental freedom to think more conceptually about things like object orientation, message passing and lambdas. May 25, 2010 at 21:11
15
votes

To me, Visual Basic seems clumsy, ugly, error-prone, and difficult to read.

To me, English seems clumsy, ugly, error-prone, and difficult to read, especially written by people who have poor grammar, poor spelling, reckless disregard for capitalization and punctuation, and no sense of how to spatially and mentally organize their thoughts.

It's not just that Visual Basic is difficult to read or clumsy because of the syntax of the language, but it's usually so because the programmer isn't really good at expressing one's own thoughts:

If blah = 10 Then If stuff = "foo" Then t = 1 + k: s = 42: dostuff21

Right, that's horrible. But it's not particularly difficult to write horrible code in other languages either. When written correctly, it would make a lot of sense even if the code is written in VB:

If SelectedType = 10 And UserName = "Foo" Then
    CurrentUsers = CurrentUsers + 1
    UserConnectionID = 42
    PerformUserOperation
End If

At least that's more readable and understandable. It's still BASIC. It really comes down to the ability of the programmer to clearly express his/her intentions by formatting code in a easy to read manner, using well-named identifiers, and paying attention to writing understandable code.

That said, I haven't touched Visual Basic much since the VB3 days, (hence the example with "old" syntax) but just because a language can be abused does not mean that it can't be used correctly to write fairly robust code. Sure, there may be some deficiencies, but approaches devised to getting around those problems also shows one programmer's skills over another.

(Indiscriminately spraying On Error Resume Next comes to mind as a not-so-good way to get around the deficiencies of the lack of exceptions in VB back in the pre .NET days.)

13
votes

Most of your argumentation against VB is only applicable to VB-Classic (second link) or based on faint or obsolete arguments

  • Even in VBC, you won't use GoSub ... Return etc.
  • What's wrong with static? C++ supports this too.
  • VB10 introduces implicit line continuation (you don't even need redundant semicola like C#)
  • The different cast functions exist in C++ and C# too. C#'s (object)(expr)-Cast-Syntax and object as type are even more confusing and inconsistent.
  • What's bad about with? You can create nested tree structures in a very intuive way which is not possible in C#.
  • Event-Handling in VB is much more elegant than in C#. You can introduce and handle events by a single keyword (WithEvents) without having to initialize delegates, eventhandler-procs etc. This makes GUI-programming in VB much more confortable and you don't need to generate event-code by the designer.
  • Optional parameters get introduced into the new C# - Hence they seem to be good.
  • VB.NET has both strict and shortcut-boolean operators.
  • You do check for syntax errors at compile time unless you run VB like a script-language.
  • End If is more helpful than just }. When having complex syntactical structures all the curly braces are just confusing whereas a concrete End ... assists you in determining which block hasn't been closed.
  • XML Literals - XML script is now a part of the code, fully support by intellisense.

All in all, there are just a few objective differences between VB.NET and C# apart from the syntax. E.G: GUI-designing is much more efficient in VB due to a better event system and a better IDE whereas e.g. algorithms can be expressed better in C# because the syntax is conciser.

The rest is just a question of your personal style. C-Style programmers feel comfortable with C#, VB (or maybe Pascal?)-Style programmers use VB.

But the word-based, more explicit VB-Syntax may be easier to read for beginners than all the symbols in C. Compare:

If (a < 15) Xor (b = 2) And Not Condition Then

to

if ((a < 15) ^ (b == 2) && !Condition())

This doesn't mean one language is better than another.

Edit : -----------------------------------------

To the argument VB would be error-prone. When you use Option Strict On it's as strict as C# but doesn't allow us to make such mistakes:

// VB would initialize with zero (C/C++ doesn't)
int countZeros;
// No confusion with loop bounds with For x = 1 To Length
for (int i = 1; i <= length; i++) {
    // Never confusing == with = 
    if (data[i] = 0) 
        countZeros++;
}
4
  • 1
    C# would give a compile error for not initializing countZeros (in local scope) and for assigning a value to data[i] in the if statement. I know you referenced c/c++ in your comment, but I believe the OP was comparing VB to C# :)
    – ebrown
    May 26, 2009 at 17:42
  • 1
    For my opinion, VB10 beats C#10 big time! May 25, 2010 at 16:24
  • I like all languages: LISP, C, VB, PHP, you name it.
    – Geoffrey
    Aug 18, 2011 at 14:28
  • +1 and I would add that VB's Switch statement isn't useless like C#'s.
    – Joel Brown
    Feb 23, 2012 at 13:05
12
votes

Historically the VB development environment was a quick and effective way of building certain types of applications (e.g. GUI apps). That led to it being a very popular choice. I think VB was the most used language during its heyday (e.g. VB6).

With that kind of installed base, it's hardly surprising there is still a lot of work going on in it.

1
  • 2
    +1 afaics VB6 and especially the VS IDE provided a (very) low barrier to entry which created a generation of new coders, with all the problems and possibilities therein
    – annakata
    May 26, 2009 at 10:11
7
votes

It all started before C# existed

Back in ~ 1999, we had Visual Studio 5/6. If you were a Independent Software Vendor or corporate using Windows and needed an application written which could, e.g. track employee's time spent on projects, you had a few options:

  1. Forms in Visual Basic.
  2. MFC, ATL or Win32 in Visual C++.
  3. Forms in Access 97/2000.
  4. ASP website.
  5. Java applet.

At the time, we were just before the Dot-Com bubble burst, so anybody who was any good with (4) or (5) went off to negotiate stock options at whatever amazing dot-com they were attracted to.

(3) had issues with locking and overall scalability, but I saw a lot of Access-driven solutions which would shell-out to run support functions as needed.

So that leaves us with VB and VC++:

The Forms editor in VB was, at the time, excellent for productivity. You could drag-drop your components - not just buttons, labels and text boxes but the full 'OLE controls' toolbox of reusable components like clever Grids, Excel sheets or IE instances. The wire-up was done behind the scenes - everything was object-like and you just double-clicked things to add event handlers. This was very much harder in Visual C++. As a member of the Visual Studio developer support team at the time, I can remember how Visual Basic support calls were mostly about which component was best to use or how to optimize their application in certain ways. It was almost never 'how do I make an application with X, Y and Z user interface features'.

Building a rich UI in Visual C++ was a different challenge. Although there was Visual editor support for dialogs and SDI/MDI forms, it was fairly limited. The support for embedding OLE Controls (ActiveX) into MFC or Win32 was a black art, although a bit easier in ATL. Wiring up simple things like resize events or owner-draw was pretty painful, let alone the Connection Points required for custom events in components.

Yes, VC++ had the execution speed, debug-ability and flexible frameworks/libraries/UI options, but the IDE support couldn't cover all that ground so addressed the most common operations with things like Wizards, comprehensive MFC class hierarchies and 90-days/2-free-incidents support lines.

IIRC, the application packager that shipped with VB could package up your app, the VB runtime and latest common controls DLLs and supply you a standalone EXE installer that you could put on a CD and get to customers. None of this 'which msvcrtXX.dll and mfcxx.dll do you have installed?', which plagued the MFC developers.

So, for reasons of time-to-market and rich user interface, VB got a very big following.

When Visual J++ and Visual Interdev hit in VS6, it was clear that the Visual Basic IDE had won some battle over the Visual C++ one, which was fair IMHO. It was no surprise at all that Visual Studio .NET had a VB-like forms editor for the new COOL C# language.

The new Java/C/C++-like language coupled with the UI designer enjoyed by VB people for all this time gave a new migration path for the C++ people who were now done with MFC/ATL/Win32. For the VB 3/4/5/6 people who didn't like the lack of 100% backward compatibility in VB.net, this offered an opportunity to learn a new language in a familiar environment.


The reasons that VB was such a comprehensive product likely has something to do with the origins of Microsoft, with Basic being their flagship developer product, but I don't have any citations at this time.

6
votes

However ugly any given language may be the reasons for sticking to it usually boil down to: it is very expensive to scrap a huge code base and the fact that the developers already know the language, makes it cheaper to use than other languages.

0
6
votes

VB.NET is easier to learn, you are right, and it's easier overall than C#, in my opinion. It's the first point why VB is so popular. Another one, and the biggest point, I think, is that there is a huge conmunity of developers who worked with VB 6 and older verisons of this language and it's easier for them to develop applications with VB.net than to learn a new language.

6
votes

As other have said, your aesthetic judgment over language syntax heavily depends on what you knew before. For a more than a decade, it looks like it has been a C-look-alike contest, with curly braces for "blocks", "->" for indirection ( perl, php ), parentheses for function call arguments, // for comments, and a semicolon at each end of line. Some people even thought that thanks to this 'pensée unique', if you know a language, you know them all, which is indeed ridiculous. But this instilled the idea among C++/Java people that's the only right syntax aesthetic and anything else is trying to clone COBOL.

A few years ago I switched to ruby, and now python, and I can't stand any more ugly semicolons, curly braces, and other garbage meaningless characters. The source code is meant to be read by humans. When I gave a try to visual studio, I chose VB over C#. I suspect some programmers to chose C# just to "look serious" with its java-like syntax, but come on, the very same features are there ... give your eyes a rest.

4
votes

Well, if you're talking about .NET, there's one really easy one I can think of:

VB.NET's editor in Visual Studio is much better at catching syntax errors than C#'s.

While C#'s editor got a huge improvement in VS2008 SP1, there are still some syntax errors the editor doesn't pick up on until you attempt to compile the program.

2
  • That background compilation is exactly what made editing large VB projects in VS2005 very very slow. In any case, that's what ReSharper is for ;)
    – Lucas
    May 26, 2009 at 18:27
  • It isn't just the background compilation, the auto-format and code cleanup tools fix a lot of things before you even move off the block to trigger the compilation. This is a HUGE time saver in vb compared to c#
    – Bill
    May 16, 2011 at 21:29
4
votes

Much of VB popularity originated in a time when VB's tooling was much more friendly than other available languages. The "classic" VB offered an easy way to build Windows applications without having to learn the guts of the Win32 API or bother with manual memory management. The barrier to entry for beginning programmers was much lower with VB than C++, so a lot of folks cut their teeth with VB.

These days, I think VB one advantage over C# is familiarity for those who have worked with VB through the years. Another advantage is that VB code is easy to read because of the tendency to use keywords instead of punctuation symbols. As someone who works in VB, Java, C, C#, and Python, I find that VB is the easiest language to jump back into when reviewing code that I wrote years ago. The syntax is more verbose, which often makes it easier to read code, and Visual Studio has always done a great job of formatting VB code to clean up the formatting as you type so that code is consistently formatted (regardless of the author's sloppiness).

As a side note, I find Python to be extremely easy to read & review for similar reasons. In Python, the formatting of code is enforced by the interpreter rather than the IDE, but the end result is the same. Python also favors keywords to punctuation, though arguably less so than VB.

3
votes

It would be hard to argue that it is any more-or-less "error-prone" than any other language. I also doubt the point re "vast majority of commercial MS web"; from what I've seen, C# is by far taking the lead for .NET development (with .NET being the flagship tool in the MS stack for things that aren't device drivers etc).

3
votes

One advantage VB.NET has over C# (which will disappear with C# 4), is default and named parameters, a very nice thing to have when using VSTO.

3
  • And, for that matter, "dynamic" - giving C# something comparable to VBs existing late/dispatch binding. May 26, 2009 at 9:11
  • 1
    This so-called advantage has always been problematic to me - my read on that is that C# has overloads which are a safer way of achieving the same practical result.
    – annakata
    May 26, 2009 at 10:13
  • 2
    the downside of overloads is they are more diffcult and confusing to maintain when you jsut want to set a few default values. You can end up with complex chains of overloads which compiler into nested method calls instead of being directly resolved to the method by the compiler. May 26, 2009 at 17:47
3
votes

VB/VB.NET belongs to RAD (Rapid Application Development) category. You can develop applications with just drag-drop controls from toolbox and less code.

3
  • You could say the same thing about the ASP.net + C# combo, no?
    – aaaidan
    May 26, 2009 at 9:15
  • Yes, most Visual Studio based langauges do.
    – NinethSense
    May 26, 2009 at 9:17
  • Well, at the age of VB (not .net) there was no C# etc. So VB was the only GREAT thing that time. Later VB users migrated to VB.NET. VB <> VB.NET anyway.
    – NinethSense
    May 26, 2009 at 9:18
3
votes

Well, I think you have to differentiate between classic VB and VB.NET.

I feel that VB.NET is not very popular, but Visual Basic "Classic" still is1 The reason is that it is VERY easy to create Windows app. Compare this to a Windows app in C++/Mfc, which was almost the only alternative at this time.

For the same reason Delphi was very popular once upon a time.

1
  • I agree that VB.net is not as popular as classic VB. Some devs who couldn't migrate their code base to VB.net may have defected to C# instead. Mar 17, 2011 at 14:33
3
votes

VB is very verbose and easy yo get used to as compared to C# which is case sensitive. For a novice programmer its the best starting point.

3
votes

To name a few:

  • ease of use
  • familiar name (basic was one of the first popular computer programming languages)
  • don't underestimate microsoft marketing
3
votes

I think part of the reason is because old asp programmers going into .NET as I have done are very familiar with VB already because VB script is the language ASP classic used for the most part. I felt it less time consuming writing in VB in .NET because I already knew how to speak VB. VB is also less of a crybaby than C#. I can read/write in both but I prefer VB because it's easy to make friends with if you're a new programmer.

2
votes

I work in an environment where we use both. We have switched to C# in favor of classic ASP and VB. In my opinion there are no deal breakers between the languages. For most projects you can do the same work with both languages. Now I do share your view on error prone and I also find VB to be cluttered (for no reason).

As others has mentioned, VB is very simple and historically you could build projects very fast. This lived on in web development (which is fast developed), but I think when people realize that C# is just as fast developed, VB will fade out. Another reason I think it will fade out is that everything else you code in (CSS, JavaScript) when making web applications looks more like C# than VB, so it makes sense to use C#, even for beginners.

2
votes

I personally like the way events are attached in vb.net with the 'handles' keyword ... The IDE /Visual Studio/ is also more responsive when dealing with VB and handles automatically most of the end-ifs and the like ... C# is of course much more consise and clean (IMHO, I've worked with both quite a bit)

1
  • I prefer subscribing to events myself, not all the magical behind-the-scenes stuff that goes on with "Handles" and the VS designer.
    – Lucas
    May 26, 2009 at 18:26
2
votes

As of the 4.0 framework, there are only a small handful of things VB lacks compared to C#, and the reverse is true as well. Namely:

  1. The most notable is that VB.NET doesn't have the Yield keyword, but it is coming soon to VB.NET with the new async framework.
  2. There's no unsafe keyword. I've never found it necessary, but surely there are some people who have.
  3. There are no multi-line strings. Multi-line strings are accomplished by using + (or the legacy &) operators across lines. Or, they can be accomplished by using the XML literal syntax: Dim s = <s>My string... multiple lines...</s>.Value. It's not pretty, but if you're not picky and really want multi-line strings it works. And, you can do string interpolation with it using <%= myVar %> syntax which is nice.
  4. There is no variable scoped equivalent of dynamic. Dynamic variables have been around in VB for a long time with Option Compare Off, but that is file scoped, so it's not as good as dynamicbecause dynamic limits the scope to only the variable declared that way.
  5. VB lacks a terse lambda syntax. Lambdas are there, but you have to use Function(x) or Sub(x).

Some features VB.NET has that C# doesn't:

  1. XML literals, which are handy for all sorts of things, not just XML.
  2. Case-insensitivity in a language is the cat's meow. Not many other languages allow it, but what a difference it makes in the speed of coding to never have to hit the shift key when you're typing and have your code just auto-format the way you want it.
  3. The often unnecessary Select clause can be omitted from Linq queries.
  4. The Nothing keyword is much more useful than null in that everything (even value types) can be set to Nothing and you get the default. There's no need for the default keyword.
  5. VB.NET is constantly compiled in Visual Studio so you see errors right away. No hitting CTRL-SHIFT-B all day long like in C#.

My shop does MVC3 with Razor using VB.NET and once you get over the (mostly unfounded) prejudices, it's actually a very nice language to use. It's not really more verbose than C# as many claim (except in the case of lambdas), and it's pretty much feature-for-feature parallel with C#. I've found that most people who are haters have not really coded in modern VB.NET for any length of time.

3
  • As for me, VB.NET is too verbose. You have to manually print lots of boilerplate code, and ReSharper doesn't help, actually. I have been coding in C#/VB.NET in paraller for 3 years already.
    – Hedin
    Aug 9, 2013 at 10:16
  • VB is indeed horizontally verbose due to the longer keywords. Although you don't often type them, because the IDE puts them in for you. But IMHO C# is often vertically verbose due to the curly braces. Some other advantages of VB: avoid debating the brace style because there's only one style in VB; (tongue goes into cheek) avoid developing overmuscled right little finger due to endlessly typing semicolon and brace boilerplate.
    – MarkJ
    Aug 9, 2013 at 11:30
  • 1
    @MarkJ: I find it interesting the way C# proponents criticize AndAlso [not withstanding that when spoken it's shorter than "double-ampersand"] but ignore the fact that an If-Then/Else/EndIf takes three lines plus the controlled statements, while the C# equivalent would take at least four and possibly six, depending upon brace conventions, unless one writes } else { as a single line.
    – supercat
    May 6, 2014 at 21:57