Sign up ×
Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. It's 100% free.

Why do people say that VB gives you bad programming habits? What do they mean by this?

share|improve this question

closed as primarily opinion-based by MichaelT, gnat, Dan Pichelman, Bart van Ingen Schenau, Kilian Foth Sep 16 '14 at 8:22

Many good questions generate some degree of opinion based on expert experience, but answers to this question will tend to be almost entirely based on opinions, rather than facts, references, or specific expertise.If this question can be reworded to fit the rules in the help center, please edit the question.

Related:… – bigown Nov 16 '10 at 0:57
There are VB issues which are not opinion but very bad programming habits, for example mixing classes and instances (solved in .net) or the dreaded dim a, b as integer (not solved in .net) – Zac Oct 24 '14 at 15:42

8 Answers 8

up vote 7 down vote accepted

In its old incarnations (VB6 and prior), Visual Basic was a melting pot of different calling conventions, bolted on features, and incomplete class structures and error handling.

With the advent of VB.NET, most (if not all) of those objections are gone. VB.NET is a pretty good language, and it will actually do a few things (e.g. XML Literals) that C# cannot (not without some bending, anyway).

Consequently, I declare that old Dijkstra adage obsolete.

share|improve this answer
I think you're excusing bad programmers. I spent 10 years coding VB from versions 3 through 6 and there was plenty you could do about most of it. If people didn't choose to then that's their fault rather than the language. – Jon Hopkins Nov 11 '10 at 10:02
@Jon: That still doesn't make it an ideal experience. I'd rather code in a sensible language than spend all of my time figuring out ways to get around the quirks in a marginal language. Just because you can cook with a stick doesn't mean you should. – Robert Harvey Nov 11 '10 at 17:11
@Jon: Anyway, the question is not why VB encourages bad practices, it's why people think VB encourages bad practices. And they think that because of the cruft. – Robert Harvey Nov 11 '10 at 17:51
I like your opinion – RCProgramming Nov 16 '10 at 0:49

I think this is a case of confirmation bias.

Since VBA was included with many versions of Office, many folks got started by writing macros and VBA code to get stuff done (in Excel, Access, or now InfoPath). This makes VB a first programming language for many self-taught programmers. In addition, since many programmers have no formal education, habits learned early on may be hard to unlearn.

Many of the folks complaining either:

  1. Met one bad VB programmer and therefore we/they are all bad programmers.

  2. Had to fix some critical business application written in VBA by someone who didn't understand programming (this is the source of complaints about apps written in Excel or Access, and in the future, we'll be whining about InfoPath apps too).

alt text
It's PI plus C of course.

share|improve this answer
Forgive me for editing your answer, but this comic seemed like it was drawn for it. – Rook Nov 11 '10 at 3:28
Use the magic word: "code monkey" – Ming-Tang Nov 11 '10 at 3:37
@Rook, it does indeed apply. Thank you. – Tangurena Nov 11 '10 at 3:40

There are a whole load of reasons. Off the top of my head:

1) VB was always designed as a tool to allow people to get results quickly - both in terms of learning curve and development time. While this is great in some ways the options it gave you to cut corners (which were in many cases the things which increased productivity) were too tempting for a lot of people even when they weren't appropriate.

2) It was massively popular, at it's peak the most popular language on the planet. Given that a reasonable proportion of all programmers are bad (and especially as VB did many things which increased the chance that it would have a higher proportion than average), the largest language stands a pretty good chance of having the largest number of bad programmers.

3) Some of the default settings encouraged bad practice. For instance by default variable declaration wasn't required (it would automatically come into existence the minute you used it, no need for any Dim iThingy as integer, or even just Dim iThingy as you didn't need to say what variable type it was if you didn't want to). Anyone decent turned it on (or just typed Option Explicit at the top of each module) but be default you didn't have to.

4) In the same way VB just had some unpleasant bits in the language and tools. "On Error Resume Next" (basically ignore errors) was over used, the fact that you had to use Goto for error handling and that even done well it was still a bit of a mess, the fact that there were a few too many controls that made simple things even simpler when people might have been better served actually thinking about things a bit more and coding from scratch, the fact that it was very forgiving (so to set the text value of a text box you could just use Text1 = "blah" instead of Text1.Text = "blah") which could lead to laziness and code that wasn't as readable as it could be.

