473,396 Members | 1,997 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Server app speed - Java vs C++

Which is typically faster - a Java server application or a C++ server
application?
Oct 2 '05 #1
19 3158
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: chiefprogramer | last post by:
How to build up a good frame for a mathematical system and it's ultra-high-speed? Althought In PHP 5 there is a new Object Model. But I think the new Object Model is still very slow >< Just...
0
by: Alexander DEJANOVSKI | last post by:
JyRetic 1.0RC3 was just released. (http://retic.sourceforge.net) Changes are (I might have forgotten some bug fixes): - Bug fix : Scheduled events didn't work if no parameter file was required...
30
by: Mike Cox | last post by:
Hi. I recently ran a benchmark against two simple programs, one written in Java and the other in C++. The both accomplish the same thing, outputting "Hello World" on my screen. The C++ program...
53
by: Krystian | last post by:
Hi are there any future perspectives for Python to be as fast as java? i would like to use Python as a language for writing games. best regards krystian
25
by: abhinav | last post by:
Hello guys, I am a novice in python.I have to implement a full fledged mail server ..But i am not able to choose the language.Should i go for C(socket API) or python for this project? What are the...
1
by: =?ISO-8859-15?Q?Ma=EBl_Benjamin_Mettler?= | last post by:
Hello Python-List I hope somebody can help me with this. I spent some time googling for an answer, but due to the nature of the problem lots of unrelevant stuff shows up. Anyway, I...
14
by: rabbitrun | last post by:
Hi Everyone, I work for a financial company. I am planning to give a presentation to rest of the development team (15 people) here on moving server side logic to client-side javascript for an...
2
by: robinsand | last post by:
There has been much discussion in these groups about the speed of C++ relative that that of Java for performing given functions and when run on specified compilers. Does anyone know how C++'s speed...
2
by: JosAH | last post by:
I run my Java programs on a small Linux laptop and today I installed it again on a MS Vista laptop.My linux laptop ran quite a bit faster than my Vista laptop and I decided to find out why. ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.