473,725 Members | 2,070 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Java's performance far better that optimized C++

133 8558

"Gaurav" <ga********@yah oo.com> schrieb im Newsbeitrag
news:71******** *************** ***@posting.goo gle.com...
http://www.sys-con.com/story/print.cfm?storyid=45250

Any comments?

Thanks
Gaurav


Huhuhu-hahaha...
Java faster ...haha... than C++ ...ha-hahaha...

First of. If you take a close look at the language features you will
see that you can do everything you do in Java in C++ but not vice
versa. Next, if you "optimize" code by the compiler it can't become
any better than the crappy C++ you provide. So, if you want to really
compare the 2, you should get 2 professional prograamers for each
language and let each one do the way their language requires doing.
Next, gcc 3.3 is not really a good optimizing compiler. Better than
2.95, but not as good as say the intel or the codewarrior compilers.
But for a wednesday mornig, a good joke, thank you.

-Gernot
Jul 22 '05 #2
The code in Java cannot be any faster than in C++, because with C++ the
generated code is practically 100% optimal, provided that the program is
written with it in mind, and the compiler is good. And there are good
compilers out there.

Best regards,
Marcin
Jul 22 '05 #3
On 16 Jun 2004 00:45:02 -0700, ga********@yaho o.com (Gaurav) wrote:
http://www.sys-con.com/story/print.cfm?storyid=45250

Any comments?


Whenever I look at inter-language benchmarks in detail, I always find
a flaw in the benchmarking for one language or the other (and often
both), generally based on the author's bias (they generally have
greater expertese in one language than the other).

In the benchmarks you've posted, the compiler options provided to GCC
are sub-optimal, and no functions seem to have been declared inline.
For example, many of the tests would benefit from loop unrolling,
which only happens on -O3 I think. Some of the benchmarks are also
highly synthetic (they don't really do anything except try to bombard
a particular language feature in a way that never happens in a real
program). It's better to set a required output for the input, and then
let the program achieve that output however it wishes to, balancing
code clarity with optimization.

Incidently, I got the fibonacci test down to around 0.1 seconds using
this simple code:

unsigned long fib(unsigned long n) {
unsigned long last = 1;
unsigned long current = 1;
for (unsigned long i = 2; i <= n; ++i)
{
unsigned long newCurrent = last + current;
last = current;
current = newCurrent;
}
return current;
}

Tom
--
C++ FAQ: http://www.parashift.com/c++-faq-lite/
C FAQ: http://www.eskimo.com/~scs/C-faq/top.html
Jul 22 '05 #4
Gaurav wrote:
http://www.sys-con.com/story/print.cfm?storyid=45250

Any comments?


LoL, the guy who wrote that knows absolutely nothing about benchmarking.

br
db
Jul 22 '05 #5
Gaurav wrote:
http://www.sys-con.com/story/print.cfm?storyid=45250

Any comments?


Those tests expose one regularity - the examples where OS support is
extensively used are slower than those where the entire code in
performed in process space. Performance of the former suffers from
user/kernel mode switching and if it is done at least once per loop
iteration the impact must be pretty visible.

So all C++ examples with extensive heap or stack (function calls) memory
allocation must be slower than corresponding Java examples where similar
functionality is performed by the JVM directly in the user process space
(Fibonacci, hash, object creation).

Of course if one is ready to pay with slower startup and bigger memory
consumption then he/she may can have the same in C++ using inlining,
memory pool and other commonly used techniques.

When such handicaps are not introduced (nested loop, random numbers) C++
performs faster as expected.

One thing surprised me. For the reason described above I expected the
method call example to be slower in any case in C++ than in Java, then
after looking at the code it appeared that all member functions were
coded inline and at least some of them were optimized away by the
compiler. So this test does not fulfil its goal. The other ones also
introduce some unnecessary temporary variables etc. and should not be
used as representative C++ code.
Regards,
Janusz
Jul 22 '05 #6

"Gaurav" <ga********@yah oo.com> wrote in message
news:71******** *************** ***@posting.goo gle.com...
http://www.sys-con.com/story/print.cfm?storyid=45250

Any comments?


I was recently part of a team that rewrote an largish C++ app in Java. No
question that for this application the Java version was slower than the C++
version. No doubt the Java version had some advantages (platform
independence for instance) but it was slower and noticeably so.

john
Jul 22 '05 #7
Gaurav wrote:
http://www.sys-con.com/story/print.cfm?storyid=45250

Any comments?


In general, you can find arguments to many unfounded things. Weather
this is correct (which I doubt) or not is irrelevant most of the time.

Don't worry about it unless you need to.

Barely related question.

How many of you guys actually work on projects in which performance is
critical? (Something written in Java is unacceptable)

I see value in both languages, however, it appears as though many people
immediately dismiss Java, regardless of the scope and requirements of
the project.

JLR
Jul 22 '05 #8
How many of you guys actually work on projects in which performance is
critical? (Something written in Java is unacceptable)


When you write a conventional user application for a multitasking system,
your program should accomplish its tasks as fast as possible. Therefore, we
are commited to deliver the fastest software ever. 0.01ms vs. 0.1ms responce
on user button click is much more important for us as opposed to development
time. Therefore, we write huge number of code lines and ignore impressing
IDEs like Intellij Idea and go on wasting our time and writing unreliable
code in order to deliver the best performance. Slow C++ compiler does lots
of things for us including and compiling huge files.
Jul 22 '05 #9
Gernot Frisch wrote:
✄
you will see that you can do everything you do in Java in C++ but not viceversa.


So there are something that may be do in C++ and not in Java?
Interesting...

Please give me your curriculum, so I can hire you in my company!

- Dario
Jul 22 '05 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

114
9864
by: Maurice LING | last post by:
This may be a dumb thing to ask, but besides the penalty for dynamic typing, is there any other real reasons that Python is slower than Java? maurice
11
9265
by: DrUg13 | last post by:
In java, this seems so easy. You need a new object Object test = new Object() gives me exactly what I want. could someone please help me understand the different ways to do the same thing in C++. I find my self sometimes, trying Object app = Object(); Object *app = Object(); Object app = new Object();
0
8752
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9401
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9257
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9176
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8097
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6702
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6011
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
1
3221
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2157
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.