News for hackers. Stuff that matters.
Re:Another go at Go failed by tomp on Wednesday January 08, 2014 @07:58AM (#7023177)
What is the (declared) type of `SetUnion`? Don't forget, Go has no generics/parametric polymorphism.
Re:Another go at Go failed by lafar6502 on Wednesday January 08, 2014 @08:30AM (#7023314)
So, are you saying that it's impossible to declare a function without generics? How did the world run before generics were invented?
Re:Another go at Go failed by Pxtl on Wednesday January 08, 2014 @10:02AM (#7023849)
> How did the world run before generics were invented?

We used code-generators or pre-compiler macros or dynamically typed languages or we hand-wrote heaps upon heaps of boilerplate.

It sucked.

And regardless, Go only offers the last option.

Re:Another go at Go failed by sixthloginorso on Wednesday January 08, 2014 @08:35AM (#7023335)
The author said that he needed a generic set for different concrete types, so he'd have to write a bunch of these functions for all the combinations he needed. And he did. And it was a mess. And it was also slow.

Edit: not that we can conclude anything from the lack of performance, though, we don't know how it was written.

Re:Another go at Go failed by lafar6502 on Wednesday January 08, 2014 @08:46AM (#7023384)
I believe it was a mess. But i don't believe it couldn't be done correctly in Go or whatever language you take.
Re:Another go at Go failed by Roboprog on Wednesday January 08, 2014 @11:27AM (#7024479)
My guess would be too much "noun oriented thinking".

Some of us came of age before the tyranny of King Java, learning such obsolescent tools as Pascal, Lisp and C back in school. (I'm gonna ignore BASIC and FORTRAN, other than as examples of what not to do) We learned how to pass around individual functions/procedures to support library code.

http://steve-yegge.blogspot.com/2006/03/execution-in-kingdom...

Re:Another go at Go failed by dded on Wednesday January 08, 2014 @08:38AM (#7023344)
No, the problem is that SetUnion needs to be implemented six times for six different data types.
Re:Another go at Go failed by sixthloginorso on Wednesday January 08, 2014 @08:49AM (#7023403)
Well, as we all know, Go does give you a way, sort of. You'd have to write basically a dynamic version using interface {}, and then write wrappers casting the values in and out, and possibly handing out the equality predicate.

That sucked in Java at the time, though, when you had to screw around casting Objects in your code, I don't see why people would prefer that.

Re:Another go at Go failed by frou_dh on Wednesday January 08, 2014 @09:20AM (#7023566)
Surprisingly, Erik Meijer (Haskell, C#) can somewhat see the appeal of no generics and a bit of casting:

22m-31m http://www.youtube.com/watch?v=on5DeUyWDqI#t=22m

(I give myself and Google a pat on the back for being able to remember and quickly find this!)

Re:Another go at Go failed by Paradigma11 on Thursday January 09, 2014 @07:44AM (#7030111)
Thanks.
Re:Another go at Go failed by corresation on Wednesday January 08, 2014 @10:10AM (#7023906)
For the app being described, would there really be six different type signatures required?

Generics would absolutely be nice for Go, primarily because they would allow the core libraries to provide all of these rich collections. However if we're discussing the notion that someone can write these themselves, it just seems contrived that people think generics are critical for any specific app -- in the example he described, it sounds like he would need one single concrete implementation.

Re:Another go at Go failed by tomp on Wednesday January 08, 2014 @08:46AM (#7023387)
No, only that in Go it's impossible to abstract the code that implements the "set union" functionality into a function.
Re:Another go at Go failed by Roboprog on Wednesday January 08, 2014 @11:19AM (#7024423)
I'm going to disagree:

    new_set = old_set.union( another_set, element_comparator_func);
If you allow some helper functions or an interface to do things such as compare/hash members, it's totally doable. Extra points for passing the helper(s) into the constructor.

Yes, you can still mismatch set types, but the casting/type-assertion in the helpers will fail with an explicit reason.

Re:Another go at Go failed by Roboprog on Wednesday January 08, 2014 @11:17PM (#7028731)
Almost forgot: in Go, classes aren't "closed". While you cannot "monkey patch" and change existing methods, you can define new functions, such as my_set_comparator, that accept each given type as "this". You would then make a new interface, such as my_set_element, which defines method my_set_comparator, and any data types for which you had defined my_set_comparator would automagically meet the new interface.