469,349 Members | 1,485 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,349 developers. It's quick & easy.

Server app speed - Java vs C++

Which is typically faster - a Java server application or a C++ server
application?
Oct 2 '05 #1
19 2922
Davey wrote:
Which is typically faster - a Java server application or a C++ server
application?


Faster at what? C++ run-time performance is generally superior,
regardless of the current zeitgeist that "nobody should be avoiding Java
for performance reasons." But if you're talking about a long-running,
multithreaded, I/O-bound application, e.g. a web server, the Java
application might actually be faster, and almost certainly will be
faster to develop.
Oct 2 '05 #2
"Jeff Schwab" <je************@rcn.com> wrote in message
news:uK********************@rcn.net...
Davey wrote:
Which is typically faster - a Java server application or a C++ server
application?
Faster at what? C++ run-time performance is generally superior,
regardless of the current zeitgeist that "nobody should be avoiding Java
for performance reasons."


Thanks for the answer.
But if you're talking about a long-running, multithreaded, I/O-bound
application, e.g. a web server,
Yes, I'm talking about the server-side component of a client-server
application. It will involve reading data from a database and sending the
information to clients apps depending on requests from those apps.
the Java application might actually be faster, and almost certainly will
be faster to develop.


OK, thanks.
Oct 2 '05 #3
Davey wrote:
"Jeff Schwab" <je************@rcn.com> wrote in message
news:uK********************@rcn.net...
Davey wrote:
Which is typically faster - a Java server application or a C++ server
application?


Faster at what? C++ run-time performance is generally superior,
regardless of the current zeitgeist that "nobody should be avoiding Java
for performance reasons."

Thanks for the answer.

But if you're talking about a long-running, multithreaded, I/O-bound
application, e.g. a web server,

Yes, I'm talking about the server-side component of a client-server
application. It will involve reading data from a database and sending the
information to clients apps depending on requests from those apps.

the Java application might actually be faster, and almost certainly will
be faster to develop.

OK, thanks.

When C++ behaves badly, it crashes. When java behaves badly, its
not hard to make it local or recoverable.

Java is fast enough on the server side, especially where the database is
likely to be the bottleneck.

The difference in speed doesn't make up for the added safety of java.

Oct 2 '05 #4
Wibble wrote:
Davey wrote:
"Jeff Schwab" <je************@rcn.com> wrote in message
news:uK********************@rcn.net...
Davey wrote:

Which is typically faster - a Java server application or a C++
server application?
Faster at what? C++ run-time performance is generally superior,
regardless of the current zeitgeist that "nobody should be avoiding
Java for performance reasons."
Thanks for the answer.

But if you're talking about a long-running, multithreaded, I/O-bound
application, e.g. a web server,


Yes, I'm talking about the server-side component of a client-server
application. It will involve reading data from a database and sending
the information to clients apps depending on requests from those apps.

the Java application might actually be faster, and almost certainly
will be faster to develop.


OK, thanks.

When C++ behaves badly, it crashes. When java behaves badly, its
not hard to make it local or recoverable.


Poorly written C++ code crashes. Poorly written Java code crashes, e.g.
with a NullPointerException. Well written code in either language does
not crash.
Java is fast enough on the server side,
That depends what's being done.
especially where the database is
likely to be the bottleneck.
True.
The difference in speed doesn't make up for the added safety of java.


The added speed may or may not be worth trading away for Java's
mandatory run-time checks. C++ provides better static safety checks,
and makes many Java-like run-time checks available, just not mandatory.
Oct 2 '05 #5
Ian
Davey wrote:
But if you're talking about a long-running, multithreaded, I/O-bound
application, e.g. a web server,

Yes, I'm talking about the server-side component of a client-server
application. It will involve reading data from a database and sending the
information to clients apps depending on requests from those apps.

In this case, run time performance is a secondary consideration, use the
environment you are most familiar with.

Ian
Oct 2 '05 #6
On Sun, 02 Oct 2005 12:19:31 GMT, "Davey" <da***@hotmail.com> wrote or
quoted :
Which is typically faster - a Java server application or a C++ server
application?


I don't think there would be any contest in who has the better chance
of getting a bug free program first. Java is much better designed for
that.

I would say that a C++ server app, if you allowed say 10 years to
polish the code would do better than the equivalent server app given a
similar length of time, but that does not happen in real life.

What happens in real life is, you have a fixed time budget. The C++
programmer spends it coding. The Java programmer has some time left
over to test and optimise and refactor.