5) Many people came to VB through VBA in Office. The chances are that if you learned to program throwing together macros in Word, then you never had to learn great programming practice and you might never have seen the need when you scaled up.

6) And as part of this when VB4 came along and added object orientation (not really proper object orientation but a bit of it) it did so in a fairly crappy way (no polymorphism, no inheritance, all the old non-OO stuff remained which meant it was very take it or leave it and mix and match). This meant that if you were the sort of developer who did bad things, you could now also have bad OO habits.

But none of these things made you write bad code. I worked with VB for a decade and wrote, and saw other people write, plenty of good workable code that did well in production and was supportable and maintainable.

The bottom line is that bad programmers write bad code, good programmers write good code. The tools may make it a little easier or a little harder but it's the individual who writes the code and the individual who should take responsibility.

share|improve this answer
I was all poised to disagree with this, then it all turned around in the last 2 paras, with which I agree 100%. So +1 after all, then :-) – Mike Woodhouse Nov 11 '10 at 9:56
@Jon Hopkins, how can point number 2 give one bad habits? – systemovich Nov 11 '10 at 11:06
not only that, but a widely popular and visible language attracts the wrong people for the wrong reasons. therefore there are more bad VB programmers not only because there are more VB programmers; but also because the good/bad ratio is so much worse there. – Javier Nov 11 '10 at 16:00
@hasan j - Sorry but that's not true. I've seen large commercial applications written in VB that functioned just fine. I'm talking suites of complex applications each using hundreds of controls being used by thousands of users in twenty six countries on four continents. This is VBs biggest problem - that when it comes down to it most people don't have a clue about it but are still happy to give their opinions on it. – Jon Hopkins Nov 12 '10 at 19:11
Many other modern languages also use GOTO for their error handling, they just call it "catch". But GOTO it is. – jforberg Jun 11 '14 at 11:08

Because they think they can assemble things together without any understanding about how anything actually works.

It's a cultural thing.

BSD and Linux foster a culture where you have to understand the system well. Thus programmers who are involved with a *nix system tend to be more competent than programmers who worked with systems and languages that are designed for people who don't want to understand how the system works.

Sure, there could be some great VB programmers, and sure there are many horrible linux programmers. But the point is, the system and the language cultivate a certain kind of mentality and this mentality can have a drastic effect on how well a programmer you become.

share|improve this answer
+1. There was a Joel Spolsky article ages ago which described this difference between *nix and Windows cultures. Not quite the same context, but similar ideas. :) – Bobby Tables Nov 11 '10 at 6:15
Yea, but I don't agree with Joel's analysis of the windows culture. If you compare windows culture to the Mac culture or the web-startups culture, windows is extremely frustrating and unfriendly. – hasen Nov 11 '10 at 18:05

One reason I can think of has to do with tutorials placing too much code directly in GUI event handlers; instead of calling a function/method in an application library. E.g. you should created a method to save the file and call that method from the event handler for the appropriate menu entry/button.

I think much of it has to do with problems like this. That is, not learning how to do it the right way from the beginning.

share|improve this answer
That can be a problem in C# also; it is solved by pushing back that logic into other classes. The problem is solved the same way in VB (all versions). – Robert Harvey Nov 11 '10 at 3:34
@robert Absolutely. Things like that aren't the language's fault. However, that was one the reasons my VB code was a horrible mess. I have since learned the error of my ways and I can say that there is hope for VB programmers to be rehabilitated. :) – George Marian Nov 11 '10 at 3:38
Flash is also like this. If you don't put the code in external actionscript files, everything is hard to find all tucked away inside event handlers. – Tangurena Nov 11 '10 at 3:44
I agree. You also find the same or very similar code in these event handlers. Copy & paste is rampant. Programmers don't think much about the 'shape' of their code and only a see small parts of their code at any one time. – paul Nov 11 '10 at 8:36
Not just in VB. This sort of stuff occurs in many languages. A lot of Delphi sample code is like this as well, and you get some bad copy-pasta Delphi, and some good OO Delphi (I write good OO Delphi!) – Gerry Nov 11 '10 at 10:24

