Go programming language release 1.16

The release of the programming language Go 1.16 is presented, which is being developed by Google with the participation of the community as a hybrid solution that combines the high performance of compiled languages ​​with such advantages of scripting languages ​​as ease of writing code, speed of development, and error protection. The project code is distributed under the BSD license.

The syntax of Go is based on the familiar elements of the C language with some borrowings from the Python language. The language is quite concise, but the code is easy to read and understand. Go code is compiled into separate binary executable files that run natively without the use of a virtual machine (profiling, debugging, and other runtime problem detection subsystems are integrated as runtime components), which allows achieving performance comparable to C programs.

The project is initially developed with an eye on multi-threaded programming and efficient operation on multi-core systems, including providing means implemented at the operator level for organizing parallel computing and interaction between parallelly executed methods. The language also provides built-in protection against overruns of allocated memory blocks and provides the ability to use the garbage collector.

Key innovations introduced in the Go 1.16 release:

  • The embed package has been added, which provides tools for embedding arbitrary files and directories into the program. A new "//go:embed" directive is provided to specify files to be embedded at compile time. For example, specifying the comment "//go:embed test.txt" in the code and declaring the variable "var f embed.FS" as a follow-up will result in the embedding of the test.txt file and the possibility of accessing it through the "f" descriptor. Similarly, you can embed files with resources or individual values ​​of a certain type necessary for work, for example, to get the string variable "s" from the version.txt file, you can specify: import _ "embed" //go:embed version.txt var s string print (s)
  • The default now requires the use of a new module system with integrated versioning support that replaces GOPATH-based dependency management. The GO111MODULE environment variable is now set to "on" by default, and modules mode is used regardless of the presence of a go.mod file in the working or parent directory. In the new mode, build commands such as "go build" and "go test" do not modify the contents of go.mod and go.sum, while "go install" processes version-specified arguments ("go install example.com/[email protected]"). To return the old behavior, change GO111MODULE to "auto". It is noted that 96% of developers have already switched to the new module system.
  • The linker has been optimized. For large projects, linking is now 20-25% faster and requires 5-15% less memory.
  • The compiler adds support for inline function expansion with a shortened definition of 'for' loops, method values, and 'type switch' constructs.
  • Added support for Apple systems equipped with the new Apple M1 ARM chip. Added netbsd/arm64 and openbsd/mips64 ports with support for NetBSD on 64-bit ARM and OpenBSD on MIPS64 systems. Support for cgo and "-buildmode=pie" mode has been added to the linux/riscv64 port.
  • Support for x87 compilation mode has been dropped (GO386=387). Support for processors without SSE2 instructions is now available via the "GO386=softfloat" program mode.

Additionally, we can note the start of testing the beta release of the Dart 2.12 language, in which the null safety mode has been stabilized, which will avoid crashes caused by attempts to use variables whose value is not defined and set to Null. The mode implies that variables cannot have undefined values ​​unless they are explicitly set to null. The mode strictly takes into account the types of variables, which allows the compiler to apply additional optimizations. Type matching is checked at compile time, for example, if you try to assign the value "Null" to a variable with a type that does not imply an indeterminate state, such as "int", an error will be displayed.

Source: opennet.ru

Add a comment