As systems get more complex, it does not matter if they can deliver
wrong answers more quickly. What counts is getting the right answer
in an acceptable length of time.

When I started out, CPUs rented for well over $100 per hour. It thus
made sense to spend considerable programmer to reduce CPU time. Today
the roles are reversed. It pays to spend CPU time to save programmer
time.
--
Canadian Mind Products, Roedy Green.
http://mindprod.com Again taking new Java programming contracts.
Oct 3 '05 #7
On Sun, 02 Oct 2005 14:57:00 -0400, Wibble <Wi****@Mailinator.com>
wrote or quoted :
Java is fast enough on the server side, especially where the database is
likely to be the bottleneck


or the datacommunications. You can find out which by comparing how
the app behaves on a LAN compared with out there on the web.
--
Canadian Mind Products, Roedy Green.
http://mindprod.com Again taking new Java programming contracts.
Oct 3 '05 #8
On Sun, 02 Oct 2005 16:31:02 -0400, Jeff Schwab
<je************@rcn.com> wrote or quoted :

Poorly written C++ code crashes. Poorly written Java code crashes, e.g.
with a NullPointerException. Well written code in either language does
not crash.


Consider how large programs are now. If you have probability p
(expressed as number between 0 and 1 e.g. 1/1,000,000) that a given
line contains an error, then the odds of a program N lines long being
perfect is:

N
(1-p)
You see how the math works against you because N, the size of the
program is in the exponent. So in other words, no matter how careful
your programmers, in large programs, errors are unavoidable.

C++ was designed back when programs were small and it was possible to
avoid error with sufficient skill and care.

Java takes a more realistic view that there will inevitably be errors
in large programs no matter who wrote them.

How can you find them? (avoiding pointers, null pointer and array
bounds checks) How can you keep doing even when they happen? (catch)
How can you flush them out? (assertions)

How could we do even better? (design by contract).

see http://mindprod.com/jgloss/designbycontract.html
--
Canadian Mind Products, Roedy Green.
http://mindprod.com Again taking new Java programming contracts.
Oct 3 '05 #9
Roedy Green wrote:
C++ was designed back when programs were small and it was possible to
avoid error with sufficient skill and care.

Java takes a more realistic view that there will inevitably be errors
in large programs no matter who wrote them.

How can you find them? (avoiding pointers,
....you can do that in C++, if you like, or use smart pointers such as std::auto_ptr, or boost::shared_ptr
null pointer
Use references instead of pointers.
and array bounds checks)
std::vector.
How can you keep doing even when they happen? (catch)
....like in C++.
How can you flush them out? (assertions)
Yeah.
How could we do even better? (design by contract).

see http://mindprod.com/jgloss/designbycontract.html


I fail to see what your first 2 sentances above are about.

Ben
--
I'm not just a number. To many, I'm known as a String...
Oct 3 '05 #10
Roedy Green wrote:
C++ was designed back when programs were small and it was possible to
avoid error with sufficient skill and care.

Java takes a more realistic view that there will inevitably be errors
in large programs no matter who wrote them.

This is a common misconception made by people who think of C++ as "a
new C". They are two very different languages (even though they
somehow manage to work really well together). IMO, this is good.

You maybe need sufficient skill and care with C, but not with C++.

There is little point comparing Java with C++ (again!) - they, also,
are completely different languages and people use each one based on the
circumstances.

To the OP: use something that you are most comfortable with.

Hope this helps,
-shez-

Oct 3 '05 #11
On Mon, 03 Oct 2005 01:43:15 +0100, Ben Pope
<benpope81@_REMOVE_gmail.com> wrote or quoted :
...you can do that in C++, if you like, or use smart pointers such as std::auto_ptr, or boost::shared_ptr
null pointer


Use references instead of pointers.


Yes you can make C++ safer with extra effort, but normally you are
running without any safety net. In Java the net is mandatory.

There is nothing in C++ to ensure you scrupulously avoided pointers or
invalid casts..
--
Canadian Mind Products, Roedy Green.
http://mindprod.com Again taking new Java programming contracts.
Oct 3 '05 #12
That depends on what you are doing and how well the Java and C++ are
written. Different circumstances will yield different results.

The only thing you can say in general is that there's overhead in
initialization of JVM that you are not going to see in C++. If the program
runs for only a few seconds, that time can be significant. If the program
runs for a longer period of time, less so.

Davey wrote:
Which is typically faster - a Java server application or a C++ server
application?


