Click to See Complete Forum and Search --> : Advantages of C++?


Speedi3579
November 25th, 2002, 01:35 PM
What are the advantages to using C++, as opposed to using something like Visual Basic or Java? I'm interested in learning what it is that makes C++ a good choice for a programming language. Any posts at all would be appreciated, thank you for your help. :D

jfaust
November 25th, 2002, 02:28 PM
templates -- generic programming is very powerful and useful, something completely lacking in VB or Java.

More control -- C++ gives you more control, which is both a blessing and a curse, depending on the developer.

Execution speed.

STL.

Jeff

Mikey
November 25th, 2002, 04:13 PM
E.g., C++ is not linked at runtime, like Java or VB, but already at compile-time.
And it's not as abstract as other Languages, so the Compiler can make more effective (faster) code.

Mikey

SeventhStar
November 26th, 2002, 02:25 AM
You can find tons of info on the net. Why bother looking here. There are heeps of advantages of c++ but there are also disadvantages.
Sometimes (rarely) Basic is better than C. It depends on the particular task. Basic doesn't allow you writing low-level programing but you can quickly make standart windows programs with it. etc... etc...
As for java I like looking at it (I speak for the language part not the compiler Mikey :) ) as a library of classes for C++. So similar they are. (as would master Yoda say) :D

there is more and more and more...

but I'm not a writer :)

davematthews
November 26th, 2002, 03:26 AM
The basic advantage of C++ is speed. Add to that additional control over what happens - but in reality that still comes down to performance - ie you can maximise speed and minimise memory footprint. If you compare C++ to Java directly you find that the languages are very similar. There are really only 2 key differences (pretty much every other differences relates back to these differences). The first is that Java is pure OO - ie every single thing you write derives from another class. This gets rid of some of the ugly things in C++ like multiple inheritance. The second thing is that Java garbage collects. That means that you will never get a memory leak in Java. The disadvantage of that is that Java has to add a load of reference counting code to every class you write which weighs them down, slows down you code and increases the memory footprint. Also, if you program well, you should be able to control the lifecycle of objects more efficiently that a simple reference counting system - again reduced memory footprint.

If you look at things from the other direction the (supposed) key advantage of using Java is portability - but this is (IMHO) a myth. The hassles getting Java to work on multiple platforms is a nightmare - you may as well write portable C++ code. Really the main advantages are:
(1) Garbage collection - sorry for the contradiction but Garbage collection makes for easier coding (albeit slower) - you don't need to think about objects, references and pointers like you do in C++.
(2) EJB etc. There are a lot of libraries for quickly generating specific code like applets, EJBs, etc.

If you want any more specific information let me know - I can also talk you through a similar comparison with VB - although the main thing with VB is that it is as slow as treacle!

Dave