TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

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

3 pointsby jemeshsuover 12 years ago

2 comments

st3fanover 12 years ago
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.
st3fanover 12 years ago
The Go version does not compile. It fails with:<p>main.go:11:5: import "wordsort": cannot find package