>How does it make the program run faster? Sunfmin, wrong answer, you'd have a 20x improvement with 20 workers only with 20 cores (ignoring the limited overhead), regardless of the number of workers your queue of jobs will be consumed in number_of_jobs*single_job_duration/GOMAXPROCS.
Thanks, but there will be I/O waiting stuff right? For that whois command example, I find the CPU usage is zero if I am not running it parallel.
Go package: fanout – make writing parallel code even easier
11–20 of 26 posts
Re: Go package: fanout – make writing parallel code even easier
#12Re: Go package: fanout – make writing parallel code even easier
#13The cost of having another 3rd party deps is greater than the seconds you save from using this.
Re: Go package: fanout – make writing parallel code even easier
#14I wrote a similar Go package for running work loads in parallel, but I used beanstalkd for job/result transport. This allows me a bit more freedom to spread the workers/requesters across my network. It's a bit rough around the edges and could use some refactoring, but it works well for my uses. https://github.com/eramus/worker
Re: Go package: fanout – make writing parallel code even easier
#15I'm not sure what the usefulness of this is (apart from saving you from writing one or two functions yourself), isn't it just a parallel queue?
it's a small abstraction, but I could see it being useful. My gripe, and I don't know how to say this without people saying I'm whining about generics, is the interface{} return. Such a pain.
It's not about whinning.There is a need for that yet no real will to implement user defined one.
Re: Go package: fanout – make writing parallel code even easier
#16Oh, 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.
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
#17Re: Go package: fanout – make writing parallel code even easier
#18Although I like the idea of having some kind of API to spread the work across multiple machines, since channels are slow anyway.
Re: Go package: fanout – make writing parallel code even easier
#19Oh, 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.
Yes, I often find myself lost in this trivial channels + goroutines + WaitGroup combination. For my self I'd prefer cast 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
#20Oh, 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.
> 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.
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.