--
Remove '.nospam' from e-mail address to reply by e-mail
Oct 3 '05 #13
On Sun, 02 Oct 2005 23:43:32 -0400, James McIninch
<ja*******************@comcast.net> wrote or quoted :
The only thing you can say in general is that there's overhead in
initialization of JVM that you are not going to see in C++.


That is not true for AOT Java, mainly HotSpot Java. Hotspot is
primarily for servers. It does not matter if server apps take 10
minutes to come up to full speed since they will be running for weeks.

AOT Java is not quite as spritely as C, but they don't have a
noticeable delay coming up.

see http://mindprod.com/jgloss/nativecompiler.html
--
Canadian Mind Products, Roedy Green.
http://mindprod.com Again taking new Java programming contracts.
Oct 3 '05 #14
Ian
Roedy Green wrote:
On Mon, 03 Oct 2005 01:43:15 +0100, Ben Pope
<benpope81@_REMOVE_gmail.com> wrote or quoted :

...you can do that in C++, if you like, or use smart pointers such as std::auto_ptr, or boost::shared_ptr

null pointer


Use references instead of pointers.

Yes you can make C++ safer with extra effort, but normally you are
running without any safety net. In Java the net is mandatory.

There is nothing in C++ to ensure you scrupulously avoided pointers or
invalid casts..


Your coding standards.

Ian
Oct 3 '05 #15
On Mon, 03 Oct 2005 17:47:12 +1300, Ian <ia******@hotmail.com> wrote
or quoted :
There is nothing in C++ to ensure you scrupulously avoided pointers or
invalid casts..


Your coding standards.


But there is nothing to enforce the standard, so you are back to
relying on your own skill and care.

--
Canadian Mind Products, Roedy Green.
http://mindprod.com Again taking new Java programming contracts.
Oct 3 '05 #16
Roedy Green wrote:
On Mon, 03 Oct 2005 17:47:12 +1300, Ian <ia******@hotmail.com> wrote
or quoted :
There is nothing in C++ to ensure you scrupulously avoided pointers or
invalid casts..


Your coding standards.


But there is nothing to enforce the standard, so you are back to
relying on your own skill and care.


Well, my personal coding standards decree that raw pointers are not to be
used. Instead, my code uses smart pointers or wrapers that support memory
leak detection. This rule, which is a real time saver, happens to be rather
simple to enforce:

bits> wc graph_002.cc
1363 4644 36840 graph_002.cc
bits> grep delete graph_002.cc
bits> grep new graph_002.cc
// new label:
bits>

(Admittedly, there was a false positive. But that was easy to spot.)
Now, I agree that there are other gotchas for C++ and more sophisticated
tools would be needed to catch those. On the other hand, I found that it
takes very little discipline to avoid these dark corners: most of the time
you simply don't have a reason to go there anyway.
Best

Kai-Uwe Bux
Oct 3 '05 #17
Roedy Green wrote:
On Mon, 03 Oct 2005 17:47:12 +1300, Ian <ia******@hotmail.com> wrote
or quoted :
Your coding standards.
But there is nothing to enforce the standard

And thankfully so.

so you are back to relying on your own skill and care.

Again, we're talking about C++ here, not C.

-shez-

Oct 3 '05 #18
responding to Davey...
I think following link can give you Good Answer...!!!

Presented at Sun Microsystems Laboratories,by Matt

http://www.eecs.harvard.edu/~mdw/pro.../sunlabs-talk/

Regards
Raxit Sheth

Oct 3 '05 #19
Davey wrote:
Which is typically faster - a Java server application or a C++ server
application?


It is likely that network or database would be a performance bottleneck,
so, it does not matter. Annother question is design, if you choose bad
server side application design, there will be problem in both cases.

C++ will execute the same sequence of simple operations faster.

There has been a lot of similar questions in this group, so, please,
don't post souch questions in the future.

DG
Oct 3 '05 #20

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

4 posts views Thread by chiefprogramer | last post: by
reply views Thread by Alexander DEJANOVSKI | last post: by
30 posts views Thread by Mike Cox | last post: by
53 posts views Thread by Krystian | last post: by
25 posts views Thread by abhinav | last post: by
1 post views Thread by =?ISO-8859-15?Q?Ma=EBl_Benjamin_Mettler?= | last post: by
14 posts views Thread by rabbitrun | last post: by
2 posts views Thread by robinsand | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by zhoujie | last post: by
1 post views Thread by Marylou17 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.