The approach is interesting, but I'd really rather see a better name.
"un" or "us" might be preferable?
My only suggestion would be a meta one, which is that I would suggest using a nice, full name and letting people shortcut it themselves. "un" is hard to search for.
But unfortunately, from a quick glance it looks like Go's doesn't, is that correct?
It also breaks the conventions for Go package names. Except for the standard library, packages should be in hostname.tld/path/to/repo
e.g.: github.com/ChimeraCoder/anaconda
This is convenient because the import identifier, the relative path to the package on the filesystem (using $GOPATH as the root), and the location of the package on the Web are all the same.
If I saw this as an import, I would be confused as to where to go to find the canonical URL for the package.
Underscore seems like it would not at all be a good fit for Golang. Golang really wants you to just use a for-loop.
I really dislike being that guy, but there's no reason why a language, today, shouldn't implement a decent map shorthand construction. For loops and unnecessary visual burden for a large variety of tasks and give no hint to the semantics of the code within a loop (is my loop doing a map, a transform, a reduction?).
Go was designed for systems programming, and the code is intentionally verbose. A few extra characters, brackets, and syntactic constructs are a small price to pay for more control in performance-critical applications.
JavaScript was designed for the web to make authoring interactive pages easier. The web benefits as an ecosystem to have commonly-used abstractions for lower-level data transformations and common tasks.
So yes, there are reasons why a map shorthand is not needed. Mostly because it doesn't do anything a loop cannot, and the ecosystem in which it was developed does not benefit from it.
I can understand programmers wanting FP concepts and techniques in languages like C++; there is a lot of legacy C++ code, libraries and overall a large ecosystem. Some C++ programmers might either
1) have started programming in C++ many years ago (let's say 8+ years ago), and they might have thought that procedural and OO concepts where all that they wanted in C++. Now they might see some benefit in FP concepts, and want to see them used in C++, too. They don't want to switch languages because they already like C++ overall, and they have invested a lot of time into it.
2) They are "stuck" with C++ because of libraries, legacy code etc.
But the Go language is, what, 5 years old? It probably also has less legacy code, and I guess also relatively lacking ecosystem of libraries compared to other more established (or just older) languages. Why shoehorn FP concepts into Go instead of just moving on to a language where these concepts aren't seemingly going against the grain of the design of the language? Do most people really have a lot to lose from "ditching" Go?
This has come from some work I have been doing in Go. I was finding it very repetitive to constantly create basic constructs for common operations and patterns.
The approach I have been working with is using reflection based helpers to move fast, especially while exploring a problem space, and then refactor as appropriate when the design has solidified.
One advantage of underscore.go is you can create typed functions, so you aren't losing the compiler's help. The performance is generally OK, it is obviously slower than raw loops, but I think the tradeoff in many cases is worth it. In my experience, development time is a scarcer resource than cpu cycles. And nothing about this prevents you from gaining those cycles back when you need to.
It shows that the author knows how to code go, but I get the impression that go programmers are more picky about idiomatic code than even python programmers, so if the author wants to get into go development, the author should probably stop that and work on something more idiomatic.
stoppy
But yeah. This is all WIP and I haven't done any real cleanup. I posted it to some go friends on Twitter, it wasn't quite meant to become "news".
I was interested in seeing the implementation of the Parallel Map, but on a quick browser through the source, could not find it.
If you're interested in other works in the same space, I think think the the Gen library (http://clipperhouse.github.io/gen/) goes a long way towards providing type-safe, idiomatic, Go code to achieve the same effects.
The default ‘genwriter’ package does LINQ/underscore stuff. If someone wanted to go further with it, they could create a new package (or extend that one).
Underscore.go is a mostly WIP that I hadn't intended to go live on HN :)
The general feedback so far is __ is annoying, I thought it was cool and if people were annoyed they could fix it on import. But I might be quite wrong on this one.
The directory layout is going to change and I am working on a branch at the moment that splits the whole thing into a file per algorithm, which makes things much easier to work with.
Yeah, I'm a bitch.
While this could be considered pedantic idolatry by some, Codegangsta's very public admission on his experience with Martini (and now Negroni) show that this is a something to be considered when launching shiny new baubles.
In my opinion, the more attempts at stuff like this, the better. This is how we all learn!
http://blog.codegangsta.io/blog/2014/05/19/my-thoughts-on-ma...
https://github.com/tobyhede/underscore.go/blob/master/src/un...
https://github.com/tobyhede/underscore.go/blob/master/src/un...
https://github.com/mediocregopher/seq
It isn't quite as pretty as this one is, but it does support (thread-safe) lazy sequences.
As someone who writes lots of go code, I don't think either of these are actually necessary, although they may be fun to use in some cases.
This doesn't make things very slow but not very faster either. When you need performance, a code generator like this can help: http://clipperhouse.github.io/gen/