tags:

views:

178

answers:

6

I know Ruby and PHP and want to start learning a lower level programming.

I'm having a hard time choosing between C++ and Java, and coming from only dynamic languages I don't know exactly what I can do with C++ and not Java, and vice versa.

Could someone explain what the benefits (focused on features) are for each of them?

+12  A: 

If you want to do system programming (write drivers ...) or need ultra fast performance (write high end games ...) C++ is the way to go. It is near the system and compiles to native code (no interpreter or VM is needed). This is what I would call a "lover level" programming language ... a language near the system.

Java is more like the languages you know. A high level language (althought static typed). It is easier to learn than C++ and eases the programming (for example: Java has garbage collection, C++ has not). If you want to write Desktop-Applications or Webservers i would recommend Java.

Arne
That's a nice balanced view.
Donal Fellows
Samrat Patil
+3  A: 

You HAVE to start with C++ to understand what is happening under the hood. After C++ any language is easy.

BarsMonster
This can also be read as: Any language is easier than C++. Note that even if you start with C++, you may not learn what happens under the hood - only if you actually dig into things like assembly output, compilers, processor architecture, andsoforth. Yes, you will know more about the lowest level of processor, but is that the goal of the OP? Or is that creating big functional applications?imho, one cannot suggest or prefer a certain language without knowing the requirements.
Cthulhu
Well, pointers, memory leaks, careful exception handling, out of bounds errors, null pointers - all these things make you good programmer. In Java it's easy to miss all these important lessons.
BarsMonster
@Cthulhu: My focus lies on application level. So maybe Java gives me more support out of the box than C++?
never_had_a_name
I don't get why you don' HAVE to start with assembly then?If your focus is on the application level C++ might be a bit too low level. I wonder whether Java is the best choice for you though?* If you go for Windows applications => C#. Download Visual Studio Express and start coding a Windows Forms app.* If you go for multi-platform applications => Java. Download Eclipse and start coding a Swing app.* If you go for web apps... Java or Ruby (on rails), Python...
Stijn de Witt
Assembly is also essencial, but kinda boring these days (less visible progress over time), C++ is low-level enough. Yes, Java have more out of the box, but it's all available in C++ in external libs.
BarsMonster
+1 for Stjin. My thoughts exactly.
Samrat Patil
+4  A: 

I'd say C++ is a bigger chunk. If you manage to absolve it, you won't have too much problems with learning java. Not the other way around though.

Tamás Szelei
+3  A: 

With C++ you can get closer to the 'bare metal' than with Java. I did learn C++ first, so I may be a bit biased. C++ is faster, but you have to understand arithmetic pointers (which can be dangerous!).

Wikipedia has a nice comparison between Java and C++ here.

More comparisons here.

Edward Leno
+1  A: 

Personally I'd say Java if you consider yourself an application programmer (high-level), and C++ if you're a low-level programmer (drivers, applications with very specific performance specifications (real-time), embedded systems), or if you're feeling particularly adventurous and don't mind debugging and vague crashes a lot.

(disclaimer: answer is probably not neutral or objective. I find C++ frustrating to work with, while I'm very comfortable with Java)

Cthulhu
+2  A: 

It really boils down to what you want to do with the new language: for web programming and some phone platforms (Andriod, RIM), Java is the way to go. If you want to make 3D games or system utilities C++ may be a better choice. In general, you can always look at the area you are interested in and check which programming language is dominant there.

Nemanja Trifunovic