Java vs C++: Performance in application using web services
I'm trying to create a consumer application which gets data from different web service开发者_Go百科s. The application has to process real time large volume data. I have to make a choice between Java and C++ only on the basis of performance. Kindly suggest.
Thanks.
The performance difference for a web site is not as important as the skill set you have available. A well written application in one language will be faster than a not so well written application in the other.
IMHO, you really need to know what you are doing in C++ to write a well written application, in Java its easier to write a well writen program as it doesn't require the same skill level.
I would agree with @Jason's point that you shouldn't consider this a one or the other solution. In a classical application 90% of the time is spent in 10% of the code. Even if you find that C++ is much faster youonly need to do this for 10% of the code.
However, I suspect you are better off spending time looking at the hardware and network infrastructure as these can make more difference and are too easily overlooked by developers.
If your scenario involves a bottleneck due to network bandwidth, it probably doesn't matter what language you use as long as it handles I/O efficiently. Both Java and C++ do this fine.
If your scenario involves a bottleneck due to computational bandwidth, C++ might be more efficient. Java has become fairly efficient in recent years through JIT compilation and other techniques.
If I were doing this myself, I prefer Java to C++ because it is a higher-level language with better tools and less opportunities for errors via memory management. I would prototype the computational part of the system in Java, and see how it performs. If adequate, I would stay in Java. Otherwise I'd compare with C++, possibly using JNI or JNA to execute the high-performance computation in C++ if there were performance benefits.
It is usually possible to write software in C++ that processes data more efficiently than equivalent software written in Java. The difference is often marginal.
Since C++ is complex it is quite common that novice programmers write C++ that performs very weakly. Java is simpler, so it is hard to make so big mistakes in Java.
精彩评论