44 ms·
How is Go slower than Java? Actually Go is pretty slow compared to many languages I would've expected it to be faster than.
by xmonkee 13y ago
How is Go slower than Java? Actually Go is pretty slow compared to many languages I would've expected it to be faster than.
- Buttons840 13y agoWhy did you expect Go to be faster than Java? One thing that surprised me about that benchmark is how many languages fall into the "2 to 3 times slower than C" category. They all have various merits, but seemingly equal performance. I've also noticed each of the languages I'm familiar with have gone through a hopeful stage of "were as fast as C" only to fall short.
- igouy 13y agoRemember, it's -- how many [programs] fall into the "2 to 3 times slower than [the] C [programs]" category.
- RyanZAG 13y agoThere's this strange idea still floating around that Java is somehow slow. Compared to hand crafted micro benchmark C code, Java is slower. But then so is everything else. The simple facts are that the JVM is the most advanced and efficient VM available today, and the JVM is specifically targeted to increase the speed of Java. It's not much of a stretch to expect good speed out of that regardless of strange preconceptions you may have had. The Go VM has a long long way to go be even remotely comparable to the JVM in garbage collection etc.
- pekk 13y agoHow much slower than C do you have to be in order to be called slow? Apparently, the cutoff is defined like this: as slow as Java is not slow, but any slower than Java is slow.
- RyanZAG 13y agoGo is anything but slow, it's just not as fast as Java. I was just addressing the idea that Java is somehow slow which seems to float around occasionally. Java is arguable the fastest language that isn't directly C-based and anybody thinking of it as slow is simply misinformed.
- gecko 13y agoThe biggest problem is that Go's garbage collector is conservative and slow. Add in that I don't think Go's optimizer is yet as good as HotSpot's, and you've got the recipe for those benchmarks.
- dbaupp 13y agoGo is getting a fully precise GC in the next release apparently: http://talks.golang.org/2014/go1.3.slide#4 http://talks.golang.org/2014/go1.3.slide#4 Also, the default Go compiler essentially has no optimiser at all, just some weak inlining + a language designed to be easy to compile directly to non-horrible machine code without much effort. GCCGo will be much faster.
- awj 13y agoHow do you expect Go to be faster than Java? Off the top of my head here's three reasons why I expect Go to be equal or slower in the general case: * the type system doesn't provide any more information to optimize against * lack of generics means you're going to incur runtime type checks to unpack data out of containers * internal pointers force a choice between ignoring advanced garbage collection (which usually involves moving data in memory), making all object accesses a double pointer dereference (to allow moving), and forcing the user to specify at allocation time if the object should be eligible for movement. All of these choices suck. Personally, I don't expect Go to ever be "faster than Java". Maybe (hopefully!) I'm wrong, but these are big roadblocks.