News for hackers. Stuff that matters.
Re:Go package: fanout – make writing parallel code even easier by TheDong on Saturday January 10, 2015 @03:42AM (#8866328)
Oh, hey, it's a generic package that means you lose type safety and saves you from writing roughly 10 lines of code.

Buffered channels + goroutines + WaitGroup already allow you to implement this trivially, and because channels are builtin generic, you can do it without the nasty type casts. Really, []interface{} is a terrible type to work with.

Re:Go package: fanout – make writing parallel code even easier by coldtea on Saturday January 10, 2015 @06:56AM (#8866629)
>Oh, hey, it's a generic package that means you lose type safety and saves you from writing roughly 10 lines of code.

Or actually, it's not a generic (as in generics) package, which is why you lose type safety.

Re:Go package: fanout – make writing parallel code even easier by chimeracoder on Saturday January 10, 2015 @10:44AM (#8866979)
> Or actually, it's not a generic (as in generics) package, which is why you lose type safety.

Can we please skip just one opportunity to begin this endless flamewar on a HN post about Go? Just one? Please?

This topic has been beaten to death and beyond, and is not relevant to TFA at all, as the word "generic" can be used in many contexts, and it's more than clear which context OP meant.

Re:Go package: fanout – make writing parallel code even easier by coldtea on Saturday January 10, 2015 @04:13PM (#8867934)
>and is not relevant to TFA at all

How is it not relevant to TFA? This is a speficic example of the problem with not having generics!

Re:Go package: fanout – make writing parallel code even easier by sunfmin on Saturday January 10, 2015 @03:54AM (#8866342)
Yes, I often find myself lost in this trivial channels + goroutines + WaitGroup combination. For my self I'd prefer cast interface{}, :-)
Re:Go package: fanout – make writing parallel code even easier by chimeracoder on Saturday January 10, 2015 @10:40AM (#8866963)
interface{} is different from []interface{}.

You can do a type assertion (not cast - these are different concepts) from interface{} to another type. You cannot do a type assertion on []interface{}; you have to iterate over each element and assert individually.

I agree with GP - the built-in primitives for synchronization, along with sync from the stdlib, are much cleaner once you know how to use them, and they're more idiomatic.

Re:Go package: fanout – make writing parallel code even easier by namelezz on Saturday January 10, 2015 @12:14PM (#8867168)
Is interface{} similar to type erasure on JVM?
Re:Go package: fanout – make writing parallel code even easier by TheDong on Saturday January 10, 2015 @01:27PM (#8867453)
No, it's most like "Object" in Java.