Click to See Complete Forum and Search --> : vb and c++


Stummer
August 22nd, 2005, 05:57 AM
i am new to windows programming,

i just wanted to know the reason people use c++ over syntactically simpler language such as vb. they both have access to the same win32 functions right? I am guessing the performance differnence isn't much to shout about...

david

NoHero
August 22nd, 2005, 07:05 AM
VB does not have fully support for the WinAPI you need to use this Declare statement over and over again when accessing WinAPI in VB. Since Windows and the WinAPI itself is written in pure C, you can only access the full possibilities from C. And why to learn a new language when you already know C or C++?

[ Moved Thread ]

fleck
August 22nd, 2005, 07:11 AM
VB is a Microsoft language.
C/C++ can be used everywhere. One of the main topics is that you can use free tools to work with these languages. Try to write an app for Unix/Linux in VB.

Alex.

Stummer
August 22nd, 2005, 07:14 AM
i mean regarding win32 specifically

philkr
August 22nd, 2005, 07:45 AM
For one thing Visual Basic is definitely better: Making a complex GUI with little time and effort. But that's it already, I'm afraid.

As you were speaking of a syntactic easier language. I simply don't see that. Why should
If Value1 = Value2 Then DoSomething
be simpler than:
if(Value1 == Value2) DoSomething();
Okay, maybe:

For X = 1 To 10 Step 2
DoSomething
Next

is a bit more understandable for a non-programming person like:

for(x = 1; x <= 10; x += 2)
{
DoSomething();
}

But once you know the syntax of the language elements makes no difference, I think. You only have to learn if, else, switch, for, while, do statements and some more. It's not very much.

Furthermore in some things the Basic syntax is not very nice. For example return values. I think "return variable;" makes more sense than "FunctionName = variable". And when you are calling a function without saving the return value you suddenly have to leave the brackets for the parameters away. That doesn't makes sense either.

And finally regarding Win32 specifically you have the freatest problems: Like NoHero said you have to declare everything you use from the API. In C you can simple type "#include <windows.>" and everything is declared. Then you have to take care of the different data types because the API is written in C. You have to take care of pointers in parameters and translate everything to Basic data types. I did it once because I started programming with VB and it is really awful when you want to do these things.

klintan
August 22nd, 2005, 09:35 AM
Well, each programming language has it's strengths and weeknesses.

c++ has excellent performance (if you do it right), it is portable, a lot of people know it, it gives you much more control over things (API's, memory, threads etc.), but for many tasks languages such as VB, c#, java is much more productive and less error prone. So it really depends on what you want to do.

Regarding syntax, c++ has a very rich syntax because you can do many things, c# for instance uses the same syntax style but it is much simpler since you don't have to deal with addresses and pointers.

About readability, I think it is just a matter of taste, which is best:

let counter=counter+1
ADD 1 TO COUNTER
counter := counter +1;
++counter;

(Basic, COBOL, Pascal, and c/c++/java/c# examples).

When COBOL was introduced, they said that programmers wouldn't be needed anymore, since programs was written in plain english.

Or how about the if example given earlier in this thread, but written in Smalltalk:


(Value1 = Value2) ifTrue: [DoSomething].


Personally, I prefer the Pascal-style syntax (which originated from Algol I think), also used by languages such as Simula (the first OO language!), and Ada.

The c-style syntax use too many special characters for my taste, but it is very effective with all brackets, ++ and stuff. Though I dislike that = not means equals like it does in mathematics.

Visual Basic uses Basic syntax, and Basic was around before Microsoft was. What I find most annoying with VB is that different assignments are used for simple types and objects (LET vs SET). And the error handling mechanisms sucks. Luckily, they have fixed both those issues in VB.Net.

Smalltalk was fun, but it took a while to get used to the syntax, where everything is an object and even statements such as if and while are methods (on the class Boolean).

For the moment I am programming in c#, I can live with the things I dislike about the syntax. c# and Visual Studio is a very productive environment. Other guys at my department are coding in Fortran, their code is usually faster but I am by far more productive. I think that programming language and enviroment should be chosen for the application needs, not for which looks best.

Stummer
August 22nd, 2005, 10:51 AM
so why do people use c++ over vb for win32 apps?

speed and flexibilty i guess

NoHero
August 22nd, 2005, 11:23 AM
so why do people use c++ over vb for win32 apps?

speed and flexibilty i guess

C++ exists for 20 years and C for even 40 years. They are highly known and spoken. And the entire WinAPI is written for and in C. So using C or C++ would come to mind first. Don't you think?

Stummer
August 22nd, 2005, 12:00 PM
well, no, considering the vb is easier and quicker to program with, and it has as much access to the win api as c does.

maybe vb is for begineers lol

NoHero
August 22nd, 2005, 12:11 PM
well, no, considering the vb is easier and quicker to program with, and it has as much access to the win api as c does.

The last thing is true but if you want to use all WinAPI functions (or any other functions from a thirdparty library written in C) you have to Declare them all, and you still have to struggle with C issues like null terminated strings, pointers, memory allocation etc. And for that stuff VB is very circuitous. For this I can still use C where I have all these things from the beginning because they are part of way how you programm in C. I started with VB too, then I did all these WinAPI stuff and thirdparty libraries using Declare, pointers and memory. After I was sick of all those stuff I finally moved to C and saw that I have just wasted my time with VB. ;) Now I write portable applications in C++ using Qt. ;)

My 0.02$

klintan
August 22nd, 2005, 06:26 PM
In the late 80's when client server was new I heard someone say:

First generation programming languages was machine code
Then second gen came (assembler), and third (Fortran, COBOL, Pascal and many others), and forth (app builders like dataflex, VB would fall in this category I would guess), and people talked about fifth generation programming languages (but noone knew what it was) - then everybody goes back to generation 2.5 (c) !

Nevertheless, as many already has pointed out:

c/c++ is good for portability, low-level stuff, excellent performance
vb/c# is good for productivity and quality, but not portability, and lacks c/c++ performance
java is portable, productive, but lacks c/c++ performance

And regarding performance vb/c#/java has about equal performance and about 80% of the performance of c/c++ - for number crunching and such stuff... but performance is usually about design, e.g. network roundtrips, efficient DB design, use of transaction monitors/application servers etc.

So it all depends on your requirements and your company strategy, if you are targeting MS platform only and developing business app's c# or VB.Net is the best choice, are you doing real time stuff you need c or c++, are you doing very intense computing nothing beats Fortran etc, are you still maintaining a large base of VB apps you might still stick to VB but I think most organizations doing that are or should consider .Net.

darwen
August 24th, 2005, 10:34 AM
I'm surprised no-one has yet mentioned the fact that C++ is object oriented, VB6 is not.

This means that when using C++ large, complex systems can be modelled and designed using all the advantages of object orientation, and described by using standard notation like UML.

Commercial VB6 applications (certainly in my experience) are huge, unwieldy and horrible beasts with no structure to be seen.

Not to say that you can't do the same with C++ of course - but the potential is at least there for people to use.

And let's face it when it comes down to one syntax over another I'd far, far, far prefer to have a nicely designed system which is easily maintainable with slightly less readable (although I've always found C++ readable except for STL) syntax than a language which looks like English but as soon as you try to maintain it your head explodes.

Of course C#/VB.NET et al are also object oriented. And I'm a great fan of .NET. My preferred language IS C# (with C++/Assembler for time critical stuff).

Darwen.

RoboTact
August 24th, 2005, 02:16 PM
If you carefully programm in C++, you have all advantages of productivity, quality and portability. Though in practice it's more difficult to force programmers code in C++ for quality then in Java/C#.