News for hackers. Stuff that matters.
Re:Proposal: Go should have generics by aninhumer on Thursday April 14, 2016 @03:37PM (#11499718)
I'd like to give them the benefit of the doubt, but even within their stated goal of "simplicity", some of their design choices still seem ignorant of PL theory. The obvious one being including a null value, which is widely recognised to be a terrible idea with pretty much no redeeming qualities.

Another subtler example is the use of multiple return values for error handling, rather than some kind of sum type. It just suggests the designer doesn't have any experience working with ADTs. (Not that I'm suggesting Go should have used full blown ADTs, just that they change the way you think about data.)

Re:Proposal: Go should have generics by AnimalMuppet on Thursday April 14, 2016 @04:05PM (#11499903)
Simplicity is, I think, a secondary goal. A big part of the motivation for creating Go was 45 minute C++ compile times. A major reason for the emphasis on simplicity is to keep the compiler fast, even on huge codebases.

So: How much would adding sum types slow down the compiler? I don't know. How fast does Go compile compared to Haskell? (Is that a fair comparison?)

Re:Proposal: Go should have generics by aninhumer on Thursday April 14, 2016 @04:44PM (#11500201)
I'm a little dubious of the speed advantage to be honest. Sure compile time is important, and C++ is pretty bad on this front, but you don't need to try that hard to do better.

And no, I don't think sum types would slow the compiler down much, especially if they were limited to a special case for error handling (which seems more in line with the rest of Go).

Re:Proposal: Go should have generics by sacado2 on Saturday April 16, 2016 @05:06PM (#11512258)
Sum types don't fit well with zero values. What is the zero value of an `(int|string)` union type ?
Re:Proposal: Go should have generics by aninhumer on Saturday April 16, 2016 @10:53PM (#11513294)
Well I don't think zero values are a very good idea to start with (if you want a default value, make it explicit), but if one insists on having them, they can just use the first case. So for your example it would be int 0.