Go language advantages and learning roadmap

Introduction

Go language, also known as Golang, was released by Google in 2009. In recent years, it has risen rapidly with the development of cloud computing, microservices, and distribution, and has become one of the mainstream programming languages. Similar to Java, it is a static language. , strongly typed, compiled programming language, born for concurrency, so it is naturally suitable for concurrent programming (network programming).

Currently, the Go language supports multiple platforms such as Windows and Linux, and can also be executed directly on mobile terminals such as Android and iOS. From a business perspective, the Go language is widely used in cloud computing, microservices, big data, blockchain, Internet of Things, and artificial intelligence. It has a wide range of applications in intelligence and other fields. So now is the time to learn.

Comparison with other languages

C/C++

Go was designed as a replacement for C, so the two have many similarities, but Go does more:

  • Provides a runtime that automatically manages threads and garbage collection. In C/C++, you need to manage threads and memory yourself.
  • Faster compilation speed

Therefore, compared to C/C++, Go development efficiency is higher.

Applicable scenarios are different:

  • C/C++ can be used for high-performance embedded systems, large-scale cloud applications, and desktop program development
  • Go is suitable for system and cloud platform development

Go is not suitable for high-performance embedded systems because embedded system resources are limited and the Go runtime requires additional overhead for thread scheduling and garbage collection. There is no GUI SDK provided so far, so it is not suitable for desktop program development.

Java

After the Java program is compiled, additional Java runtime needs to be installed. The portability of the Java program depends on the Java runtime. Go does not need it. The Go runtime is already included in the compiled binary file. This is reflected in the difference in deployment. The server installs Java runtime, while Go only needs to deploy a single file.

In addition, when the program is executed, Go is compiled into a binary file and executed by the operating system, while Java is usually executed in a JVM that contains a JIT compiler, and JIT will optimize the code.

Python/PHP

Python/PHP are both dynamic languages, while Go is a static language that does type checking and is more reliable.

When developing web applications, Python/PHP usually hides behind Nginx/Apache as a background process, while Go provides a built-in web server that can be used directly in the production environment.

The reason why Python/PHP needs to use an additional web server is to handle concurrent requests. Python has a global lock that only allows one thread to run at the same time. PHP itself does not have a multi-threaded multi-process mechanism. A request is an independent one from the beginning to the end. Process, in order for Python/PHP-based web applications to support concurrent requests, an external web server must be used.

Go's built-in web server makes full use of goroutine and has good support for concurrent connections. In addition, since the essence of coroutines is to schedule different threads in the same process, shared resources are also supported.

In addition, Python/PHP is a dynamic language and its performance is not as good as Go. If you want to improve the performance of Python/PHP, you must write extensions in C language. The complexity and learning cost are too high.

JavaScript

The JavaScript here is mainly Node.js.

JavaScript is a single-threaded model. Although the asynchronous IO mechanism can use different threads, the main program still runs in single-threaded mode. Time-consuming main program code will block the execution of other codes.

The multi-threading model of the Go language can run in different threads of multiple processors through runtime management and scheduling coroutines, making full use of system hardware.

Node.js uses Google Chrome's V8 engine, which contains a virtual machine with a JIT compiler, which can optimize JavaScript code to improve performance, while Go code is directly compiled into machine code for execution. There is nothing similar and no This is necessary.

Note: The above comparison is compiled from the book "Go In Practice".

Learning roadmap

Note: There are a lot of books listed here, just pick the ones you are interested in and read them. If you really want to read all these books, they will not be published for three to five years.

And basic knowledge map:

 

There is also a complete roadmap:

Of course, in the learning process, official documents are also indispensable companion tools.

Next, the academy will start with basic knowledge to help you quickly get started with Go language development, and then conduct practical demonstrations based on microservice architecture and development, so that everyone can fully master this language.

Guess you like

Origin blog.csdn.net/weixin_59284282/article/details/125177864