Seriously, Go?

Pascal Cuoq - 11th Dec 2012

I used to be curious about the D programming language. D had been pitched to me as “C done right”. Even before I had time to look at it though someone on StackOverflow was having an issue that stemmed from constant floating-point expressions being evaluated at compile-time with different semantics than the run-time semantics.

The C language has this problem too. But I do not see the point of switching to a similar supposedly improved language if it does not at least fix this sort of issue.

History it turns out is cyclical modulo alpha-renaming. Today in another question on StackOverflow someone was having a hard time writing the IEEE 754 constant -0.0 as a literal in the new programming language Go.

Go was not pitched to me as a better C but it is pitched as a good replacement for some of C's applications. I had been mildly curious since I heard about it. Call me easily disappointed but here is what I learned from today's question:

  1. In the current Go implementation if you write -0.0 you get +0.0.
  2. If you write var a = 0.0 * -1.0 variable a is still initialized to +0.0.
  3. But you can obtain -0.0 if you write var a = 0.0 followed by a *= -1.0.

So Go has egregious differences between the run-time and compile-time semantics used for floating-point computations but on the plus side it sucks at recognizing static floating-point computations.

Pascal Cuoq
11th Dec 2012