4 ms·
Go has one BIG advantage compared to Java with respect to both JIT and GC. Go has structs. This introduces a little more complexity that Java chose (reasonably)
by kjeetgill 8y ago
Go has one BIG advantage compared to Java with respect to both JIT and GC. Go has structs. This introduces a little more complexity that Java chose (reasonably) to avoid by making everything a primitive or a reference. There isn't any "direct" objects or explicit pointers like Go has.
This may muddy up the language vs Java a little bit, but it also gives a lot more tools to work your code around the runtime's limitations. And thats a perfectly fine design point by me.
If you're going to have platform limitations (no JIT, simple GC) then I need reasonable tools when I hit them. It's much easier to avoid frequent allocations or implement arenas in Go. This takes the pressure of the runtime to be one size fits all.
I know, I know, Java is getting Value Types some day! We'll see where that lands.
- staticassertion 8y agoIt's then interesting to compare to C#, which also can do stack allocation, but still chooses a generational GC.
- kjeetgill 8y agoI knew it had it but I have no C# experience. Does idiomatic code use this or only more niche optimizations?
- pjmlp 8y agoAll performance critical data structures are value types. Meaning int, long, char, bool, ..., points, rectangles, pairs, colours, enumerations. Then generics are reiffed. So each instance gets a copy if value types are used. Additionally, you can explicitly allocate value types and arrays on the stack and there are APIs for manual memory management.
- masklinn 8y agoC# defaults to reference types, structs are not usually recommended as the default way to build your own types, only as an optimisation.
- nemo1618 8y agoI love Go's value types. If you're careful/obsessive, you can write programs that don't allocate anything on the heap. That sort of power is really nice to have in a pinch.