4 ms·
The author of the article needs to be reminded a bit as to how Java works and as to what "good practices" are. I'm sorry but when I stumble upon such obvious m
by martinced 14y ago
The author of the article needs to be reminded a bit as to how Java works and as to what "good practices" are.
I'm sorry but when I stumble upon such obvious mistakes I can't take such an article seriously:
"Integer boxed = 0; // i.e., boxed = new Integer(0);"
No, that's not how it works. Values between [-128..127] are guaranteed to give back cached instances: there's no object creation here.
"on a 64-bit JVM you can double the size of every pointer"
No, no and no. 64-bit JVMs do offer compressed pointers precisely to not 'waste' countless bits that are always going to be set at zero.
"...in fact boxed has the advantage of also having a 'null' value which can indicate an unset value."
Having objects which may or may not be initialized is not necessarily a very good way to code.
What's next: using NullPointerException as flow control?
Since Jetbrains / IntelliJ IDEA introduced their @NotNull annotation (years and years ago) I've been using it religiously and can hardly remember what a NPE is in my own code (it's another matter when using poorly designed 3rd party APIs of course).
But what else do you expect from a "game programmer" who writes professional games in Java? Because we all know Riot Games, Blizzard, etc. all write their games in Java without using primitives right?
And, from a performance standpoint, we all long for Java 10 which may not give access to primitives anymore right?
- struppi 14y agoSo true! Also, the JIT compiler of the JVM does dome things that are pretty close to magic, at least from my point of view. And I guess Oracle will continue to improve it. I know the following is a "Sufficiently smart compiler"-type argument, but: It's not entirely impossible that future versions of the JVM - where primitives "don't exist anymore" - would simply use primitives when they detect that it's possible.