Take the 2-minute tour ×
Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. It's 100% free, no registration required.

Lets say I am writing a server, which will run continuously and answer the queries of the client. Now what parameters (speed, memory, ease of use, quality etc.) should I consider to decide whether to use JAVA or to use C++ and how? How does system architecture decides this? Or they just choose the one in which they can found expertise?

share|improve this question
add comment

4 Answers

up vote 5 down vote accepted
  • How large is the server, and how many requests will it serve; will garbage collection be an issue?
  • How critical is memory management?
  • How critical is it that your code be closer to the hardware (C++) or farther away (Java)?
  • What kind of hardware/OS will it run on?
  • What do your developers already know?
  • What languages does your other software use?
share|improve this answer
add comment

Expertise / Real time nature of your requirements.

Amazon runs on Java - http://stackoverflow.com/questions/415360/what-types-of-technologies-does-amazon-com-use-internally so Java will definitely serve all of the business purposes and most of the perf needs.

On the other hand, Around the world, I see C/C++ being used in cases where performance / latencies are measured in milliseconds, and the spiky nature of Java GC is not acceptable.

Another reasoning to consider would be how solid do you expect this code base to be. Java is definitely more RAD than C/C++, and talent pool is huge.

Final decision factor is your interfaces. If you are going to be needing other libraries that are available only for X language, then you got no choice!

share|improve this answer
2  
Well, if language X is C, then many languages provide a glue layer that you can use to bind the library into that language. –  tdammers May 28 '11 at 9:41
    
About the latency, it's not the only concern. In real-time (or almost real-time aka games for examples) applications, the main problem is more determinism of time execution than just speed. If Java or Python or C# could run on a VM that execute deterministically everything, including object creation/destruction and memory allocation-deallocation, then it would be an as interesting choice as C++. –  Klaim May 28 '11 at 22:51
add comment

There are some good answers already. I'll add a few more:

  • Libraries. You'll probably be using a lot of third-party libraries and frameworks, so figure out what you need, and compare the offerings for both of the languages.
  • Security. Java has automatic memory management, which prevents some of the problems that you might have with C/C++, like buffer overflow attacks.
  • Platform. Do you have a heterogeneous environment? As in, servers that run Linux, and developers using Windows or Mac OS? If so, then Java is the way to go - otherwise it doesn't matter.

As far as performance goes, I doubt that you'll see a significant difference. Java imposes a huge penalty at start-up, but for a long-running server process, that doesn't matter. Once everything is up and running, Java is about as fast as native code.

share|improve this answer
    
what is the issue with an heterogeneous environment ? You just need libraries that abstract it for you and to compile on each target. –  Matthieu M. May 28 '11 at 18:53
    
Java just makes it less likely that something goes wrong. You can use the exact same library binaries for everyone. And you don't have to compile separately for different targets. –  Mike Baranczak May 28 '11 at 20:25
    
"Once everything is up and running, Java is about as fast as native code." -- it really depends on what the server is supposed to do; if it's running Monte Carlo simulations for clients and returns the results, then Java has little chance of being as fast as C++; been there, done that. –  quant_dev May 28 '11 at 20:52
1  
PS: Oh, and Java has some slight differences between JVMs when it comes to handling floating-point numbers, which can cause different outputs on different systems (Sun JDK vs GNU JDK). –  quant_dev May 28 '11 at 20:53
add comment

Which are you most comfortable with ?

Because working on a project where you struggle with the language is going to be a real pain...

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.