I know this is probably a dumb question but, what is the difference between VB and C++? Or..What are the pros and cons of the languages? I've never tried programming a game before, but I'd love to try it.
Printable View
I know this is probably a dumb question but, what is the difference between VB and C++? Or..What are the pros and cons of the languages? I've never tried programming a game before, but I'd love to try it.
Well, for one thing, Visual Basics was programmed in C++
And C++ is closer to machine code then VB, making it that much better.
VB isn't fully a OOP language, ie. you can't really use class inheritation.
Also VB does not officially support pointers.
VB code needs an interpreter while C++ code is compiles.
C++ ist faster ;)
In C++ you can include ASM code directly.
in C++ you need to do more things by hand... ie. you can pre-define functions, better said you need to :)
You can include files (damn VB this is so usefull !!!)
If you're doing small things C++ might be much complicater
---
Just to mention a few...
Hey stop dissing VB. ;)
- When making Windows apps (look & feel of windows, etc.) VB is the way to go!
- If you use DirectX for your games, it just doesnt matter if you use VB or C
In VC++ you can make windows as in VB...
If you're using DirectX in VB you can access a great library *nearly* as fast as in C++... but say you want to make seriuos games you are just lost in VB
PRO - you can make a VB app. look more like a Windows app.
CON - VB is slower
Erm, windows is made in C, VB is made in C, and Excel and Word and everything other, too...Quote:
you can make a VB app. look more like a Windows app.
how come everyone thinks in C you need to make DOS programs or these stupid Borland C++ -buttons with icons and rounded border???
VB is Object Oriented and does have pointers (although you never actually see them =). Defining a variable as say, a TextBox, is really defineing a "Long", and allocating memory for the textbox object. And yes, you can use inheritance, but it sucks =(. Look up "Polymorphism" or something like that in the MSDN for more info.
VB DOES compile to native code, but it relies on several VERY large runtime DLLs for built in functions. VB apps ARE use API calls under the surface, so its much easier to create a GUI really fast. Probably the biggest reason VB is so slow is because MS doesnt have any competition against it, so they have no real reason to spen a lot of time optimizing the VB compiler. VC++ on the other hand, has lots of competition, so they have to make their c++ compiler optimize your code much better. VB also has to make assumptions, for it to hide certain things away from the beginning programmer. You really dont want to see what an "Event" looks like in C++ =).
On the other hand, the way the VB IDE is setup is better in my opinion. The VC++ IDE is kinda shaky when it comes to Intellisense, and that kind of thing.
As was said earlier, VB will get an app up and running, and is quite adequate for most games, but if you really need to get down into the system, C++ is the way to go. It may be a bit more complicated, but it pays off in the long run. And even then, VB is still of much use for creating Map Makers, etc =).
Z.
This is probably another dumb question...Is it possible to make 3D games? I guess that's what the Direct "3D" is all about...What should I know about, before making vb games?
Well of course you can make games in VB... but depending on how good they are it's even difficult or impossible in VB. Direct3D is part of the DirectX package and in the meantime it's called DXGraphics (which also contains DDraw, the 2D part of DirectX, now).
With a few good sites, a copy of DirectX8 SDK and 3 weeks, I made myself a 3D program. It lacks some of the maths components though. Eg.. collision detection and Gravity. ;) lol
Yeah, the only bad thing in VB is slowness :)
But I'm writing a game that uses special effects (including real-time calculated fire in the player's ship), made in pure VB - and it's quite fast, running at about 30 FPS with no delay on my P800 ;)
So it's not that slow after all - but I might have to make a DLL version of the special effects for the final version.
Yeah you can always say 'it's fast enough' - but compared to C/++ it's just slow...
30 FPS is enough, but Quake3 (sorry but I think it has better graphics than yours) runs with 120 FPS on my P800 and that's slightly faster :)
Hehe I know, but was that speed on the VB IDE while running an heavy visualization plug-in on Winamp? ;)
I *had* to break down the FPS, because it was too fast :p
All I have now is a debug message called "frame delay" :)
can someone send me their stuff? I'd like to see "VB3D" in action hehe
Basically C++ is better for smaller, and faster code (All-Purpose)
VB is good for RAD, and Databases.
C++ is good if you don't want your program to take up nearly 2mb for "Hello World" :rolleyes:
C++ with TINYCRT from Microsoft...no runtime support at all...2K...yeah... ;)
heh, i made a c++ program that took up 512kb once, all it said was, I MADE A C++ PROGRAM, WOOOO, and it took up that much, ic an do that in VB and it takes up much less..
assembler, no THATS the language you wanna learn, c++ was made in that!
Ok then.
C++ = 50K program, no dependencies
VB = 10K program, requires 2mb of runtime support files
No contest :)
And yeah, ASM kicks everything else but there's little use for it now since it's so hard to program in. It's nice for spot-optimising though :D
Your hello world program was probably really big because you were still in debug mode :)
It depends on the compiler, ie. MS VC++ makes your program really BIG (compared to others) but compiling doesn't take too much time...
Ummm...the VC++ compiler makes some of the smallest .exes I've seen ;)
I heard this discussion so many times :rolleyes:
well I have a question somewhat related:
is there any good page or good book, to learn C after already knowing VB, (also german books in case fox knows some). I really don't feel like reading what a variable or command button is, just because I want to learn C. :(
Anyone?:confused:
I can recommend you 'Visual C++ in 21 days' (german if you want), I also bought it to learn C++ after already knowing VB and it really shows you the important things... it teaches you lot about MFC and C++ in general, but after all you can directly step on to DX coding like in VB..
Don't learn MFC until you're very good at C++. Unlike using the API, MFC demands a considerably higher level of expertise.
Assembly is not all that hard to read, but you have to know what you are looking at, and exactly what it should be doing.
VB executables are small, VB programs are not. VC++ can create very large executables, but it can also create very small ones. It all depends on your compiler options.
Also i doubt that VC++ was written in Assembly, although it does compile C++ code into assembly language instructions (as do all compilers). VB does the same thing, so the "VB was written in C++ so its slower" argument is invalid.
For myself, I think that if you dont include an FPS counter, as long as it looks smooth, no one will care >=).
Z.
Thanks fox for the book thing. I never trusted a 21 day thing. I think I will need a little longer till I could claim to know the language.
and about that:
that seems pretty funny to me, because it's not like VB is interpreted by C while interpreting its own VB programs :). We live in the time of compilers people :)Quote:
VB was written in C++ so its slower
See the FAQ in the C++ forums if you want free online books and tutorials. :p
I'm in a similar situation, I was studying VB and now have decided to go to VC++ mainly because of it's power/speed and the fact that I like to create things almost from scratch and like to know how a language like VB is making things so easy.
Most VB programmers don't realise how much VB is doing for them.
What is better to lean first C++ or VC++ I already have two books on VC++ and stated one of them about 4 days ago. Am I right in saying if I lean VC++ I will know C++ properly?
VC++ is a compiler/IDE/project manager
C++ is a language
Therefore, it takes about a day to learn how to use VC++ but a lot longer to use C++.
However, in the case of your books, VC++ would mean MFC :mad:
Thanks Parksie, but would leaning the VC++ mean getting a book on C++ later on?
The VC++ Book I'm currently reading was given to me by my Uncle and is:
Visual C++ in 12 Easy Lessons
By Greg Perry & Ian Spencer (SAMS Publishing)
I don't think this book doesn’t get into MFC (I could be wrong), it goes up to OOP and writing text files to disk etc and it's a great book, well so far anyway nicely laid out with definitions and reviews etc.
The second one which I accidentally parched thinks it was for beginners is:
Learn Visual C++ Now
By Mark Andrews (Microsoft Press)
Have you herd off any of these two books or read them? If so what you think of them?
As long as it teaches the language rather than using MFC or the VC++ interface you're okay.
I don't have much experience with books because I learnt C from the K&R book and used MSDN to get up to speed on C++.
It is not like he would get 120 FPS if he would program his game in C++. I bet those professionals are a little more advanced than what us people here pick up from SDK. :)Quote:
30 FPS is enough, but Quake3 (sorry but I think it has better graphics than yours) runs with 120 FPS on my P800 and that's slightly faster
Professional game programmers usually have lots of lovely asm in there as well :) Plus they have knowledge of how to get the most out of a compiler so they're programming in C (sorry, but C beats C++ for speed in a lot of cases) but it looks a little weird because they're cheating and making the branch-prediction work a little better :)
Well, I have all the VB-code to make the bounds of the arrays match, so all I need now for my special effects is a really fast DLL that loops trough 2 arrays, checks one against the other in a lookup table (another array), and dumps the result in one of them... it's really easy, I've got the code in VB (5 lines), all I need is someone to convert it to a faster language ;)
Currently, most recent games that are on the market, or are in development, are written in C++. Even thouse C may be faster, and require less memory, the amount of System RAM, the speed of Microprocessors, and the current crop of graphics accelerators on the market make the speed difference almost negligable. C++ offers benefits that far outstrip the tiny bit of extra speed that C offers. Also, contrary to popular belief, modern games dont use near as much inline ASM as people believe. It is used most often for small areas that need to execute at maximum speed, like in nested loops. Even then, the optimization that commercial compilers usually perform is generally far better then what any but an expert ASM programmer could do. The reason most commercial games are so fast is because of rendering techniques use, frustrum culling, back face culling, the various tree methods for occlusion culling (quad trees, oct trees, bsps).
Certainly though, there are games that make use of a lot of ASM. Quake is probably the best example. The original only had software rendering, and the inner rendering loops were re-re-re-re-optimized ASM.
For you C++ programmers out there, here is a neat optimization tip:
This will print the Fibinacci(sp?) value for 75. I know it works in MSVC++6. Try writing a recursive function that does the same thing and compare the results. Its stunning.Code:#include <iostream.h>
template <unsigned n> struct Fib
{
enum x
{
val = Fib<n-1>::val + Fib<n-2>::val,
};
};
template <> struct Fib<1> { enum x { val = 1, }; };
template <> struct Fib<0> { enum x { val = 0, }; };
int main()
{
cout << Fib<75>::val << endl;
return 0;
}
Z.
Nice :)
Gives me 10 warnings though :rolleyes:
Hey when you guys say ASM are you talking about Assembly Language, sorry but I'm not familiar with the term ASM and was just wondering.
Yes. :)
I thought most of the newer games (e.g: 1996 or 1997 and up) used C++ to program the games?Quote:
Originally posted by parksie
Professional game programmers usually have lots of lovely asm in there as well :) Plus they have knowledge of how to get the most out of a compiler so they're programming in C (sorry, but C beats C++ for speed in a lot of cases) but it looks a little weird because they're cheating and making the branch-prediction work a little better :)
By the way, the industry standard is C, correct? (in contrast to C++)