1. 4
  1.  

  2. 2

    I think “0 is true” is right thing. In Perl and PHP even empty string is false which doesn’t make sense.

    1. 1

      Regarding the part about Java using the same reference for small integers, the author wrote,

      even if the performance benefits are worth it

      But are they really? Making things faster by breaking the == operator is cringe-inducing. Is there some place where this property is so useful that it justifies itself?

      I mean if you want to write something that’s really, really fast, you don’t really look at Java (fast as it is), you’d likely go for something like C.

      1. 3

        Interning strings is something that the JVM supports, though I’ve never been able to find compelling studies that measure its usefulness. It’s also easy enough in Java that if I ever found a need, I would probably give interning a shot before doing a rewrite in C.

        I could imagine it being worth it if you have an application that caches a lot of data with in-memory maps/lists and you need to make the list.contains/list.find/map.get methods fast. All those rely on Object.equals, so being able to speed up equality checking could have a real effect.