What is the difference between Java and C++? Are both object-oriented?
-
2Please close the question or make it a community wiki. This question is not worth getting reputations on. – Perpetualcoder Dec 22 '08 at 20:31
-
@Perpetualcoded: Not voting it would be enough. – OscarRyz Dec 22 '08 at 20:42
-
2He didn't ask which is "better", he asked what the differences are. Perfectly valid question. – bpapa Dec 22 '08 at 20:47
-
4Why are we so worried about rep? This guy sounds like a newbie and may not understand the community wiki process. It is a valid question, look at the response that is has generated. A lot more than some of the highly geeky questions that get asked. – WolfmanDragon Dec 24 '08 at 19:55
-
1I find that often questions ideally suited for programmers, are marked as not programmer questions.. How much easier it would be to just ignore them and let question stand. Still upset that my question on how to save a career in programming was nixed. – baash05 Nov 22 '11 at 11:39
-
Here's a summary that might help: http://marketimpacts.com/blog/2011/12/23/programming-languages-java-vs-c.html – Don Cowan Sep 05 '12 at 20:34
-
You may find this useful as well. http://stackoverflow.com/questions/4405074/differences-between-the-c-and-the-java-object-model – Berat Cevik Jan 27 '16 at 05:50
11 Answers
This is far too general a question to be answered here.
Java is an explicitly object-oriented language, with the harder-to-use bits snipped off.
C++ is a multi-paradigm language with the safety off. You can do object-oriented programming in it, as well as procedural and generic.
If you had a more specific question, we could be of more help. Why did you ask? If you want recommendations for a particular platform, or project, or whatever, we could be more responsive.

- 56,304
- 9
- 91
- 158
-
11"Any language will let you shoot yourself in the foot. C++ will provide the gun, load the bullets, give you a drink to steady your hand, mount telescopic sights, and paint a large target on your foot" – Paul Tomblin Dec 22 '08 at 20:45
-
6Sure will, but it will also gives you a gun with a big enough bang to drop a dinosaur. All in perspective. – WolfmanDragon Dec 22 '08 at 21:39
-
@PaulTomblin "Java will give you a gun which randomly sues you back..." – Abhinav Gauniyal Jan 18 '17 at 10:47
A C++ programmer will tell you that Java is rubbish. A Java programmer will tell you that C++ is rubbish. Therefore I conclude that they are indeed the same thing.

- 6,797
- 3
- 32
- 41
-
3Besides, everyone knows that Erlang is better than both. Or is that Scheme? Or Clojure? Or Ruby? I can never remember. – James Schek Dec 22 '08 at 23:51
-
4An Erlang programmer will tell you that Scheme is rubbish and a Scheme programmer will tell you that Erlang is rubbish. Therefore I conclude that they are indeed the same thing. – Daniel Paull Dec 23 '08 at 01:04
-
2and when c# gets involved both join forces for a second and chuck their whole arsenal at the c# programmer. – Aleks Sep 05 '12 at 21:46
-
1
Each language designed with different purposes in mind, so IMO it's not fair to compare the two from one perspective, and ignore the other.
Generally speaking, C++ is an open standard, designed for implementing high performance systems where speed and performance and critical, there are lots of impressing projects designed using this language like Phoenix Lander, Adobe Acrobat Reader and others. C++ gives the developer the ability to program using a very high level abstraction -using generics for example, and, when needed, go down deep to the bare metal of the machine -to handle an interrupt for instance.
Java was designed with other purposes in mind, when Sun was planning Oak (later called Java), it focused on web applications so it supported the language with a bunch of heavy libraries of easy-to-use interfaces considering that. and portability (Compile once, run anywhere) using JVM, which prevents the programmer from coding to specific machine, but instead coding to a sandbox which in turn runs the code on the hosting machine, and this has obviously negative reflections on performance/speed.
Comparison of those two language is a popular cause of debate between programmers, and this is due to their different working demands and nature, IMO every language has made mistakes in order to mature, for example, C++'s exported templates, and Java's lack of procedural programming (Big Mistake). plus, each one has its pros and cons regarding different aspects, hence the one that balance productivity/performance issue IS the right language.
For more information Wikipedia's comprehensive article on Comparison of Java and C++
It might be interesting to take a look at what languages are used (and being used) to create major systems (like Google) from here.

- 353
- 1
- 2
- 8
-
1Java used to be an open standard too, for some time... (or at least a bit more open that it's now under the rule of oracle) – scravy Jan 22 '12 at 11:38
- Everything is Object in Java as everything is derived from java.lang.Object But this is not the case in C++
- No pointers in Java whereas C++ has provide support for pointers
- No destructors in java (Java has automatic garbage collection) but C++ has destructors to do that
- Thread support is built in Java but not in C++
- No scope resolution operator in Java
- No Goto statement in Java
- No Multiple Inheritance allowed in Java but C++ allows that
- No operator overloading is allowed in Java but C++ allows that
- Java is interpreted for most part and hence Platform independent

- 21
- 2
One of the most important differences hasn't been mentioned yet - one is compiled to machine code, the other is compiled to bytecode which is interpreted by a virtual machine.

- 5,043
- 2
- 30
- 33
Both are object oriented but they are very different languages. This probably isn't the best forum to ask for the differences... I would suggest you look both up on Wikipedia and review the descriptions there. You will be able to see the differences very quickly for yourself.

- 77,985
- 20
- 184
- 180
I love c++ but unless you absolutely need to use c++ then use something else. When you need to use c++ then you will know the difference, Grasshopper.
(hint do not write device drivers, video decoders, encryption libraries, 3-d graphics engines or language run-time engines in java).

- 9,854
- 2
- 30
- 30
Yes, both are object oriented programming languages.
C++ is an evolution to C. Which was a system programming language. C++ Added many features to the language to make it object oriented. It became the mainstream programming language for that reason.
Java is an evolution of C++, with different goals ( cross platform for instance ). It remove some of the features that make C++ so hard to learn. Simplify others and remove others.
The main difference is C++ programs are compiled directly to machine code ( understood by the CPU ) while Java programs are compiled to be run in a "Virtual Machine" the JVM most of the cases. For these reasons java programs were interpreted by another program and at the beginning were veeeery slow programs. Nowadays the VM may optimize this code and make it run very very fast.

- 196,001
- 113
- 385
- 569
-
jit (just in time) often converts the java "compiled" bits down to the machine code.. so this mitigates many of the speed differences.. I (being a c++ developer in my heart of hearts) resent the note evolution of c++. I'm also not sure I understand the sentence fragment "hard to learn". It's no harder to master than Java. Both take about 10 years.. (or I'm assuming java does, I'll tell you when I get there) – baash05 Nov 22 '11 at 11:45
Gross but accurate oversimplification: Java is easier. C++ is faster.
-
With the state of compilers at the moment, C++ is only faster than java if it is optimized. Not the languages fault though. – WolfmanDragon Dec 22 '08 at 22:33
Just a quick addition to what David Thornley posted. C++ is a procedural language that supports Objects and OO design. Java is pure OO. Java does less but on more.

- 7,851
- 14
- 49
- 61
-
Hence a multi-paradigm langauge. I personally think "procedural" langauge capabilities are far less important than C++'s template metaprogramming capabilities. Not only can C++ drop a dinosaur, but you can do it in an infinite number of ways. – James Schek Dec 22 '08 at 23:49