Content deleted Content added
Assessment: Java: class=B; Software: class=B (assisted) |
syntaxhighlight & fix lint |
||
(12 intermediate revisions by 6 users not shown) | |||
Line 1:
{{WikiProject
{{WikiProject
{{WikiProject Software |importance=mid}}
}}
{{Broken anchors|links=
* <nowiki>[[Metadata#Program metadata|metadata]]</nowiki>
}}
== "x times slower" ==
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">
class Bar {
int inc(int i) { return i + 1 }
Line 65 ⟶ 70:
delete b;
}
</syntaxhighlight>
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.
<
class aa {
static class Fruit{}
Line 219 ⟶ 226:
}
}
</syntaxhighlight>
[[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 345 ⟶ 352:
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)
|