Golang has many advantages over Java such as simple syntax, microservice compatibility, lightweight threads, and fast performance. But are there any areas where Java is superior to Go? In which cases would you prefer to use Java instead of Go?
Videos
Background: I've been using Java for about 8 years and just started learning Golang.
So far, I'm in love with the language, and these are the top reasons:
More low-level control of memory. I hated how much the JVM's GC relied on the compactor. Objects can only be created on the heap and object arrays are arrays of pointers to non-contiguous locations in memory. Many like to say that Java has better GCs than Go, but that's because Go's memory model doesn't require such complicated GCs. It's also nice to have pointers in Go.
More paradigm-neutral. Java was designed from the beginning to be a language primarily for OO programming. Using Java for functional programming results in unnatural syntax and inefficient use of memory. Golang feels ambidextrous.
I'm still very new to Golang but as of right now, I even see it as a replacement for Node and Python in the areas of scripting and web server development. Golang's fast compile time closes makes it competitive against interpreted languages in terms of development speed, but 1-ups these languages because it gives the developer more low-level control of memory and has static typing.
When is it better to use java over GoLang?
I have seen several performance tests that always give GoLang the fastest and least memory and CPU usage.
The question here is why should I or any company prefer using java over GoLang?
thanks