Monday, May 24, 2010

A question about C++ and Java?

I am a c++ beginner, I have finished the beginning tutorial, but I find C++ is so hard to use, and I want to turn to Java.I know the programs written with java can run in all platforms, but as I know C++ is difficult to do so.


I heard that programs written with C++ run faster than those with Java.


now I have no idea how to make a choice between C++ and Java, could you offer me some suggestion.

A question about C++ and Java?
C++ is not platform independent but the STL is platform indepedent. The reason why C++ is hard is they allow strict language since C++ interacts directly with memory while java is handled by the JVM.





Since C++ is memory driven, it's quicker to execute while java can only wait for response from the JVM.





C++ is not difficult, it's merely too advance as you can use pointers to access memory objects rather than accessing objects directly (like java does). Basically Java and C++ are both OO so the only thing you should ask is: Do I want my program to be memory driven executed or JVM executed?





Hope this helps.
Reply:It depends on what you want to achieve.





These days, almost all of the applications are being developed in either C# or Java.





so if you have choice switch to Java, there are center 3rd party programs that generate native machine code for Java programs so that they run as fast as any program written in any language.





Don't sweat it! and switch to Java as it is being used more now then C++.
Reply:Despite some of the other answers' claims, C++ is still the most widely used programming language (check Wikipedia). C++ is a multi-paradigm language supporting:


procedural programming,


object-oriented programming, and


generic programming (templatization)





I agree with some of the other answers that it depends on what you are trying to accomplish and what platform you will be working with and also how portable you really need your software to be.





If faced with the choice of the two, my recommendation would come down to:


1. If you're developing on the Windows platform for client applications or a server application with high performance and scalability requirements, go with C++.


2. For any other need and where the JRE (Java Run-time) will be available, choose Java.





From an academic standpoint, Java is a 'more pure' OO language and also easier to learn. On the other hand, if you learn C++, transitioning to Java would be a breeze.





Note that a lot of the complexity of C++ (that also makes it powerful) can be avoided when you're first learning the language.
Reply:it depends on what os you are using and how complicated your progs are..... i'd say java is easier to use, but c and c++ are more powerful languages....


again, this really depends on what you want for an end result, but learning both would be the best thing to do and determine which you like better.... both languages are kind of difficult (object oriented is a pain in the *** in the beginning)....


to answer your question, though, i prefer java for oo because that's what i learned oo on, but for simple things i will still use c (not c++)...


No comments:

Post a Comment