Skip to content

Comment on Paul Phillips explains why he lost faith in Scala and left Typesafe [Slides]

Comments

I was hoping for a more coherent critique. The one complaint that is concrete and clear enough to evaluate is about floating-point behavior, namely this:

   scala> val x1: Float = Long.MaxValue
   x1: Float = 9.223372E18

   scala> val x2: Float = Long.MaxValue - Int.MaxValue
   x2: Float = 9.223372E18

   scala> println(x1 == x2)
   true
This is just the way floating-point arithmetic works – its granularity increases as the values you represent increase; at 2^63 its so coarse-grained that adding 2^32 has no effect. To explain in more detail, a 32-bit float only has 23 bits of significand, so at 2^63, the next representable float is 2^63/2^23 = 2^40 larger. Yes: 32-bit floats cannot represent any numbers between 2^63 and 2^63+2^40. That's a huge gap, but there's only so much you can do with 23 bits of precision. That gap is much larger than the largest 32-bit integer (2^31-1). Thus, adding the max int value has no effect whatsoever, since that delta doesn't get you anywhere close to the next representable float. The best you can do is leave the value alone when adding something so (relatively) small to it. If you want better than this, you need to use more bits.

All of this is a minor detail, but if Paul Phillips is complaining about this behavior without even taking the time to understand what's going on, for me that really undermines the credibility of the rest of his presentation.

[1] https://en.wikipedia.org/wiki/IEEE_floating_point

Yea, I caught that as well. It's really depressing how many seemingly smart competent programmers there are out there whom are completely oblivious to IEEE 754. Don't get me wrong, you're certainly free to criticize how computers do floating point, but smart people have thought long and hard about this and there are reasons for their decision, so at least try to understand those reasons first.

AboutSource Built by g1lg1l

Hackerly is an independent reader for Hacker News, built on the public HN API. Not affiliated with Y Combinator.