I've been writing in visual basic for a number of years and have suffered so much criticism just for using the language. It's so easy to pick up and it can be compiled to an executable, that's why I learned it... From what I've gathered, the things that are "wrong" With visual basic is that
1) it only runs on windows
2) it's so easy that people who don't know how to program can program in VB (messy incomprehensible code)
3) can't write device drivers (whatever.)

Anyways, none of these really seem like issues since 1) practically everyone runs at least one windows machine anyway, and I mostly just write software for my own benefit, 2) I myself learned how to write nice code so it doesn't matter what other people do, and 3) I would not need to ever write a device driver... The only actual issue I've ever had with it, is that it can't compile a DLL with exports. But you can interrupt the message between the compiler and linker, and fix that problem.

So that leaves me to wonder what is actually legitimately wrong with writing software in visual basic--
any actual answers?

also, I have this piece of software sort of similar to what python is that I was just writing to see if I could do it, but now that it's getting bigger I'm wondering if I could sell it... is something written in VB marketable?

Recommended Answers

All 11 Replies

If you feel confortable with VB and mostly write things for yourself, why even ask? Just carry on!
But.
As all things evolve, so do computers and programming languages.
I programmed (as a pro)in a language called Modula-2. Liked it very much. I can still program in that language if I wanted to, but I evolved and I now use Visual Studio .NET and the C# language and feeling quite happy with it.

I suppose, and it seems like VB is even getting phased out of windows with Vista and Windows 7, which is why I'm trying to learn C, C++, and assembly, since those languages are, for the most part, immortal.

