C++ vs. Java?

Started by
13 comments, last by JTippetts 18 years, 5 months ago
Quote:Original post by pinacolada
Quote:
What's the differences between C++ and Java?

C++ compiles to machine-code, Java complies to a machine-independent code called Java bytecode, which can be executed on a Java virtual machine or translated to machine-code through JIT.


How a language is compiled is not exactly a great indicator of difference since Java can be compiled to native and C++ can be compiled to bytecode for a VM and it's already been done.
Advertisement

1) TIOBE Programming Community Index for August 2004

Java is the most used, followed by C, followed by C plus plus.

2) C plus plus has the most potential for being faster.

3) 1991

4) Depends on what you want to do.

5) C plus plus, because you can learn 4 languages at once with it! C, C plus plus, Macro pre-processor, and assembly. :-P

6) I'm not aware of any Java based console games, though it seems they are used on cellphones.
Quote:Original post by snk_kid

How a language is compiled is not exactly a great indicator of difference since Java can be compiled to native and C++ can be compiled to bytecode for a VM and it's already been done.


And the same goes for the "speed" of a language. C++ code can be compiled to be just as bloated as any Java compiler, and Java code can be made just as lean as what's output by the best C++ compiler.
Quote:Original post by Cinder
What's the differences between C++ and Java?

What is mostly used today?
What's fastest?
When was Java created?
Which language is most functional?
What do I learn most from?
What language are used for console games?

other things..?


There're my answers:
1)C++ has a lot of legacy code. Since it could be considered and extension of C (well, not exactly, but come on...) you have in addition a lot of C programs (think to pretty all *nix apps). Today C# targets pretty the same usage of Java, so perhaps Java is loosing (in percentage) a bit (not sure, anyway).

2)C++ programs are faster, at least in my experience (try using NetBeans or OpenOffice and compare them to, i.e. Visual Studio and MS Office). But in many cases it does not count so much, since you have powerful systems and many programs wouldn't suffer too much even if they run at half speed of a c++ counterpart. (except NetBeans :-(
But I wouln't suggest 3d games or ray-tracers in Java, if the speed is important.
On the other hand, the development speed is usually higher with Java than with C++, due to a very large api that covers all aspects of sw development and sue to a smaller probability of making some errors that in c++ could lead to hours of debug.

3)1994? It was designed to be used with embedded systems, but then...

4)They can do pretty the same things. But, for example, don't expect to go to the hw in a java program (i.e. I don't think that a driver can be made in java).

5)I would say C++, for the following reasons: java forces you to use OO design, if not in your very code (but still, you need a Object Based approach) at least every time you access its api. C++ is a multi-paradigm language: you can use it in a imperative way (like C, Pascal,...) or in a OO way, because it supports OO, but does not require it. In addition, many of the errors you get when you program in C++ may teach you a lot of things , in the learning phase. Moreover, c++ lets you work with the very byte (even bit) without using tricks (i.e. bitfields vs. bitwise operators) and you can get an idea about how does the pc works when you use c++ (stack, buffer overflow, C-like strings, many parameter passing methods [by value, pointer and reference],...).
That's said, I learned a lot about SW design since I began to use Java, and now this helps me even with c++.

6)Don't know, but I'm pretty sure C++.

I would suggest to give a look to both of them, then start a bit with C++, and then choose what you think is best for your needs. I think that knowing a imperative language helps a lot in learning Java, because I suspect that with Java a newbie can easily confuse what is a 'programming language' and what is a 'programming paradigm', or he may think that the provided api IS the language, just because you do nothing without it, while in C++ FIRST start to use the language, THEN begin to use the api. But perhaps that's just me.
vs threads don't really solve anything, and the last thing we need of any vs thread is a C++/Java one. teh cloz3d

This topic is closed to new replies.

Advertisement