C++ vs Java

This is a discussion on C++ vs Java within the C++ Programming forums, part of the General Programming Boards category; Which one is 'better'?What are their advantages/disadvantages? It seems that C++ is more powerful, however Java can be used online....

Naturally I didn't feel inspired enough to read all the links for you, since I already slaved away for long hours under a blistering sun pressing the search button after typing four whole words! - Quzah

You. Fetch me my copy of the Wall Street Journal. You two, fight to the death - Stewie

"The computer programmer is a creator of universes for which he alone is responsible. Universes of virtually unlimited complexity can be created in the form of computer programs." -- Joseph Weizenbaum.

"If you cannot grok the overall structure of a program while taking a shower, you are not ready to code it." -- Richard Pattis.

"The computer programmer is a creator of universes for which he alone is responsible. Universes of virtually unlimited complexity can be created in the form of computer programs." -- Joseph Weizenbaum.

"If you cannot grok the overall structure of a program while taking a shower, you are not ready to code it." -- Richard Pattis.

Naturally I didn't feel inspired enough to read all the links for you, since I already slaved away for long hours under a blistering sun pressing the search button after typing four whole words! - Quzah

You. Fetch me my copy of the Wall Street Journal. You two, fight to the death - Stewie

Java is a platform as much as a language. although the syntax is related much of the design and philosopy is radically different. Java has much more power, as the word is originally used than c++. c++ is more low level than Java and thus, by definition less powerfull. This is not a bad thing, less power puts more decisions in the hands of the programmer and thus more control. An automatic transmission is more powerful than a manual transmission as your car is making more decisions. If you look at a class with virtual methods and non-trivial constructors it does more, is more powerful, but you can't make a copy with memcpy, can't save it to disk with write, can't read it from disk with read, can't include it in a union and so forth. A Java reference can do things that a c++ pointer cannot, like relocate or garbage collection. The JVM can even (under the right conditions) make that reference a simple imedeate location in the JIT code (like an automatic in c/c++) this comes at the cost of sometimes having that reference be a pointer to a pointer (possibly with some additional management beyond that). Different tools for different problems. Java is the best tool for creating programms for the Java platform. c++ is my prefered tool for creating computer programs.

Which one is 'better'?What are their advantages/disadvantages?
It seems that C++ is more powerful, however Java can be used online.

I just go mad when someone says that something is more powerful than the other, and most of the time, it turns out that they have no idea what they are talking about (no offense Cris987, you are actually asking), did anybody else notice this powerful thingy?
now back to topic:
Both have uses, you should always Pick The Right Tool For The Job™, Win32 client programs in Java just suck, while network programming, servlets, multi platform programming rock, those just are examples btw.
Anyway, I highly recommend you to learn both, so you can pick up the one that suits the job better.

gluser3f is right, learn both , it gives you alot more options for how to solve a problem, i.e. you need to make a GUI for a database program, you dont need alot of speed as it isnt a very mathematical intense program, so you would use JAVA for its easiness of making something like that. on the other hand, if you are making a 3d FPS , you would go with C++ or ASM because they give you more choices and are less bloated and provide the speed the game needs.

Originally posted by glUser3f I just go mad when someone says that something is more powerful than the
other, and most of the time, it turns out that they have no idea what
they are talking about (no offense Cris987, you are actually asking),
did anybody else notice this powerful thingy?
now back to topic:
Both have uses, you should always Pick The Right Tool For The
Job? Win32 client programs in Java just sucks, while network
programming, servlets, multi platform programming rock, those just are
examples btw.
Anyway, I highly recommend you to learn both, so you can pick up the
one that suits the job better.

>I just go mad when someone says that something is more powerful than the other
I feel the same way when somebody tries to compare two programming languages. The scope of such a comparison is way beyond a little thread like this one. Basically, the best answer you can get is an opinion (usually not well thought out either).

I like Java because it has so many features built into the language standard: concurrency, GUI classes, networking and much, much more.
C++ on itself cannot do much useful. You'll need additional libraries that aren't part of the standard.
The performance difference is often not important. I belive that future computer languages will be more like Java and Haskell and less like C and C++, with more layers of abstraction. Not many are programming in assembly these days.