News for hackers. Stuff that matters.
Re:Idiomatic Generics in Go by masklinn on Tuesday September 30, 2014 @12:38PM (#8389213)
Well it's pretty close to Java pre-1.5, which I guess was fine back in the 90s.
Re:Idiomatic Generics in Go by norswap on Tuesday September 30, 2014 @06:26PM (#8391747)
Precisely, more than 10 years have passed. And Java evolved for a reason, I think. And releasing Java without generics may not have been a smart thing even back then.
Re:Idiomatic Generics in Go by NateDad on Tuesday September 30, 2014 @02:05PM (#8389877)
Except go has value types and closures and first class functions and implicit interfaces and multiple return values....
Re:Idiomatic Generics in Go by pjmlp on Tuesday September 30, 2014 @06:12PM (#8391664)
Yeah it wins over Java 1.5, but it looses against so many 80's and 90's languages, which offer all of that and, wait for it...., generics.
Re:Idiomatic Generics in Go by NateDad on Tuesday September 30, 2014 @02:34PM (#8390154)
Oh yeah, and generic lists and maps And built-in testing infrastructure, performance testing, code distribution, linting, code formatting, parsing and AST libraries...
Re:Idiomatic Generics in Go by papaf on Tuesday September 30, 2014 @04:54PM (#8391150)
And a built in dependency manager, build tool, documentation generator...
Re:Idiomatic Generics in Go by dkarapetyan on Tuesday September 30, 2014 @06:10PM (#8391653)
But generics crosses the line because compile-time code generation is so much clearer and simpler and doesn't add any overhead to compilation times because code substitution is not compilation.
Re:Idiomatic Generics in Go by pjmlp on Tuesday September 30, 2014 @06:13PM (#8391670)
pre-Java 1.5 already had all of that.
Re:Idiomatic Generics in Go by burntsushi on Tuesday September 30, 2014 @07:16PM (#8391976)
Where was pre-Java 1.5's generic HashMap? Or closures?
Re:Idiomatic Generics in Go by pjmlp on Wednesday October 01, 2014 @03:23AM (#8393208)
> Where was pre-Java 1.5's generic HashMap?

In java.util.Hashtable as implementation of the java.util.Dictionary interface, since version 1.1 back in 1997.

Implemented using s/interface{}/Object/g with ability to use any type as key, as long as, hashCode() and equals () are overriden.

Also allows for fine tuning of the capacity and load factor.

> Or closures?

In anonymous inner classes. A pain to use when compared with real closures, but doable nonetheless.

Re:Idiomatic Generics in Go by burntsushi on Wednesday October 01, 2014 @06:59AM (#8393707)
That is not a generic HashMap. See masklinn's response.

The fact is, the comparison between Go and "pre generics Java" is a bad one. There are many substantial differences, and blessed parameterized types in Go is absolutely one of them.

Re:Idiomatic Generics in Go by masklinn on Wednesday October 01, 2014 @05:42AM (#8393535)
In the discussion's context, "generic" is about parameterized types (type-safe collections), not about working on any object.
Re:Idiomatic Generics in Go by pjmlp on Wednesday October 01, 2014 @07:01AM (#8393710)
Which Go lacks and the OP was stating it has.
Re:Idiomatic Generics in Go by masklinn on Wednesday October 01, 2014 @09:09AM (#8394071)
* Go has a generic hashmap, the builtin map type is one of the magical special-status generic collections (with arrays, slices and channels).

* pre-1.5 Java did not have one, its only parametric type was the low-level array

Re:Idiomatic Generics in Go by pjmlp on Wednesday October 01, 2014 @10:25AM (#8394531)
Ah, ok. That is correct.