Go is an open source programming language that makes it easy to build simple, reliable and efficient software. – golang.org

I have been a Java programmer for over 10 years.

To this day, I can’t work without Java, but I will increasingly use Go to solve problems and even advise colleagues to use Go in their work. But will people encourage each other to use Java? I don’t think so!

Why use Go?

Once we move from C to Java, we are now surrounded by a robust Java ecosystem, thanks to multi-platform garbage collection from Java to Java.

Still, the advent of containers, the rise of Docker and Kubernetes, suddenly made Go discoverable, and you needed to know it, love it, and abandon Java.

My answer to using Go is simple: simplicity and speed

Why do Java developers choose Go?

Next, I will briefly talk about the advantages of Go and why you should learn to Go.

Simplicity and Speed

Go and Java have a lot in common:

· C family (command, curly braces)

· Static type

· Garbage collection

· Memory safety (zero references, runtime boundary checking)

· Variables are always initialized (zero/zero/false)

methods

The interface,

· Type assertion (Instanceof)

Reflection,

However, Go requires cleaner, shorter code in almost every way to achieve the same functionality. See the following code:

Method definition:

· Java supports only one return value; if more values are needed, an Object is defined.

· Go supports multiple return values

func foo() (string, bool) {}

Class:

, Java classes

· Go has structs, and structs do not need getters/setters and toString or equals

Interface:

· In Java, we have a specific interface type: Interface, and the methods in that interface are specifically implemented by the class that inherits that interface.

· Go also has interface functions, but instead of explicitly declaring the implementation of the interface in Go, only structures (that is, classes in Java) can implement the methods in the interface.

The code above is a simple example of using an interface in Go, which is much cleaner and more flexible than Java.

Even the for loop is more flexible:

· In Java, we use:

for (int i = 0; i < arr.length; i++){ Object b = arr[i]; / /… }

· In Go, it’s as simple as this:

for i, v := range arr { } // or I don’t need index for v := range arr { fmt.println(“value=”+v); }

There are many examples of Go being easier and faster to write than Java.

This is why many companies only need 3 or 5 Go programmers, while Java might need 10 programmers to do the same job.

Is that all? No, Go’s bigger advantage is performance.

Go is the answer to Google’s scale problem.

Go is Google’s ultimate solution to concurrency.

· Designed for 1 machine

· Daily work runs on thousands of machines

· Work coordination and interaction with others in the system

· Many at a time

The language provides a concurrency model that differs from most mainstream programming languages.

Go advocates a different way of thinking about concurrency in modern software.

There are many articles on the Internet that compare the performance of Go and Java for your reference.

Would I completely replace Java with Go?

No, I can’t. Java still has many advantages.

There are also many differences between Go and Java in terms of language capabilities and usage scenarios.

Java has been around for more than 20 years. Programming languages have an impact on its functionality. It has huge support from developers and a strong community. They are the developers of the past, but they are an active community solving your problems. Go, on the other hand, has an active community that is small but growing faster.

There are many resources and sample code.

If you run into problems, it’s more likely that, if documented, you’ll find a solution with the help of other developers who have traveled the same path before.

Java provides portability; it is designed to be written once and run anywhere.

The JVM interacts with the hardware to make the code work in any application.

Sometimes it may not be accurate to start the same line of code on any more complex machine.

It is the default development language for Android phones.

conclusion

Now is the best time to learn Go.

Using Go will lead the way in the cloud era based on Docker and Kubernetes.

The Go community is becoming more mature and more open source frameworks are available. The more support you have, the more you can learn. Let us master another weapon to strengthen ourselves and better adapt to the new era.