Why do people say that VB gives you bad programming habits? What do they mean by this?
|
|
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. |
|||||||||||
|
|
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:
|
||||
|
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. |
|||||||||||||||||
|
|
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. |
|||||
|
|
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. |
|||||||||||
|
|
Because they (well, those who do) agree without thinking to everything a certain guy says.
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. |
|||||||||||||||||
|
|
I think there are several reasons.
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#. |
|||||
|
|
In days of old 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:
|
|||
|
|
