Software > Software

JAVA -> C++

(1/2) > >>

robonerd137:
I currently only know how to program in JAVA. How important is it that I learn how to program in C++. Is C++ very different from JAVA? Can someone give me a good resource to learn C++ after JAVA.

newInRobotics:

--- Quote from: robonerd137 on July 03, 2013, 11:12:53 AM ---How important is it that I learn how to program in C++.
--- End quote ---
For us it's not important at all  ;D However for whatver You want to do - it might be. What do You want to do? Why do You consider it?


--- Quote from: robonerd137 on July 03, 2013, 11:12:53 AM ---Is C++ very different from JAVA?
--- End quote ---

* Comparison of Java and C++
* c++ vs java (Google search)

--- Quote from: robonerd137 on July 03, 2013, 11:12:53 AM ---Can someone give me a good resource to learn C++ after JAVA.
--- End quote ---
c++ tutorial (Google search)

mviljamaa:

--- Quote from: robonerd137 on July 03, 2013, 11:12:53 AM ---I currently only know how to program in JAVA. How important is it that I learn how to program in C++.
--- End quote ---

It depends on what you do. Some software undoubtedly requires C++, because it's written in C++. But apart from having to write C++, because the software is written in C++, I personally would try to avoid it, because of the unnecessary complexity of the language, and focus on using C and high-level languages that interface with C (e.g. Python, Objective-C, Haskell etc.). Why? Because you get the both worlds of simplicity (a higher level language that interfaces with C) and performance (C).


--- Quote from: robonerd137 on July 03, 2013, 11:12:53 AM ---Is C++ very different from JAVA?
--- End quote ---

As both are primarily imperative and object-oriented, no it isn't. It's just considerably more complicated, because there are way more language constructs in C++ than in Java.

jwatte:
If the Java you know is J2EE style, with AbstractFactoryHelperBeans, then C++ is likely to be simpler :-)

The main difference is that, in C++, like in C, you have direct control over data structure layout in memory. This is great for when you need to fit in small spaces, but it's annoying when you end up using a pointer wrong and smashing some random piece of memory where some other part of your program lives.
Also, in C++, you have to call delete on each object exactly once. Forget it, and you leak memory. Do it more than once, and you crash.

Also, C++ (and C) has value objects/structs, which Java does not. In java, pretty much everything is a heap/reference object.

If you're doing embedded systems with small amounts of memory (Arduino, PIC, raw AVR, MSP430, etc) then C and a carefully chosen subset of C++ is likely your best bet; Java is too big to fit comfortably and will limit how much you can do on those devices. Also, don't use the heap ("new" or "malloc") at all in those small spaces; pre-allocate everything you need as static/global instances.

robonerd137:
Thank you all for the excellent responses! :)

Navigation

[0] Message Index

[#] Next page

Go to full version