3 ms·
If you want speed, use golang ? Java (and kotlin) are faster than Go in almost all cases (except for startup time) (and even there difference is shrinking, plu
by candiodari 9y ago
If you want speed, use golang ?
Java (and kotlin) are faster than Go in almost all cases (except for startup time) (and even there difference is shrinking, plus you get a lot back for that startup time). C, if you must, is faster still, and C++ can be faster as well.
As a quick (and inaccurate) rule, any program that runs longer than 10-20 seconds will be faster in Java than in Go.
- vbezhenar 9y agoWhat about memory? I wouldn't run any kind of production Java web server with 256M RAM server. I've had impression that Golang is much less memory-dependant.
- sebcat 9y agoNot sure about the most recent versions, but Go can run on MIPS platforms with 32MB RAM.
- skybrian 9y agoBut if you care more about latency and predictable performance, Go's very low-latency GC is attractive.
- candiodari 9y agoNot really. Golang provides "mostly" low latency, at the cost of everything else, most significantly throughput, and load. https://blog.plan99.net/modern-garbage-collection-911ef4f8bd8e https://blog.plan99.net/modern-garbage-collection-911ef4f8bd... TLDR: Go's GC will only be realtime as long as you use it only minimally. With tiny programs, that's fine of course. With larger programs, it will block for a looooong time. That's masked by the language making it very hard to write larger programs in the first place. For instance, by not having decent data structures (not even a tree, seriously ?) I guarantee if you actually use the GC, there comes a point where java runs circles around Go. Hell, there comes a point where the lua GC runs circles around the Go one. That point is a lot closer than you might think, and as a bad rule of thumb you should probably think of it like this: if any of cpu, mem, i/o goes >80% of the machine's capacity, Go will disappoint very badly compared to Java (GC using more memory, using more cpu, longer pauses, ...). But if all those values are at 2% of capacity, Go's runtime will perform better. Tradeoffs. Everything is tradeoffs. Go is not better than Java/JVM, it's worse. But a different set of tradeoffs means that there are circumstances where it'll beat the other set of tradeoffs. But "close to 0", Go will beat the JVM.
- skybrian 9y agoThere's no reason you can't write a tree in Go. Take a look at go/ast.
- msluyter 9y agoHmm, I guess I was going of benchmarks such as these, which suggest Go is, well, faster some of the time? https://benchmarksgame.alioth.debian.org/u64q/go.html https://benchmarksgame.alioth.debian.org/u64q/go.html However, perhaps as you indicate these are including JVM startup time and thus tainting the results. For some reason I had gotten it into my head that Go was faster than Java, but it's been a couple of years since I've used either one, so I definitely may be off on that point.
- weberc2 9y agoLast time I checked, the maintainers of that game said the startup time is negligible.
- xyproto 9y agoGo is a language with at least two compilers. One of them is gcc (yes, gcc, since version 4.6). I doubt Go code compiled with gcc is much slower than C, and can't think of a reason why Java would be faster. "faster than Go" could mean any compiler