Because they (well, those who do) agree without thinking to everything a certain guy says.

*It is practically impossible to teach good programming to students that have had a prior exposure to BASIC: as potential programmers they are mentally mutilated beyond hope of regeneration*

-- Edsger W. Dijkstra

Fortunatelly, some reasonable contra arguments given in one of the older questions here Do you think that exposure to BASIC can mutilate your mind? prove there is hope for humanity still.

share|improve this answer
I'm a perfect example that BASIC doesn't destroy our minds. I've been programming over 30 years, and, if I hadn't hit the limit of allowed GOTO statements in my interpreter I'd be finishing my first BASIC program any day now. :-) – the Tin Man Nov 11 '10 at 3:52
Dijkstra said that loooong before Visual Basic. The BASIC he's referring to didn't even have methods! Compared to the language Dijkstra was talking about, VB would've looked positively wonderful. – Dean Harding Nov 11 '10 at 4:27
Read this for a counter-appeal-to-authority: "In turn, this led me to the realization that Visual Basic was the ideal language for the road ahead because it is the only widespread language (yet) that allows static typing where possible and dynamic typing where necessary." – Benjol Nov 11 '10 at 6:36
@Dean et al - The BASICs he was talking about often didn't even have an ELSE statement - you HAD to use GOTO. VArilable names were one or 2 char long at most, there was no WHILE loop etc. VB is more like a mutation of an ALGOL style language – Gerry Nov 11 '10 at 10:21
At the same time, there's something to what Dijkstra says. Highly-educated programmers outside of CS raised on Fortran know almost nothing about indenting, structure, declaring variables, naming things consistently, commenting, readability, maintainability, all the things we take for granted, and mostly they have no desire to change. – Mike Dunlavey Nov 11 '10 at 14:45

I think there are several reasons.

  1. BASIC as a language has traditionally been reviled by professional programmers and academics. This was due to the fact that original incarnations of it were very primitive and encouraged using non-structured code.

  2. Lots of people using VB (or any BASIC for that matter), tend to be beginners or non-tech people who just need to get a simple task done. This results in a lot of very low quality code being written, which is not really directly the fault of the language being used. But it does IMHO result in the community having a huge number by beginners or people who just write bad code (I know this is subjective and you have every right to disagree). A friend of mine cited this as his primary reason for switching to C#. He felt there was a lot more of good code and knowledgeable people to help him in C# than in VB.

  3. AFAIK VB6 was not exactly a true object oriented language in that it did not support proper inheritance and polymorphism.

  4. BASIC is seen to be very verbose by some programmers. But proponents argue this makes it easier to learn and more readable.

I think most of the above objections no longer apply. Criticisms of early BASIC dialects are out of date. Most modern BASICs, VB included, no longer need GOTOs and GOSUBs and support modern programming constructs and concepts very well. VB6 is being phased out and VB.NET is essentially a new language that fully supports OOP as well as anything else in C#.

share|improve this answer
Regarding number 3, you're correct. It does not support inheritance. It supports a "kind" of interface. – Scott Whitlock Nov 16 '10 at 1:30

In days of old
When DOS was bold
And BASIC came preloaded
The code we made
Was well displayed
Before the screen imploded

In 1986 at Craven Community College, my Introduction to Computer Programming class used this book; Structured BASIC for the IBM PC with Business Applications (ISBN 0-87150-990-3)

You can write very structured code with BASIC. Having said this, I'd guess that 20% of the code was structured. VB is an extension of BASIC. Learning to write VB code is not that difficult. In my younger days I would refer to VB as a kiddie language. That didn't win me very many friends.

I would have to say that because VB got it's roots from BASIC and BASIC could be learned fairly easily, those associated with VB were most likely considered less diciplined in the craft of programming.

Back in the day you would see this on every Radio Shack computer:

10 INPUT "What is your name?";NAME
20 PRINT "Hello ";NAME
30 GOTO 20
40 END
share|improve this answer
love the rhyme lol – RCProgramming Nov 14 '10 at 18:06

Not the answer you're looking for? Browse other questions tagged or ask your own question.