Home >Backend Development >Golang >Is go language a back-end language?

Is go language a back-end language?

青灯夜游
青灯夜游Original
2022-12-01 18:16:417886browse

Go language is a back-end language. Go language is a server-side programming language, and its direction is mainly back-end. Reasons for using Go language for back-end development: 1. At the language level, it has the characteristics of simple syntax and high execution efficiency (underlying language); 2. Go language focuses on concurrency and is born for concurrency, and its starting point is to target big data High-concurrency, distributed application scenarios in the context of cloud computing era; 3. Go language can be directly compiled to generate executable programs on different platforms, and the basic memory usage is very small.

Is go language a back-end language?

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

Go language is a server-side programming language. The direction of go language is not the front-end, but mainly the back-end.

Go (also known as Golang) is a statically strongly typed, compiled, concurrent type developed by Google, and Programming language with garbage collection function. Go was officially announced in November 2009, becoming an open source project and implemented on Linux and Mac platforms, and later added implementation under Windows systems.

Go language syntax is similar to C, but its functions include: memory safety, GC (garbage collection), structural form and CSP-style concurrent computing.

Description

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.

Why use Go language for back-end development?

1. Simple and efficient: Almost all mainstream programming languages ​​such as Java, C, PHP, Python, JavaScript, etc. can be used for server-side development. As a rising star, Go language has great advantages in language level. It has the characteristics of simple syntax and high execution efficiency (underlying language); in comparison, Java, Python, and PHP are all inefficient, C is too troublesome, and Go can achieve both simplicity and efficiency;

2. High concurrency: Go language focuses on concurrency and is born for concurrency. Its starting point is to target high concurrency and distributed application scenarios in the era of big data cloud computing;

3. Cross-platform : Can be directly compiled to generate executable programs on different platforms. The basic memory usage is very small. Small applications take up a few M and large applications take up dozens of M and can run well. This allows golang to be used on small devices such as Raspberry Pi. It runs very well, and this performance is much better than Java;

Containerization, distribution, and microservices are the trends in server development, in these directions:

1. Containerization: Go language is the absolute overlord in the container field. The well-known Docker and Kubernets (K8S) are developed using Go language;

2. Distribution: the best An example is Ethereum, because the blockchain is a distributed ledger;

3. Microservices: The best example of Go language supporting microservices is Toutiao. Today, more than 80% of the traffic of back-end services in Toutiao is Runs on a service built in Go. The number of microservices exceeds 100, the peak QPS exceeds 7 million, and the daily processing request volume exceeds 300 billion. It may be the largest Go application in the industry.

Go language is a back-end language. Compared with other back-end languages, what are the advantages or characteristics of Go?

  • # The language level supports concurrency. This is the biggest feature of Go. It is easy to write multi-threaded programs and can make full use of multiple cores.

  • As a programming language born in the 21st century, it supports garbage collection. Like Java, developers do not need to manage memory and can focus on business implementation.

  • Rich standard library, Go has a large number of built-in libraries, especially the network library is very powerful.

  • Go language deployment is relatively simple, directly compiled into machine code, and there are cross-platform compilation options.

  • The philosophy of Go language is "less is more". Compared with C and Java, Go language is easier to get started.

Writing style

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

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

  • The opening brace cannot be placed on 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 sort out excess whitespace in the code, align variable names, and convert aligned spaces into Tabs. [Related recommendations: Go video tutorial]

Compiler

There are currently two Go compiler branches, namely the official compiler gc and gccgo. The official compiler was initially written in C and later rewritten in Go to achieve bootstrapping. Gccgo is a Go compiler using standard GCC as a backend.

The official compiler supports cross-platform compilation (but does not support CGO), allowing source code to be compiled into binaries that can be executed on the target system and architecture.

Go language success stories

1. Docker (container)

Up to now, Docker is almost a success story that is difficult to find and copy in Go. The Docker project received $40 million in Series C financing in September 2014. The version iteration speed is super fast. Currently, there are 78 versions seen on GitHub, and it is only a project that was officially started in early 2013. At present, domestic Docker technology promotion is also in full swing, such as the Docker Chinese community, and CSDN has also established a Docker zone. The reason why the Docker team likes to use the Go language is mainly because Go has a powerful standard library, a full development environment, and the ability to build cross-platforms.

2. Kubernetes (container)

Kubernetes is Kubernetes launched by Google in the summer of 2014. It is based on Docker and its purpose is to allow users to manage cloud container clusters through Kubernetes clusters without the need for users to Perform complex setup work. The system will automatically select appropriate working nodes to perform specific container cluster scheduling and processing work. Its core concept is Container Pod.

3. Etcd & Fleet (distributed database)

etcd is a key-value storage system developed and maintained by CoreOS. It is written in Go language and handles log replication through Raft consistency algorithm. Ensure strong consistency. Currently, Google's container cluster management system Kubernetes, open source PaaS platform Cloud Foundry and CoreOS' Fleet all use etcd extensively. Fleet is a distributed initialization system. The reason why they choose to use the Go language is because of the good cross-platform support of the Go language and the strong community behind it.

4. Deis (Cloud Service Platform)

Deis is an open source PaaS platform based on Docker and CoreOS, designed to make it easy to deploy and manage applications on servers. It can run on AWS, GCE and Openstack platforms.

5. Flynn (Cloud Service Platform)

Flynn is an open source PaaS platform written in Go language, which can automatically build and deploy any application to run on a Docker container cluster. The Flynn project is supported by Y Combinator and is still under development. It is called the next generation open source PaaS platform.

6. Lime (desktop application)

Compared with the above Go languages ​​in addition to the cloud and server side, Lime is quite special. Lime is a desktop editor program written in Go language, which is regarded as an open source implementation of the famous editor Sublime Text.

7. Revel (Web Framework)

Revel is a highly productive Go language Web framework. The Revel framework supports hot compilation. When editing, saving and refreshing the source code, Revel will automatically compile the code and templates; full-stack features support routing, parameter parsing, caching, testing, internationalization and other functions.

8. InfluxDB (distributed database)

An open source distributed timing, event and indicator database written in Go voice, without external dependencies. Its design goal is to achieve distributed and horizontal scaling.

9. .Syncthing (cloud disk)

An open source cloud storage and synchronization service tool written in Go language. Users’ data will be fully controlled by themselves, and all communications will be encrypted. Each access node is authenticated with an encryption certificate. The project is considered an open source alternative to Dropbox and BitTorrent Sync. The reason why Syncthing chose the Go language is also due to cross-platform considerations.

10. Gogs (self-service Git service)

Gogs is a self-service Git service project developed by Guoren Wuwen (GitHub). The goal of Gogs is to create the simplest, fastest and easiest way to build self-service Git services. According to the author, the reason for choosing to use the Go language for development is that Go allows Gogs to be distributed through independent binaries and has good support for cross-platforms.

For more programming related knowledge, please visit: Programming Video! !

The above is the detailed content of Is go language a back-end language?. 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