Home  >  Article  >  Backend Development  >  Which language does go belong to?

Which language does go belong to?

青灯夜游
青灯夜游Original
2023-01-17 15:01:102176browse

Go is a statically strongly typed, compiled, concurrent programming language with garbage collection capabilities; Go requires a compiler to compile the code. A compiler compiles source code into a binary (or bytecode) format; as it compiles the code, the compiler checks for errors, optimizes performance, and outputs binaries that can run on different platforms.

Which language does go belong to?

The operating environment of this tutorial: Windows 7 system, GO version 1.18, Dell G3 computer.

Go (also known as Golang) is a statically strongly typed, compiled, concurrent programming language with garbage collection capabilities developed by Google's Robert Griesemer, Rob Pike and Ken Thompson.

Go uses a compiler to compile code. A compiler compiles source code into a binary (or bytecode) format; as it compiles the code, the compiler checks for errors, optimizes performance, and outputs binaries that can run on different platforms. To create and run a Go program, a programmer must perform the following steps.

  • Use a text editor to create a Go program;

  • Save the file;

  • Compile the program;

  • Run the compiled executable file.

Go's syntax is close to C language, but the declaration of variables is different. Go supports garbage collection. Go's parallel model is based on Tony Hall's Communicating Sequential Process (CSP). Other languages ​​that adopt a similar model include Occam and Limbo, but it also has features of Pi operations, such as channel transmission. Plugin support is opened in version 1.8, which means that some functions can now be dynamically loaded from Go.

Compared with C, Go does not include functions such as enumeration, exception handling, inheritance, generics, assertions, virtual functions, etc., but it adds slice type, concurrency, pipes, garbage collection, Language-level support for features such as interfaces. The Go 2.0 version will support generics, but has a negative attitude towards the existence of assertions, and also defends that it does not provide type inheritance.

Unlike Java, Go has built-in associative arrays (also known as hash tables (Hashes) or dictionaries (Dictionaries)), just like string types.

Writing style

There are several regulations in Go. When the following regulations are not matched, compilation will produce an error.

  • There is no need to write a semicolon after each line of the program.

  • The opening brace cannot be placed in a new line.

  • if judgments and for loops do not need to be enclosed in parentheses.

Go also has a built-in gofmt tool, which can automatically clean up excess whitespace in the code, align variable names, and convert aligned spaces into tabs.

Why you should learn Go language

If you want to create system programs or network-based programs, Go language is a very good choice. As a relatively new language, it was designed by experienced and respected computer scientists to address the challenges of creating large-scale concurrent network programs.

Before the emergence of the Go language, developers were always faced with a very difficult choice: whether to use a language (such as: C) that has fast execution speed but unsatisfactory compilation speed, or use a language that has fast compilation speed but not ideal compilation speed. What about languages ​​with poor execution efficiency (such as .NET, Java), or dynamic languages ​​that are less difficult to develop but have average execution speed? Obviously, Go language achieves the best balance between these three conditions: fast compilation, efficient execution, and easy development.

The Go language supports cross-compilation. For example, you can develop applications that can run on Windows on a computer running a Linux system. This is the first programming language to fully support UTF-8. This is not only reflected in the fact that it can process UTF-8 encoded strings, but also its source code file format uses UTF-8 encoding. Go language is truly international!

Go language purpose

The Go language is designed as a system programming language for use on giant central servers running web servers, storage clusters, or similar purposes.

For the field of high-performance distributed systems, Go language undoubtedly has higher development efficiency than most other languages. It provides massive parallel support, which is perfect for game server development.

【Related recommendations: Go video tutorial, Programming teaching

The above is the detailed content of Which language does go belong to?. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn