Live data from Hacker News

Underscore.go

tobyhede.github.io

31–40 of 62 posts

Re: Underscore.go

#31
post #19

Underscore is not a perfect fit for JS, but it's close enough; if you like coding in the style Underscore promotes, Underscore.js makes Javscript programming simpler. 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 almost, but not quite, entirely agree.

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.

Re: Underscore.go

#32
post #2

Underscore was chosen in JS presumably because it is a valid variable name that isn't used for anything. Underscore in Go actually means something, which is why this is actually double -underscore, which makes it even visually more confusing. The approach is interesting, but I'd really rather see a better name.

> Underscore in Go actually means something, which is why this is actually double-underscore, which makes it even visually more confusing. 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…

Yeah. The packages isn't correctly formatted ... fixing that.

Re: Underscore.go

#33

What is the term for unpythonic in the Go community? This seems to be it. By the way it isn't using gofmt. https://github.com/tobyhede/underscore.go/blob/master/src/un... 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…

I just disagree with some of the idioms :)

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".

Re: Underscore.go

#35
post #5
post #4

Neat. I like that you can add your own type specific functions. 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.

It doesn't appear that it is complete when compared to the listed functionality on the site.

Yeah. WIP that wasn't quite news-ready. :D

Re: Underscore.go

#36

What is the term for unpythonic in the Go community? This seems to be it. By the way it isn't using gofmt. https://github.com/tobyhede/underscore.go/blob/master/src/un... 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…

goop. just kidding, i made that up, but i hope it sticks

It won't because "goop" is already a dependency manager for Go.

Re: Underscore.go

#38
post #2

Underscore was chosen in JS presumably because it is a valid variable name that isn't used for anything. Underscore in Go actually means something, which is why this is actually double -underscore, which makes it even visually more confusing. The approach is interesting, but I'd really rather see a better name.

> Underscore in Go actually means something, which is why this is actually double-underscore, which makes it even visually more confusing. 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…

It's possible to 'go get' this package using the import path "github.com/tobyhede/underscore.go/src". This import path does not follow Go conventions because the last element of the path is not the same as the package name. Otherwise, the path "github.com/tobyhede/underscore.go/src" follows Go conventions.

Re: Underscore.go

#39
post #19

Underscore is not a perfect fit for JS, but it's close enough; if you like coding in the style Underscore promotes, Underscore.js makes Javscript programming simpler. 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 like the philosophy here of "Move fast, optimize later". It is faster even if it isn't perfect for golang

Re: Underscore.go

#40
post #19

Underscore is not a perfect fit for JS, but it's close enough; if you like coding in the style Underscore promotes, Underscore.js makes Javscript programming simpler. Underscore seems like it would not at all be a good fit for Golang. Golang really wants you to just use a for-loop.

It seems that enough people are tired of such a verbose idiom in 2014 to merit a library like this. 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?).

It depends on the level of abstraction with which the language was designed.

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.

Post reply on HN