Click to See Complete Forum and Search --> : Is C++ more powerful than Java?


jetblackz
06-10-2003, 01:32 PM
I found this in another forum. Which one is powerful? How do you define powerful?

The thread started didn't mention which version of C++ and Java. Assume standard.

Rüpel
06-10-2003, 03:18 PM
if (powerful==fast) cout << 'yes';

bwkaz
06-10-2003, 09:29 PM
Originally posted by jetblackz
How do you define powerful? That's entirely the problem. It's defined in completely different ways depending on who you talk to.

For example, some people say that having automatic refcount garbage collection (Java) makes the language much more powerful, because the programmer doesn't have to worry about freeing memory manually. So the Java programmer can focus on making the program do The Right Thing more easily.

Some will say that not having GC makes the language more powerful, because the programmer has more control, even though in the case of GC, it's hard to see how you'd have more useful control over the process of freeing data -- Java only frees it when it can't possibly be used anyway anymore (when there are no references to it from objects accessible in the current VM's memory space). *shrug* whatever.

Flame wars will probably ensue, and I (or someone else) will probably have to close this thread too, but hey, whatever. We'll see. :D

jetblackz
06-10-2003, 10:26 PM
The thread starter in another forum claimed C++ was more powerful than Java. He based it on the load time it'd take to load the bytecode and execute it. VM takes a while to load the bytecode and run it. A compiled C++ program runs almost instantly.

At least 2 forum goers pointed out C is actually faster than C++. The latter takes a performence hit due to the use of polymorphism.

One of them looked at the lowest level, saying in the end, it's all 0's and 1's.

I think speed shouldn't be the only factor. Capability should be considered. And portability.

One guy hit the nail on the head: you shouldn't hide in the corner, come out and speak, we all learn something from each other.

nowonmai
06-12-2003, 08:45 AM
if portability is a measure of power then java kicks C++'s ***... you can run java on many devices, phones, smartcards etc...

if pure speed is what you're after, then C++ is the way to go

if flexibility and ease of development is what you want, I'd have to say Java

the problem is that because they are both OO (to greater or lesser degrees) and they both have curly braces, people assume that they're similar... they're not, except on the most superficial of levels. horses for courses...

shakin
06-12-2003, 09:18 AM
As others have said, it depends on what you're measuring. I don't think things like speed of execution and garbage collection matter in and of themselves so much as what you can do with the language. Each has their strong points.

Java is great for enterprise web development, where EJBs reign supreme. Java is also excellent at bridging two different systems because of its cross-platform capability. Java's superior OO architecture can make large-scale development easier.

On the other hand, there's a reason why very little major client-side development is done in Java. C++ provides much better low-level control of a computer as well as better direct access to OS APIs (Java loses its point for existing once you do that). C++ apps are also smaller, making them great for low-storage space applications.

I use both languages and my opinion is that if you can do the job in Java without speed of execution of resident size in memory being a problem, then Java is the better language due to its ease of use and portability. If you can't do it in Java or the speed/size issue becomes problematic, then C++ is a good option (as is C or any number of other languages).

Unfortunately, we must measure C++'s strong aspects as counterpoints to Java's weaknesses.

Stuka
06-12-2003, 10:02 AM
One advantage that hasn't been mentioned for C++ over Java is the fact that C++ is a multi-paradigm language. Actually, shakin referred to this as Java's "superior OO architecture", which I believe is a mistake. C++'s OO architecture is just as good (if not better - I've seen some OO proponents who think the "global object hierarchy" is a Bad Idea (TM)) as Java's, but C++ also supports procedural programming, generic programming (though I hear that the Java 2 1.5 release will have that too), and even functional programming to an extent. Also, the fact that every modern OS is built on C or C++ means that to directly interface with the OS, which is the best way to wring every bit of performance out of a box, requires C or C++ means that C++ has distinct advantages over Java. I do believe that Java has a place, but my opinion is that, overall, C++ is a more powerful language.

DragonHead
06-13-2003, 01:36 PM
As already stated, I think it depends on what you are trying to do. For some projects, Java is a better fit. For some it would be C/C++. For others it may even be a different language.

You pick the tool for the task.

Rüpel
06-13-2003, 02:23 PM
that's the third time i try to answer to this thread and this time it's really easy:

You pick the tool for the task.

DragonHead, thank you! that's exactly what i wanted to explain but never got it that straight and easy.

sclebo05
06-13-2003, 02:46 PM
i think you are all pretty much hitting the nail on the head. each language has its strong points. before i graduated, i wrote a file sharing client for my school's network, i wrote the client using Java because i wanted it to be cross platform and quick to develope. someone else wrote some of the backend stuff in C++ on the server because of the speed needed. in that case, we used BOTH where they were best suited and it all came together.