Content deleted Content added
Reverted 4 edits by Roman ali12 (talk): Rv edits to a bot's talk page message |
syntaxhighlight & fix lint |
||
(4 intermediate revisions by 2 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 210 ⟶ 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 221 ⟶ 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 304 ⟶ 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 ==
|