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

科技回声

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

GitHubTwitter

首页

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

资源链接

HackerNews API原版 HackerNewsNext.js

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

Go vs Java WordSorter comparison. Faster and less LOC in Golang.

3 点作者 jemeshsu超过 12 年前

2 条评论

st3fan超过 12 年前
The problem with these two examples is that they are not doing the same thing.<p>The Go version limits the number of concurrent Go routines to the number of processors.<p>The Java version on the other hand spawns 128 threads that all get started simultaneously.<p>When I remove the concurrency limiting code from the Go version it runs on 1575ms instead of 750ms. (On an 1.8 GHz i7 MacBook Air)<p>The line in question is:<p>runtime.GOMAXPROCS(runtime.NumCPU())<p>Imagine what would happen if the Java code used a ExecutorService to limit the number of concurrent threads in a similar way.
st3fan超过 12 年前
The Go version does not compile. It fails with:<p>main.go:11:5: import "wordsort": cannot find package