@IWishIKnew
The pros and cons aren't really as clear-cut as you seem to think.
[Java] Runs on ANY system (no porting!)
[C++] does not run on any OS unless ported |
Java doesn't run on "any system", much less with "no porting". It runs on any system the Java interpreter is ported to (although that is quite an extensive number of systems). The C++ language is every bit as portable as Java -- the original Java compiler and virtual machine were implemented in C/C++. In theory, C++ can be ported to pretty much any architecture because it makes so few assumptions about the system. The portability of Java refers to code that's written in it, not the language itself. It refers to the fact that, once compiled, your code will run on any supported platform: Java code gets compiled to an intermediate form, called bytecode, which the JVM then converts to native code and executes. This means that you only have to create one binary, and then that binary will run on any JVM, hence the phrase "write once, run anywhere". C++, on the other hand, has no intermediate form; it gets compiled straight to native code which means you have to create separate binaries, although those binaries will typically run much faster (at the very least, they will load faster due to the lack of a need to convert from bytecode to native code). Also, the C++ standard library is much less extensive than Java's, which means that to do certain things you have to resort to platform-dependent code. Java also has well-defined integer sizes (int is always 32-bits) which C++ still lacks (std::
uint
nn_t is optional and might not be defined on some platforms). However, Java code isn't guaranteed to be portable just because it's written in Java. Not
every platform has a JVM, though the important ones do, and there are still platform-dependent things that have to be taken into account, like endianness. Also, the original implementations of the Java GUI library had some differing behaviour between different platforms. So, to recap, the languages themselves are no more or less portable, and a given piece of C++ code can be as portable as an equivalent piece of Java code; Java's advantage where portability is concerned is that you only need to manage one codebase and distribute one file, and that running on a virtual machine allows it to make certain guarantees that C++ can't make without affecting portability.
[you can] probably learn [Java] faster |
Yes and no. Java is a simpler language than C++ in that it doesn't have pointers or manual memory management or templates and because it has a big, fully-featured standard library which simplifies things. However, the huge class library takes a lot longer to learn than the smaller C++ standard library. I would say that overall Java is easier to learn, though -- it was designed to be.
[Java] can't be used to run high-cpu calculations (way too slow for that, aka no graphics engines with it, no refrencing hashes too much, etc...)
[C++ is] fast |
Again, not necessarily. Java is quite fast and it can be used for stuff like graphics just like C++ can, although you probably wouldn't use it for complex, real-time graphics (though you could just write those parts of your program in C++ and the rest in Java). Minecraft is written in Java and it gets pretty poor performance despite having quite simple graphics (although it does have to simulate a lot of objects; it could probably render much better graphics with fewer objects). Java is only slower because it's effectively two programs running at once -- the JVM, which either interprets, or (more commonly) dynamically recompiles, Java bytecode into native code, and then the actual Java program.
@Lumpkin
C++ has a smaller standard library which doesn't do as much for you, so you'll find yourself implementing things that Java has already got, and you may also find yourself writing more boilerplate code in C++.