News for hackers. Stuff that matters.
Re:The Next Step for Generics by jasonhansel on Tuesday June 16, 2020 @05:13PM (#23544209)
Go really should have learned 2 lessons from Java 5:

1. People will eventually want generics 2. Retrofitting generics onto an existing language is hard and leads to unusual problems

(edit: I'm glad Go is doing this, but...Java learned this in 2004.)

Re:The Next Step for Generics by kjksf on Tuesday June 16, 2020 @06:25PM (#23545055)
There's is a design document for Go generics.

If you see "unusual problems" with the design, then tell us what they are.

Otherwise it's just shallow pattern matching "Java added generics late, they had problems, Go added generics late therefore they'll have problems too".

Counterexample: C# added generics late and it's perfectly fine design.

The reason Go team is not rushing to implement generics is precisely so that the design makes sense, in the context of Go.

Over the years Ian Taylor wrote several designs for generics, all of which were found to not be good enough.

They are doing it the right way: not shipping until they have a good design and they didn't have good design when Go launched.

Re:The Next Step for Generics by mikelward on Tuesday June 16, 2020 @05:21PM (#23544324)
If this follows the monomorphic approach described in Featherweight Go [1][2], they will at least avoid problems caused by type erasure and avoid too much runtime overhead.

1. https://arxiv.org/abs/2005.11710 2. https://news.ycombinator.com/item?id=23368453

Re:The Next Step for Generics by jasonhansel on Tuesday June 16, 2020 @05:31PM (#23544465)
But then you have compile time overhead (an issue Rust and C++ have faced). One of Go's design goals was to have very fast compile times, which might be in doubt if they take the monomorphization approach.
Re:The Next Step for Generics by entha_saava on Wednesday June 17, 2020 @12:15AM (#23547717)
Is rust's slow compile time because of poor LLVM IR generation or just because monomorphization? D has generics and compiles fast. I guess Nim compile times are okay, too..
Re:The Next Step for Generics by Ericson2314 on Tuesday June 16, 2020 @06:31PM (#23545095)
Go is just Java repeated as farce. The histories are almost identical with ~10 years lag.

We all called this when Go was created, too.

Re:The Next Step for Generics by cies on Wednesday June 17, 2020 @02:37AM (#23548456)
Just without the "VM".
Re:The Next Step for Generics by Ericson2314 on Wednesday June 17, 2020 @07:01PM (#23557852)
JAVA -> Go + WASM is conservation of MEMEs? :D

(Not to disparage WASM, which has some nice ideas both on the technical and ecosystem level.)

Re:The Next Step for Generics by neop1x on Wednesday June 17, 2020 @07:23PM (#23558030)
Thanks but I don't need another Java. Enjoy your full Java and keep Go doing things go-way. :)
Re:The Next Step for Generics by gowld on Tuesday June 16, 2020 @05:34PM (#23544494)
Are you saying Go should have not launched in 2009, but shout have waited 10 years until generics were ready?
Re:The Next Step for Generics by jeremyjh on Tuesday June 16, 2020 @06:21PM (#23545020)
If they made it a priority they could have shipped in 2010 with generics. There is no new art in this design.
Re:The Next Step for Generics by AaronFriel on Tuesday June 16, 2020 @07:37PM (#23545702)
Go has the unfortunate circumstances of its birth being before widespread recognition of the value of generics and better type systems. Those ideas existed in many languages, and in the PL community, and they were starting to take hold in other languages, but the consensus for most software engineers was that "sum types" are hard and "generics" aren't necessary and the type system should stay out of the way.

I think TypeScript, Scala, Kotlin, C#, and various others I forget now proved that these things weren't a fad and could yield significant gains in productivity and code correctness.

Had Rob Pike been more forward looking (or hired Anders Hejlsberg or Guy Steele to design the language) or dipped further into the PL research, he might have been so bold himself. I don't think anyone can fault him for it, these were niche and minority views in 2010 and may not even be in the majority today.

I think at the same time, we see what happens when a new language has large corporate backing in more recent years. Swift more closely resembles Rust than Go in terms of its type system.

Re:The Next Step for Generics by plorkyeran on Tuesday June 16, 2020 @08:15PM (#23546052)
"Generics are useful" was not even remotely a niche view in 2010. That was already 6 years after Java got them, and the lack of generics in Go was a common criticism from day one.
Re:The Next Step for Generics by exdsq on Wednesday June 17, 2020 @03:35AM (#23548830)
Philip Wadler introduced generics into Java and had previously designed Haskell, so he must have been thinking about types for at least a further 15 years before Java (20 years before Go).
Re:The Next Step for Generics by fooster on Tuesday June 16, 2020 @08:38PM (#23546245)
This is such a bullshit argument. Why is it that any go post on hacker news pulls out all the tropes. Lack of exceptions. Lack of generics. Would generics make go a better a language? Maybe. Does the lack of generics make go objectively bad? Hell no!

I've had a long career coding in C, C++, Java, Lisp, Python, Ruby... you name it I've done it. Go is my favorite most productive language by far for solving typical backend issues. My least favorite? Java by a HUGE mile.

Re:The Next Step for Generics by twblalock on Tuesday June 16, 2020 @09:50PM (#23546803)
> Why is it that any go post on hacker news pulls out all the tropes. Lack of exceptions. Lack of generics.

It's pretty simple -- those of us who use those feature regularly in other languages know how valuable they are, and we miss them when they aren't there.

Re:The Next Step for Generics by cies on Wednesday June 17, 2020 @02:45AM (#23548498)
> Lack of exceptions

Is that really a problem? I think proper sum types to allow Result types that can encode many success/error states are so much nicer than an exception hierarchy. Rust and Kotlin did not go with exceptions, and for good reasons.

> C, C++, Java, Lisp, Python, Ruby... you name it I've done it.

Let me name a few: Rust, Kotlin, OCaml/Reason, Haskell, Elm. These languages carefully selected a set of features, the all have: no implicit nulls and sum types. And in your list non of them have those features. I really wonder what you think of these features when you've worked with them.

Re:The Next Step for Generics by aa66tt55rr44 on Wednesday June 17, 2020 @08:59AM (#23550815)
> Kotlin

Kotlin very much did go with exceptions except for the Result type in coroutines which wraps a Throwable anyway and is only used for the border between the coroutine runner and the async functions.

Re:The Next Step for Generics by dcgudeman on Tuesday June 16, 2020 @11:45PM (#23547525)
Why do you dislike java so much?
Re:The Next Step for Generics by AaronFriel on Tuesday June 16, 2020 @09:01PM (#23546435)
It was a common criticism but I don't think it was a majority criticism. Hacker News is not representative of the internet at large, and the idea that Go doesn't need or might not even benefit from generics is still pervasive. (See the first person to reply to you.)
Re:The Next Step for Generics by Carpetsmoker on Wednesday June 17, 2020 @12:23PM (#23553224)
The Go authors acknowledged the usefulness of generics as far back as 2009, shortly after its public release: https://research.swtch.com/generic