5 ms·
tl;dr: The Go implementation being faster has nothing to do with Java or Go. The version implemented in Go used a slightly different algorithm, which allowed ho
by quanticle 10y ago
tl;dr: The Go implementation being faster has nothing to do with Java or Go. The version implemented in Go used a slightly different algorithm, which allowed hot inner loops to terminate early, greatly improving the performance of the algorithm.
- jaimex2 10y agoWish I read this before reading the post. thanks.
- dboreham 10y agoIf I had a penny for every...
- weberc2 10y agoI like Go, but it's not dramatically faster than Java. Any contest between the two of them will probably just be a back and forth of optimizations. They share pretty much the same upper bound.
- tomohawk 10y agoGiven a specific machine with a set amount of cpu, ram, and io bandwidth, I find I can easily do more on that machine with go than java. Also, try running multiple java processes on a machine as opposed to multiple go programs.
- weberc2 10y agoSo could I. I imagine a Java aficionado would say the opposite. Like I said, different ways to think about the problem.
- donatj 10y agoTo the posters point about running multiple Java aaps on a single machine, I think ram is the real issue. Java makes in my experience far less frugal use of it. I've seen Java applications eat hundreds of mbs of ram rewritten in Go using 1-2 mb.
- vinceyuan 10y agoExactly. Go app uses much less RAM than Java app.
- weberc2 10y agoEvery time I hear this conversation play out, the Java folks point out that the GC is highly tunable/pluggable, so you can shift some levers and get lower memory consumption in exchange for more frequent collections. I'm not a GC expert, so I'm just repeating what I've heard.
- mcguire 10y agoThis is true. The Java GC (and the whole VM) is one of thr most impressive pieces of software in existence. There are several GCs available, they're tunable, and they support monitoring better than any other I've seen. No GC I know is happy without a heap several times larger than the program's requirements. OTOH, Java programs tend to be built using frameworks that soak up memory like crazy. So there's that.
- FlyingPiranhas 10y agoI believe that Go's GC currently bounds heap memory usage to 2x the actual usage (worst case).
- nerdwaller 10y agoI tend to agree from the naive Java approach, but with Java and multiple processes on the same machine they really should share a single JVM. Many people end up having one JVM per process. But the go runtime is less greedy and supports that logical thinking much more obviously.
- koffiezet 10y agoSpeed is not everything however, when it comes to memory usage, Java has a serious disadvantage.