News for hackers. Stuff that matters.
Re:Go Contracts – Draft Design by Cthulhu_ on Monday July 29, 2019 @09:17AM (#20554276)
I think the complexity / length is a good indication as to why there's resistance to adding generics to Go; frequently, Java generics are cited since (and this is from the top of my head) it almost doubled the size of both the Java spec and its implementations (compiler, runtime). That is a lot of complexity to manage, and runs counter to what I believe is the current mindset of the Go language.

And in Java it didn't stop there; the people (person?) behind generics moved on to create Scala, a language with even more features and a notoriously complicated 25-step compilation process (see https://typelevel.org/scala/docs/phases.html) (compare with Java's six phases https://www.javatpoint.com/compiler-phases and Go's... three? Not sure, I found https://getstream.io/blog/how-a-go-program-compiles-down-to-...).

edit: Actually most of my knowledge comes from https://news.ycombinator.com/item?id=9622417, I had bookmarked it.

Re:Go Contracts – Draft Design by msbarnett on Monday July 29, 2019 @11:41AM (#20555728)
> And in Java it didn't stop there; the people (person?) behind generics moved on to create Scala, a language with even more features and a notoriously complicated 25-step compilation process

What does this have to do with anything? Scala is complex to compile for reasons far, far beyond generics. Are generics somehow guilty by association because an engineer who was once involved in an implementation of them went on to build some other complex thing?

Re:Go Contracts – Draft Design by Footpost on Monday July 29, 2019 @02:48PM (#20557964)
I'm afraid that's not the case. Generics are very easy to implement under the following reasonable conditions:

1. you don't care about performance (you simply 'box' everything),

2. you don't care about executable size (you simply specialise every generic definition to their concrete use cases -- this is what C++ compilers do),

3. you don't do reflection on types in generic definitions.

As "cinnamonheart" mentions in a sibling post, ML's generics are straightforward, and remain, despite hailing from the 1970, even today a shining example of programming language design. Unfortunately, Scala had to violate all three points above to maintain compatibility with Java, and the JVM.

Re:Go Contracts – Draft Design by apta on Monday July 29, 2019 @11:19AM (#20555459)
> And in Java it didn't stop there; the people (person?) behind generics moved on to create Scala,

Java and Scala are two very different languages, it doesn't makes sense to compare them. What you're suggesting is basically a slippery slope fallacy.

Re:Go Contracts – Draft Design by cinnamonheart on Monday July 29, 2019 @01:37PM (#20557164)
I don't think generics necessarily need to have a complex specification. Standard ML's specification, despite parametric polymorphism and parameterised modules, is incredibly small and easy to understand.
Re:Go Contracts – Draft Design by erik_seaberg on Monday July 29, 2019 @08:44PM (#20561054)
The compiler should do as much work as it possibly can. The alternative is making me do it at 0.0001 MHz because I'm made of meat.