News for hackers. Stuff that matters.
Re:Can Your Static Type System Handle Linear Algebra? (2014) by ADRIANFR on Wednesday April 29, 2015 @05:28PM (#9461926)
Also, ideally, you don't want to add length to width, or Hertz to Becquerel (both have [1/sec] unit). This was my humble attempt to address this with a Scala Units library: https://github.com/adrianfr/scalau
Re:Can Your Static Type System Handle Linear Algebra? (2014) by coldtea on Wednesday April 29, 2015 @05:40PM (#9462008)
If you want to find the periphery of something you DO want to add length to width...
Re:Can Your Static Type System Handle Linear Algebra? (2014) by Someone on Wednesday April 29, 2015 @06:07PM (#9462155)
No, you add the lengths of the sides. That's type-safe and generalizes from rectangles with edges parallel to the x and y axes to general polygons:

  perimeter = poly.edges.map(length).sum()
Height and width have (implicit) direction; length doesn't.

But yes, this will get hairy. For convenience, you want the ability to add heights, but that only makes sense in some cases. Two 100m high skyscrapers only make a 200m high skyscraper if you place one on top of the other.

Re:Can Your Static Type System Handle Linear Algebra? (2014) by marvy on Wednesday April 29, 2015 @06:53PM (#9462352)
Or maybe you want to find the height of an average skyscraper so you want to add and then divide. This is going too far maybe. At some point, one has to accept that not all logic bugs are type errors, and not all type errors are common enough in practice to worry about. I have no idea where that point is, but I'm sure it exists.