Re:Playing with Go: Embarrassingly Parallel Scripts
by zmj on Monday December 03, 2012 @10:53AM
(#4865926)
I'm embarrassed how many times I've implemented the above without thinking to look for a standard lib solution. Thanks!
Re:Playing with Go: Embarrassingly Parallel Scripts
by jameskilton on Monday December 03, 2012 @10:46AM
(#4865899)
Nice. Yeah I'm very new to Go so I know almost nothing about the stdlib libraries. Thanks for the pointer.
Re:Playing with Go: Embarrassingly Parallel Scripts
by darkhelmetlive on Monday December 03, 2012 @01:45PM
(#4867049)
Tooting my own horn here, but I'm working on a book covering the Go Standard Library. Still in progress, and not at the sync package yet, but it's coming along. Check it out if you feel inclined.
Re:Playing with Go: Embarrassingly Parallel Scripts
by lsb on Monday December 03, 2012 @02:22PM
(#4867283)
You know what'd be cool? To take arbitrary code in a language, pattern match on the implementation in that language of each std lib function, and actively recommend substitutes for duplicated code.
Re:Playing with Go: Embarrassingly Parallel Scripts
by jlgreco on Monday December 03, 2012 @03:46PM
(#4867684)
That would be very cool. I wonder how hard it would be though. At least in Go I know that the standard lib contains lots of duplicate code (primarily so that things that should be small don't require larger things as dependencies. I think the time package's String() functions use reimplemented fmt package functionality for example, since fmt is a much larger dependency than time should have.)
Re:Playing with Go: Embarrassingly Parallel Scripts
by skybrian on Monday December 03, 2012 @04:02PM
(#4867786)
Yes, but outside the Go standard libraries, adding a dependency on a standard library isn't a big deal and won't add a cycle.
Re:Playing with Go: Embarrassingly Parallel Scripts
by jlgreco on Monday December 03, 2012 @04:06PM
(#4867808)
Yes. What I mean though is that if you are reimplementing, say, fmt.Printf, such a suggestion system might correctly suggest you use fmt.Printf instead, but also suggest you can use func (m Month) String() string from time, or something equally silly.
Since the standard libs in Go duplicate code, you would have to be careful that your suggestion system isn't picking up false positives. I think the idea has a lot of promise though.
Re:Playing with Go: Embarrassingly Parallel Scripts
by stock_toaster on Monday December 03, 2012 @02:43PM
(#4867383)
Looks interesting (thanks). Will certainly check it out.
Re:Playing with Go: Embarrassingly Parallel Scripts
by 0xABADC0DA on Monday December 03, 2012 @07:33PM
(#4868825)
Even so why would you write that boilerplate code out each time?
Something like this would work even better:
result = src.asyncMap { |e| dowork(e) };
Except Google Go returns several values instead of tuples, so you can't just collect all the results as-is. And with no generics it would be annoying to actually use e and the result, since they would need casts. Too bad.
Re:Playing with Go: Embarrassingly Parallel Scripts
by burntsushi on Tuesday December 04, 2012 @12:19AM
(#4869666)
Why am I not surprised to see you trolling HN too? What's all too sweet is that you've brought your anti-Go zealotry here too! Joy.
> Except Google Go returns several values instead of tuples, so you can't just collect all the results as-is.
This is false. Functions in Go do not have to return multiple values. Therefore, you can "collect all the results as-is".
> And with no generics it would be annoying to actually use e and the result, since they would need casts. Too bad.
Actually, it wouldn't be annoying, because you wouldn't use a general purpose map like you've shown. You'd use code shown in the parent.
Re:Playing with Go: Embarrassingly Parallel Scripts
by 0xABADC0DA on Tuesday December 04, 2012 @01:01AM
(#4869744)
If you think you can do asyncMap in Google Go, without casts and without manually collecting multiple return values, by all means show us the code. I would find that really interesting.
Re:Playing with Go: Embarrassingly Parallel Scripts
by burntsushi on Tuesday December 04, 2012 @02:23AM
(#4869902)
I didn't claim I could. Take your trolling elsewhere.
Instead of counting and using a done channel,