tags:

views:

175

answers:

3
+1  Q: 

Shifting to Java

I'm a C/C++ developer.

I am just intrigued why some of my colleagues are shifting to java. They actually have a lot to say why Java is better than C++. This is actually more of a trivial question, but I know for sure it would be a source of enlightenment for many also for novices like me.

Knowing only C++ and a little of java, how do you think could you convince a C++ developer to shift to java? If not, why stick to c++?

+1  A: 

Reasons to stick with C++:

  1. Old C++ code base difficult/too much work to port
  2. Require use of specialized 3rd party C++ libraries.
  3. Low-level (hardware device driver) required control. C is considered a better language for that.
  4. Unable to run JVM on desired target platform.

Otherwise, I would choose for java as:

  1. The language is much "cleaner" (it's not necessary to be downwards compatible with C)
  2. The use of references instead of pointers make your life easier, much less need to write 'destructors'.
  3. My experience with switching to java/eclipse is that the refactoring tools make your life much easier. (Disclaimer: I'm not quite familiar with the latest C++ IDEs).
  4. I really like the amount of ready-to-use libraries, not only inside JDK, but also on Apache, etc.
Roalt
@Roalt Add portability;)
Petar Minchev
"no destructors" is a complete myth. The garbage collector manages memory, and only memory. Other resources still need to be cleanup up, and convincing these garbage collected languages to do so at the proper time is hell compared to C++ RAII.
Ben Voigt
@Petar: ANSI C and ISO C++ both have much better source code portability than Java.
Ben Voigt
@Ben Voight Come on, you tell me that when you write a C++ application, you can run it on another machine immediately without any problems;) I doubt that;)
Petar Minchev
@Petar: No, but I can *compile* it immediately on another machine, and then it runs without problems. (I'm assuming you gave me the chance to debug it on the first platform?)
Ben Voigt
@Ben Voigt : "no destructors" is no myth. Since I program in java I do not have to bother to free all my data structures, linked lists and so on. That does not mean that you should not think what must be done if you clean something up.
Roalt
@Roalt: Ok, you don't have to free *all* your data structures, only *a lot* of them. Pretty much anything that has a member variable from the `java.io` package, and that's just one example of many. And when you do need cleanup it's nowhere near as simple as with C++ (in C++, simply using `unique_ptr` or `shared_ptr` is usually enough).
Ben Voigt
+2  A: 

There aren't any good reasons to switch to Java. C++ is better than Java for systems and/or embedded programming, and there are many better alternatives for rapid prototyping.

Now, you tagged your question MFC even though it doesn't appear in the main text. I would recommend switching from MFC to one of the more modern C++ UI frameworks, because MFC is brain-dead, non-standard, fragile and very difficult to customize.

Ben Voigt
by "modern C++ UI frameworks", do you mean something like QT?
Owen
@Ben Voight - It depends on what he is developing. As you say, if it is low level embedded programming then C++ is better, but for enterprise applications Java is far far better.
Petar Minchev
@Petar: Even if Java >> C++ for enterprise programming, that doesn't mean switch to Java. Other languages leave Java in the dust at such tasks.
Ben Voigt
@Ben Voight OK, I understand you don't like Java. But I think you are trying to call one of the most popular and good languages useless...
Petar Minchev
@Owen: Qt isn't the best example because it also works outside the standard C++ language to get its job done, but it sure would be a better choice than MFC. Other frameworks like WFC, wxWindows, (and at the lower layers SDL) would be modern C++ libraries.
Ben Voigt
@Petar: Java has an easier learning curve than C++ (once you get past needing half a page of code just to run without errors), but we're discussing someone who already knows C++. There's really no point for such a person to learn Java. They can round out their abilities far better with a dynamic language or functional language than by working in C++-lite.
Ben Voigt
+1  A: 

In my opinion there is no good reason to switch to JAVA, if programming is meant for academic purposes only. But if you want programming language for personal use or creating commercial application you should try out c#.NET, python or other frameworks.

Ashwini Dhekane