TE
科技回声
首页24小时热榜最新最佳问答展示工作
GitHubTwitter
首页

科技回声

基于 Next.js 构建的科技新闻平台,提供全球科技新闻和讨论内容。

GitHubTwitter

首页

首页最新最佳问答展示工作

资源链接

HackerNews API原版 HackerNewsNext.js

© 2025 科技回声. 版权所有。

Underscore.go

140 点作者 Goranek将近 11 年前

16 条评论

jerf将近 11 年前
Underscore was chosen in JS presumably because it is a valid variable name that isn&#x27;t used for anything. Underscore in Go actually means something, which is why this is actually <i>double</i>-underscore, which makes it even visually more confusing.<p>The approach is interesting, but I&#x27;d <i>really</i> rather see a better name.
评论 #8065489 未加载
评论 #8066570 未加载
评论 #8065592 未加载
评论 #8065084 未加载
评论 #8065764 未加载
评论 #8065261 未加载
tptacek将近 11 年前
Underscore is not a perfect fit for JS, but it&#x27;s close enough; if you like coding in the style Underscore promotes, Underscore.js makes Javscript programming simpler.<p>Underscore seems like it would <i>not at all</i> be a good fit for Golang. Golang really wants you to just use a for-loop.
评论 #8066569 未加载
评论 #8066585 未加载
评论 #8066888 未加载
benatkin将近 11 年前
What is the term for unpythonic in the Go community? This seems to be it. By the way it isn&#x27;t using gofmt. <a href="https://github.com/tobyhede/underscore.go/blob/master/src/underscore_test.go" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;tobyhede&#x2F;underscore.go&#x2F;blob&#x2F;master&#x2F;src&#x2F;un...</a><p>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.
评论 #8067112 未加载
评论 #8066598 未加载
评论 #8066341 未加载
评论 #8066583 未加载
ChikkaChiChi将近 11 年前
The Go community is still small enough that any packages like this that get promoted become cringe-worthy if they are not idiomatic. If someone is coming from a javascript background and this is the first package they see, it might give them the wrong idea about Go.<p>While this could be considered pedantic idolatry by some, Codegangsta&#x27;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.<p>In my opinion, the more attempts at stuff like this, the better. This is how we all learn!<p><a href="http://blog.codegangsta.io/blog/2014/05/19/my-thoughts-on-martini/" rel="nofollow">http:&#x2F;&#x2F;blog.codegangsta.io&#x2F;blog&#x2F;2014&#x2F;05&#x2F;19&#x2F;my-thoughts-on-ma...</a>
tobyhede将近 11 年前
Oh hello. Library author here.<p>Underscore.go is a mostly WIP that I hadn&#x27;t intended to go live on HN :)<p>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.<p>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.
评论 #8067524 未加载
alexpw将近 11 年前
Not quite as interesting to see an _ clone after watching this critique of _ <a href="https://www.youtube.com/watch?v=m3svKOdZijA" rel="nofollow">https:&#x2F;&#x2F;www.youtube.com&#x2F;watch?v=m3svKOdZijA</a>
garfij将近 11 年前
Neat. I like that you can add your own type specific functions.<p>I was interested in seeing the implementation of the Parallel Map, but on a quick browser through the source, could not find it.<p>If you&#x27;re interested in other works in the same space, I think think the the Gen library (<a href="http://clipperhouse.github.io/gen/" rel="nofollow">http:&#x2F;&#x2F;clipperhouse.github.io&#x2F;gen&#x2F;</a>) goes a long way towards providing type-safe, idiomatic, Go code to achieve the same effects.
评论 #8065254 未加载
jprob将近 11 年前
If there&#x27;s a `src` folder in your repo, you&#x27;re doing it wrong.
评论 #8066781 未加载
评论 #8067625 未加载
ankurpatel将近 11 年前
Similar to <a href="https://github.com/markmontymark/underscore-go" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;markmontymark&#x2F;underscore-go</a>
pjmlp将近 11 年前
Love how the library takes advantage of Go&#x27;s generics to expose parametric functional programming.<p><a href="https://github.com/tobyhede/underscore.go/blob/master/src/underscore.go#L59" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;tobyhede&#x2F;underscore.go&#x2F;blob&#x2F;master&#x2F;src&#x2F;un...</a><p><a href="https://github.com/tobyhede/underscore.go/blob/master/src/underscore.go#L85" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;tobyhede&#x2F;underscore.go&#x2F;blob&#x2F;master&#x2F;src&#x2F;un...</a>
mediocregopher将近 11 年前
As a shameless, related plug, here&#x27;s a clojure-like seq library I wrote for go:<p><a href="https://github.com/mediocregopher/seq" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;mediocregopher&#x2F;seq</a><p>It isn&#x27;t quite as pretty as this one is, but it does support (thread-safe) lazy sequences.<p>As someone who writes lots of go code, I don&#x27;t think either of these are actually <i>necessary</i>, although they may be fun to use in some cases.
ahmett将近 11 年前
I have done something similar in the past: <a href="http://ahmetalpbalkan.github.io/go-linq/" rel="nofollow">http:&#x2F;&#x2F;ahmetalpbalkan.github.io&#x2F;go-linq&#x2F;</a> (<a href="https://github.com/ahmetalpbalkan/go-linq" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;ahmetalpbalkan&#x2F;go-linq</a>) this also has filter&#x2F;map functions (where&#x2F;select in LINQ) I haven&#x27;t used reflection but callers should make type assertions needed.<p>This doesn&#x27;t make things very slow but not very faster either. When you need performance, a code generator like this can help: <a href="http://clipperhouse.github.io/gen/" rel="nofollow">http:&#x2F;&#x2F;clipperhouse.github.io&#x2F;gen&#x2F;</a>
findjashua将近 11 年前
Using the function as the first argument and the iterable as the second, makes it easy to curry functions. A port of Ramda (<a href="https://github.com/CrossEye/ramda" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;CrossEye&#x2F;ramda</a>) would be better for this reason.
评论 #8066562 未加载
Randgalt将近 11 年前
-1 on double underscore. Very off-putting.
评论 #8066602 未加载
maninalift将近 11 年前
Ew, now you can have an awkward weak implementation of some FP ideas in Go too.<p>Yeah, I&#x27;m a bitch.
评论 #8066112 未加载
mc_hammer将近 11 年前
really cool, thx for this. just what go needs imo.