Features of Go language

Overview

Language design and grammar

simple

There are not many ways to write the Go language, and the writing style is fixed to some extent, so it can be implemented simply. It's relatively easy to understand the language specifications for yesterday.

Compiled language

A compilation language is a language that ** compiles (translates) all code into machine language or intermediate language at once ** before execution. The compiled language has the characteristic that the description method is strict **, but it has the characteristic that ** processing is fast ** because it is converted into machine language at once and processed by the computer. The Go language is said to be ** fast to compile **.

Static typing

In Go language, you must specify the type in advance when writing a program **. By compiling static typing in advance, there is no need to check the type biosynthesis when the program is executed, which speeds up the process. It also checks for types at compile time, so you can check for ** type matching errors **. Java and C have this feature.

On the other hand, there are dynamically typed languages that do not type when writing programs. JavaScript, Ruby, Python, etc. are dynamically typed languages. These are not fast, but the amount of writing in the program is small and the learning cost of the sentence is low, so you can write the code intuitively.

Concurrent programming

Go routine

It is a function to start processing in a virtual thread, and it is an image of a lightweight thread. This can be achieved by calling the function with the go keyword.

func main() {
  go f()  //Calling a go-routine
}
func f() {
  // some task
}

You cannot set a return value for a function in Goroutine. In the go routine, it is discarded when the process is completed.

channel

Since it is not possible to detect whether a work is being performed or abandoned using only the go routine, error handling cannot be performed when unintended behavior occurs. Also, since there is no return value, you cannot receive the processed value as a result of the work. Therefore, a function called a channel enables ** data exchange between go-routines **. By describing the reception of the channel, ** it will wait until the value is sent **. A channel can also have a ** buffer **, and specifying a buffer at creation determines the number of data a channel can have. (Default is 0) Sending a value beyond the buffer causes send blocking.

Rich standard library

The Go language has a large collection of standard libraries.

Single binary cross-compile

The Go language allows you to create binaries for different operating systems and architectures. This can be achieved by specifying the environment variables GOOS and GOARCH as shown below.

# Windows(32bit)For
$ GOOS=windows GOARCH=386 go build

# Linux(For 64bit)
$ GOOS=linux GOARCH=amd64 go build

Programs written in Go language are basically generated as single binaries that can be executed independently. Once compiled, there is no need to manage the runtime and dependencies required for LL language (a language that can realize processing with a short description), and there is no need to prepare an operating environment.

Recommended Posts

Features of Go language
Hello world with full features of Go language
[MacOS] Installation of Go (Go language) using goenv
Go language learning record
Go language environment construction
Go language cheat sheet
100 language processing knock-75 (using scikit-learn): weight of features
Main features of ChainMap
Ruby expert learned the basic grammar of Go language
Features of programming languages [Memo]
go language learning miscellaneous notes 1
[Golang] About Go language channel
About the features of Python
[Golang] Basics of Go language About value receiver and pointer receiver
Try implementing Yubaba in Go language
Use optinal type-like in Go language
Train_test_split of features held by dict
Features of pd.NA in pandas 1.0.0 (rc0)
About the basic type of Go
Post to slack in Go language
10 functions of "language with battery" python
Go Language Spreadsheet Library: Excelize 2.3.2 Released
Master the rich features of IPython
100 Language Processing Knock-59: Analysis of S-expressions
Summary of go json conversion behavior
2021 Go Language Framework Star Count Comparison
A Tour of Go Learning Summary
Mastering the rich features of IPython (2)
Features of symbolic and hard links
Write tests in GO language + gin
Summary of multi-process processing of script language
Do something object-oriented in GO language
[GO language] Organize the behavior of import in places other than GOPATH
I made a kind of simple image processing tool in Go language.
What Java users thought of using the Go language for a day
I made go language for api and minimum configuration of react for front
Answers and impressions of 100 language processing knocks-Part 1
100 Language Processing Knock-91: Preparation of Analogy Data
100 Language Processing Knock-44: Visualization of Dependent Tree
Natural language processing of Yu-Gi-Oh! Card name-Yu-Gi-Oh!
Language processing 100 knocks-22: Extraction of category names
Answers and impressions of 100 language processing knocks-Part 2
What kind of programming language is Python?
Notes on standard input / output of Go
Proposal of a new language shield language framework
100 Language Processing Knock-26: Removal of emphasized markup
[Golang] Go language basics What is Goroutine?
[GO language] Let's read a YAML file
Summary of library hosting pages by language
Correlation visualization of features and objective variables
Reading comprehension of "The Go Memory Model"
[Golang] About Go language Producer and Consumer
I compared the speed of go language web framework echo and python web framework flask