<i>> Using primitives is a good discipline, specifically because your default programming techniques should be clean, simple, efficient. The point isn’t that you should be prematurely optimizing your code, but rather that when given a choice between two nearly identical approaches, you shouldn’t irrationally choose the less performant option without a good reason.</i><p>By the same token, you shouldn't arbitrarily pick the non-object solution without considering the other code interacted with.<p><i>> If your language’s standard libraries included both quicksort and bubblesort, you should never choose the latter.</i><p>Not entirely true. If you know n <= 8 or some small number, you might want to.
I'm not sure how Ruby handles the numbers as objects case internally, but just because something looks like an object doesn't stop it from actually being a tagged pointer underneath, and will not have the same storage and allocation costs.
The author of the article needs to be reminded a bit as to how Java works and as to what "good practices" are.<p>I'm sorry but when I stumble upon such obvious mistakes I can't take such an article seriously:<p><pre><code> "Integer boxed = 0; // i.e., boxed = new Integer(0);"
</code></pre>
No, that's not how it works. Values between [-128..127] are guaranteed to give back cached instances: there's no object creation here.<p><pre><code> "on a 64-bit JVM you can double the size of every pointer"
</code></pre>
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.<p>"...in fact boxed has the advantage of also having a 'null' value which can indicate an unset value."<p>Having objects which may or may not be initialized is not necessarily a very good way to code.<p>What's next: using NullPointerException as flow control?<p>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).<p>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?<p>And, from a performance standpoint, we all long for Java 10 which may not give access to primitives anymore right?