Setting Aside Minor Language Quirks, It's slow as hell. Don't believe me?
Add a button, and 2 labels...(I've done this without a form too, using sub main() with debug.prints, but the difference is negligible)

Private Sub Command1_Click()
Dim retval As Double

Label1.Caption = Time
Me.Refresh

For I = 0 To 100000000
    retval = I * I
Next I

Label2.Caption = Time
Me.Refresh
End Sub

On A Pentium 4 2.80Ghz Dual core processor with 3GB's Ram, this code averages (compiled, not IDE) 8 seconds.
Now this in Visual C++ (it's faster in code::blocks, but hey):

#include <iostream>
#include <time.h>

using namespace std;

int main(int argc, char **argv)
{
	double retval;
	char timeStr[9];

	_strtime( timeStr );
	
	cout << timeStr << endl;

	for (int i=0; i < 100000000; i++) {
		retval = i * i;
	}

	_strtime( timeStr );

	cout << timeStr << endl;

	return 0;
}

On the same processor averages 1 second. So, 7 times faster than VB? To be perfectly honest, the inability to use pointers is annoying as all hell (addressof, for real?). What about strings.... what about how strings are always duplicated no matter what?

Form_Unload very hardly does justice to a destructor, and Form_Load is a poor example of a constructor. To be honest, I don't use windows, I use *nix only (well, ok, so I have a virtualbox with XP in it, but eah).

String escapes.... wow, that's frickin' nasty. Go ahead, add a " to your vb string. Next thing you know, you have an entire function devoted to making one string, because you have to close quote concatenate, open quote, etc, etc ( x = "Coma said " & chr(34) & "How Are You Today?" & chr(34) ). What is that trash? This is much cleaner: x = "Coma said \"How Are You Today?\""; . Not to mention that x="" uses 8 bytes of ram. In order to make that "efficient" if you can call it that, you need to use x = vbnullstring .

Oh I guess I haven't mentioned the fact that every object has a different property that means the same thing (ok, so .net cleans that up some). So I have a textbox with a .text property... makes sense... now I have a button, I should set its .text property too right... yeah no. It's a .caption property. wtf?

Putty, it's a great program that I use to access my server remotely through ssh... one great thing about it, is that it doesn't require an installation... I just double click it, and it runs. VB requires numerous .dll files, (vb runtime files), and you also have to ship along any additional .ocx's or .dll's that you plan to use. I'm not even going to talk about the "variant" data type (whew, what a nasty one).
Consider also, that the language is sloppy. It basically allows you to toss out variables on the fly without declaring them, and how absurd is it that you use = for assignment, and comparison.

So setting aside the syntactic flaws, the bloatware nature, the lack of processing speed, strings, lack of pointers, etc, etc.... Absolutely nothing. VB can be used to make functional working programs (I've done it, and still do), but I have no intention of pretending that there is nothing wrong with VB, because there is. That said, VB can be used to make programs... it can be used to make functional, easy to use (and easy to make) programs... but it does suck.

okay okay, I've never looked into it in that much detail before, but actually I am curious about the variant data type--why is it awful?
and what's wrong with using = for both comparison and assignment?

and yeah, I guess you're completely right that is sucks.


----EDIT----

lmfao, I read that site and can't believe all the shit I put up with without noticing that it is completely stupid.
I guess it's because VB was my introduction to programming.

Variants use more memory, and require additional overhead because when passed to a function or used in a certain way, it has to be cast to that type. The same VB code I posted above, I changed the Dim I as Integer to Dim I as Variant and the speed jumped from 8 seconds (for the wild loop with multiplication) to 18 seconds just by using the Variant data type instead of integer. Using = makes it more difficult for code readability, and slightly confusing, because in most other languages if you do something like if (x = 5) { it will return true if x successfully gets assigned the value of 5. So if x fails to become 5, then you know not process the following code. Such a thing isn't possible in VB, without adding additional steps.

All that said, don't beat yourself up. VB does work, and honestly, for applications that don't require time critical processing, does it really matter? With RAM cost dropping faster than a roller-coaster the extra it uses is hardly a reason to never use it. I've written an instant messenger client and server with VB6... and just recently, a program that blocks certain web-sites based on the current time. So while VB does suck, it's not entirely without use, and to some degree kind of fun. :)

well it IS pretty fun to use, since it's so quick to do whatever you want with it...

anyways, I've been trying to get into C and C++ for awhile, I've got all the basics and understand syntax and such just when it starts getting complicated I get lost, because everything that I know programming is, changes dramatically with the move from VB to C... for example, a couple months ago is when I first learned that a parameter can be a reference or value parameter... anyways the only issue I'm having is that I've spent a couple of years teaching myself to be clever with code by writing something similar to python I guess (I've never really used python but I just learned what it was recently) a script interpreter, which interprets my own language with a somewhat complex syntax, like

var "a"
$a = 4 * (8 * 4 - (3 - asc("c") - asc("a") / (2 + 9)) + sqrt(22)) + 3
msgboxex $a, mOK, mExclamation, replace("some evaluation", "e", chr(asc("E")))

would work properly... anyways it took a long time to teach myself everything and build it up, my main concern was that after all this time I wouldn't really be able to use it or sell it or give it to anyone since it turned out quite nice, but I don't know how I would even begin trying to write it in any other language.

But thanks for telling me all the intimate details about VB, now at least I know a little more about it

------
by comlex syntax I really just mean I made it read functions with brackets and evaluate long equations, and it has program flow control if/for/while/etc... it's not THAT complex I know, but whatever

Microsoft promised to make VB6 programs "just work" in Vista because there's a TON of classic VB code out there in business and industry - a segment VERY reluctant to upgrade operating systems. Yes, they have a ton of legacy code... and it works for them. And re-writing or converting would cost millions. Unfortunately, MS didn't promise to make the VB development environment work.

Oddly enough, the COM object model still exists... even in some MS programs sold today, so I doubt it will disappear soon.

As you mentioned, one of the strengths of classic VB was the ability for the masses to learn and use... which spawned some real creativity. Sadly, i think we're reverting back to programming as a specialty, without a language for the "masses." Lot's of people did cool things with classic VB that won't have the time to invest in learning any variation or C. I understand languages and OS's have to evolve, but I think they could have made a smoother transition.

I don't make my living coding... but I do make some nice change selling a commercial app written in classic VB to a specialized vertical market.

Add a button, and 2 labels...(I've done this without a form too, using sub main() with debug.prints, but the difference is negligible)

Private Sub Command1_Click()
Dim retval As Double

Label1.Caption = Time
Me.Refresh

For I = 0 To 100000000
    retval = I * I
Next I

Label2.Caption = Time
Me.Refresh
End Sub

You need to define I as a double, otherwise it will be declared as a VARIANT and it will run much slower. As is, this code took 4 seconds to run. Changing the I to a DOUBLE shaved 2 seconds. This is, of course, on the IDE. Creating an executable should increase the speed of the loop even further.

To be perfectly honest, the inability to use pointers is annoying as all hell (addressof, for real?). What about strings.... what about how strings are always duplicated no matter what?

Pointers do exist in VB, as you have indicated. How they work and how they are implemented is completely different. VARPTR for example will return the pointer to a variable and there is an undocumented array pointer function as well.

Form_Unload very hardly does justice to a destructor, and Form_Load is a poor example of a constructor. To be honest, I don't use windows, I use *nix only (well, ok, so I have a virtualbox with XP in it, but eah).

I think that Form Load and Form Unload are not intended to be anything more than event-driven functions. They are no part of the OOP toolset that VB provides. I am not super well versed in OOP but I would guess that what you are talking about is found in VB.NET...

String escapes.... wow, that's frickin' nasty. Go ahead, add a " to your vb string. Next thing you know, you have an entire function devoted to making one string, because you have to close quote concatenate, open quote, etc, etc ( x = "Coma said " & chr(34) & "How Are You Today?" & chr(34) ). What is that trash? This is much cleaner: x = "Coma said \"How Are You Today?\""; .

You are right, but keep in mind that a way to clean it up a bit is to assign CHR(34) to a variable (say NL), and then concatenate. Back in the old days of BASIC you used the + as a concatenator, so we are lucky to have this future now!! You can also come up with a much more elegant way by somehow implementing the JOIN keyword.

Not to mention that x="" uses 8 bytes of ram. In order to make that "efficient" if you can call it that, you need to use x = vbnullstring .

Again, just different paradigms.

Oh I guess I haven't mentioned the fact that every object has a different property that means the same thing (ok, so .net cleans that up some). So I have a textbox with a .text property... makes sense... now I have a button, I should set its .text property too right... yeah no. It's a .caption property. wtf?

Your example is not great, as I know of no reason why someone would want to change the text/caption of a button on run-time. Having said that, I get the gist of what you are saying...

You are right but keep in mind that in VB 6 (at least, IDK about .NET), each object has a default property (...I know, bad programming practice to do it), so you can say:

Label="Blah"

and

TextBox="Blah"

and they will have the same result. The default property for Labels is CAPTION and the default property for TextBoxes is TEXT.

I do not use the default properties in my programs as it could be confusing to some. It makes it easy to know that it is a label or a textbox.

Also keep in mind that the reason the VB designers used different property names is because they wanted to let the programmer be aware that they are not supposed to be the same thing. Text boxes are faster at refreshing than labels (if I am not mistaken; it could be the other way around).

Putty, it's a great program that I use to access my server remotely through ssh... one great thing about it, is that it doesn't require an installation... I just double click it, and it runs. VB requires numerous .dll files, (vb runtime files), and you also have to ship along any additional .ocx's or .dll's that you plan to use. I'm not even going to talk about the "variant" data type (whew, what a nasty one).

You are right on these... I hate VARIANT... :) and I abhor DLLs...

Consider also, that the language is sloppy. It basically allows you to toss out variables on the fly without declaring them, and how absurd is it that you use = for assignment, and comparison.

Actually, among the "parent" languages, C and its derivatives, are unique in providing that assignment operator.

If you set it to OPTION EXPLICIT, you do not have implicit declarations. I have no idea why VB6 provides implicit declarations. This makes debugging difficult. I always set it to EXPLICIT.

VB can be used to make functional working programs (I've done it, and still do), but I have no intention of pretending that there is nothing wrong with VB, because there is. That said, VB can be used to make programs... it can be used to make functional, easy to use (and easy to make) programs... but it does suck.

I have used VB to create computer vision applications, and other number-crunching type of programs with great success. I also know of others that have created very complex vision, neural networks, and other type of AI with VB6.

It's all in how you approach the programming. If you know the language well to know the tricks, you will be able to do almost anything.

C is a great language. I -sort of- like it too. But I think that VB provides a very easy programming environment... I love IntelliSense, and the ability to create applications with nice, usable interfaces, without a lot of work.... (I wish debugging was easier!)

I personally, think VB6 is a great language... It has its flaws (believe me, MANY), but I would not underestimate its power and versatility. Even Microsoft has had a hard time pushing people to change to .NET.

Welcome ReefPicker,

I must say well said in several areas but I also must say...

AHHH!!! Necrophiliac! It raises the DEAAAAD! AHHHH!!! :)

Meaning the thread is over a year old and some people will get the willys with you doing your thing with the dead... :)

Thanks! Sorry, I got the dates mixed up... I honestly did think that it was more recent... It actually came up on a search I was doing trying to find out if anyone had a solution for an "annoyance" that I had encountered in VB6... So it was a webot that retrieved it ;)

PD If you are wondering what the annoyance was, it has to do with using any of the graphic methods on a PICTURE object... Sometimes upon stopping for debugging, when I attempt to return it sets an error "Wrong number of arguments or " blah blah... At first this baffled me, then I found out that by adding a remark (') to the offending code, running the application on the IDE, then stopping, removing the remark, and re-running, then all was well.... So I know 100% sure it is a bug... I am surprised it has not been fixed for so long... and that nobody else seems to have encountered it....!!

But this thread and any others are going to live on the internet forever and ever, and people are going to read them all in the future, what's wrong with adding additional information to a thread for future readers?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.