Talk:Java performance: Difference between revisions

Content deleted Content added
SineBot (talk | contribs)
m Signing comment by Kelt65 - ""Speed" ?: new section"
syntaxhighlight & fix lint
 
(15 intermediate revisions by 9 users not shown)
Line 1:
{{WikiProject Javabanner shell|class=CB|importance=mid}}
{{WikiProject Software|class=CJava |importance=mid}}
{{WikiProject Software |importance=mid}}
}}
{{Broken anchors|links=
* <nowiki>[[Metadata#Program metadata|metadata]]</nowiki>
}}
 
== "x times slower" ==
Line 31 ⟶ 36:
 
==Program Speed ==
Surely we need more references or benchmarks to support the claim "Java's speed is now comparable with C or C++ and in some cases Java is significantly faster". I am a professional programmer who works with both Java and C/C++ and in my experience, everything done in Java is MUCH slower. At the moment there is only a very questionable benchmark as a reference, which uses a 3D engine. This is a bad example, as the drivers/OpenGL api implementation would have more of an influence on the FPS than the actual language used. [[Userhttps:CptAnonymous|CptAnonymous]//acadgild.com Acadgild] 14:47, 8 September 2007 (UTC)
:I added the Jake example, but then I wrote: ''Java programs take more time to start, are slower and use more memory than their C or C++ equivalents.'' But I don't completely agree with you: OK Java is slower than C/C++, but not MUCH slower; and I think that the Jake example is relevant (but I agree that it is not a benchmark). 3D engines typically create a LOT of objects (outside the OpenGL API), and they need to update frames every few milliseconds. OK, the OpenGL driver performance is very important, but after that, the 3D engine used on top of it, and the game itself, are also important. Badly coded (or unfinished) video games typically lag (see Stalker, for example), regardless of the driver. [[User:Hervegirod|Hervegirod]] 22:05, 8 September 2007 (UTC)
:: I use C/C++ for real works (used to it + more portable), however if to think for desktop then my impression is that the java as language is also good looking, often easier to write than C++ and very quick language. Articles about "java perfomance" in wikipedia can no way raise the speed of the programs you write. What makes the real applications in java commonly slow is probably the widespread programming style. Feels like java developers do not often concentrate on solving the real problems of their users quickly and simplily and elegantly. Java developers seemingly concentrate (as first thing) on the modularity of software and the engineering process and feature-richness of their classes and modules (also important and welcome). However when one forgets for what he does it all ... it may result with perfect-looking foam factories (just a waste of power). java engines now optimize the bloat out runtime. Adjusting things with such a powerful engines drags down the starting and loading performance. So like usual ... the problems may lay between the chair and keyboard. Vambola Kotkas [[Special:Contributions/212.47.207.152|212.47.207.152]] ([[User talk:212.47.207.152|talk]]) 13:58, 4 February 2008 (UTC)
Line 55 ⟶ 60:
While Java may be able to do escape analysis more often than C++, it can be used sometimes in C++. For example the following code:
 
<syntaxhighlight lang="text">
<code>
class Bar {
int inc(int i) { return i + 1 }
Line 65 ⟶ 70:
delete b;
}
</syntaxhighlight>
</code>
 
with this code the compiler can know, that b will never be used outside of the function foo. I agree that pointers make escape analysis harder, but under certain conditions the compiler can verify that varibles do not escape a funciton. BTW, I have not programmed in C++ in a long time. Thus I may have made some syntactic errors.
Line 74 ⟶ 79:
[[User:213.237.48.86|213.237.48.86]] 19:21, 11 October 2007 (UTC)
: "the compiler != the compiler". Java is compiled twice. Generics and there cast are added by the javac complier. The JIT-Complier may produce different code. In the case of generics hints are added for the runtime, which can be used to optimize the code. However you can't guarantee type-saftie as you can cast any Collection to a generic collection and add different types of Objects. Java7 or Java8 will propably address it by introducing generic types into the jvm itself. --[[Special:Contributions/141.84.69.20|141.84.69.20]] ([[User talk:141.84.69.20|talk]]) 17:37, 5 May 2008 (UTC)
 
{{reflist-talk}}
 
==Program Speed 2==
Line 208 ⟶ 215:
: There are two reasons why Java JIT compiler can rearrange calls to foo and bar, first is because there are no pointers in java, making it easier for the compiler to prove that the reordering (or inlining) will not change anything, second is because of deoptimization, the JIT compiler can make aggressive optimizations based on assumptions (not proof), and deoptimize the code (un-JIT it) if it appear over the time that its assumptions were not true anymore. Concerning your Apple / Fruit example, arrays are objects not pointers in Java, so you are not allowed to put something which is not an Apple in an Apple array. In C/C++, you can put anything in it since an array is just a pointer. [[User:Hervegirod|Hervegirod]] ([[User talk:Hervegirod|talk]]) 17:18, 23 October 2011 (UTC)
:: In this example, it cannot be 'easier' because cost of this for C/C++ is zero. Aggressive (dangerous) optimizations, again, involve run-time check. "No pointers" is more a naming issue. In C, if you have struct complex { float re,im; }; and never take addresses of its fields - re and im (why would you?), but only take addresses of struct complex - you get the same "no pointers" situation as in Java. You miss the Apple/Fruit example entirely. Java disallows this only at run-time, inserting dynamic type-checks. C++ disallows at compile-time. Well you can still put a Pear in Apple array (do you even know how? a simple typecast won't work), but it violates the rules. For one thing you can be sure, there will be no dynamic check for that just because compiler wasn't clever enough to prove it is not necessary.
<sourcesyntaxhighlight lang="java">
class aa {
static class Fruit{}
Line 219 ⟶ 226:
}
}
</syntaxhighlight>
</source>
[[User:Alliumnsk|Alliumnsk]] ([[User talk:Alliumnsk|talk]])
:: The fact that Java hides pointer semantics from the programmer means nothing about the underlying architecture. Actually, ''every'' object in Java is a pointer, wrapped in a shiny name "reference", except for the primitives.[[User:1exec1|1exec1]] ([[User talk:1exec1|talk]]) 23:08, 25 October 2011 (UTC)
Line 302 ⟶ 309:
If you would like me to provide more information on the talk page, contact [[User:Cyberpower678]] and ask him to program me with more info.
 
From your friendly hard working bot.—[[User:Cyberbot II|<span style="color:green;font-family:Neuropol">cyberbot II</span>]] [[User talk:Cyberbot II|<sup style="color:green;font-family:arnprior">Notify</sup>]]<sub style="margin-left:-6.1ex;color:green;font-family:arnprior">Online</sub> 18:33, 8 December 2013 (UTC)
 
== Self-contradictory Information in Summary and Body ==
Line 325 ⟶ 332:
 
While performance of running programs is covered, something everyone knows but never discussed is how slow java server apps (jvms) are to start (and stop). I don't think it's a small matter, either, as a simple restart is no longer trivial enough to not have to build tooling around, since restarts can take over a minute (and cause outages). I feel it should be mentioned. <!-- Template:Unsigned --><small class="autosigned">—&nbsp;Preceding [[Wikipedia:Signatures|unsigned]] comment added by [[User:Kelt65|Kelt65]] ([[User talk:Kelt65#top|talk]] • [[Special:Contributions/Kelt65|contribs]]) 00:14, 20 October 2016 (UTC)</small> <!--Autosigned by SineBot-->
 
== External links modified ==
 
Hello fellow Wikipedians,
 
I have just modified 6 external links on [[Java performance]]. Please take a moment to review [[special:diff/811641512|my edit]]. If you have any questions, or need the bot to ignore the links, or the page altogether, please visit [[User:Cyberpower678/FaQs#InternetArchiveBot|this simple FaQ]] for additional information. I made the following changes:
*Added archive https://web.archive.org/web/20100331155325/http://www.cherrystonesoftware.com/doc/AlgorithmicPerformance.pdf to http://www.cherrystonesoftware.com/doc/AlgorithmicPerformance.pdf
*Added {{tlx|dead link}} tag to https://jdk.dev.java.net/verifier.html
*Added archive https://web.archive.org/web/20070105224757/http://weblogs.java.net/blog/campbell/archive/2005/07/strcrazier_perf.html to http://weblogs.java.net/blog/campbell/archive/2005/07/strcrazier_perf.html
*Added archive https://web.archive.org/web/20060516011057/http://forums.java.net/jive/thread.jspa?messageID=94530 to http://forums.java.net/jive/thread.jspa?messageID=94530
*Added archive https://web.archive.org/web/20080221131118/http://www.informit.com/guides/content.aspx?g=cplusplus&seqNum=195 to http://www.informit.com/guides/content.aspx?g=cplusplus&seqNum=195
*Added archive https://web.archive.org/web/20050214080519/http://janet-project.sourceforge.net/papers/jnibench.pdf to http://janet-project.sourceforge.net/papers/jnibench.pdf
*Added {{tlx|dead link}} tag to https://jna.dev.java.net/
*Added archive https://web.archive.org/web/20091015215436/http://developer.yahoo.net/blogs/hadoop/2008/07/apache_hadoop_wins_terabyte_sort_benchmark.html to http://developer.yahoo.net/blogs/hadoop/2008/07/apache_hadoop_wins_terabyte_sort_benchmark.html
 
When you have finished reviewing my changes, you may follow the instructions on the template below to fix any issues with the URLs.
 
{{sourcecheck|checked=false|needhelp=}}
 
Cheers.—[[User:InternetArchiveBot|'''<span style="color:darkgrey;font-family:monospace">InternetArchiveBot</span>''']] <span style="color:green;font-family:Rockwell">([[User talk:InternetArchiveBot|Report bug]])</span> 23:21, 22 November 2017 (UTC)
 
== Most of the memory use section is really odd nitpicks ==
 
For example, "if the size of an object is not 8, it is rounded up to 8" is not just something Java does -- it's C++ and other such languages too. Citing this as a Java thing is not exactly prudent. As well, the lack of address arithmetic (as said in article) is simply a consequence of a GC-based language, and most of the structures listed aren't something I see as necessitated.
 
The memory use of the JVM and such are per-implementation, and therefore not something that can be broadly said to apply to Java.[[Special:Contributions/216.186.142.254|216.186.142.254]] ([[User talk:216.186.142.254|talk]]) 19:34, 16 August 2019 (UTC)