Go 1.21 Adds New Built-Ins
Written by Kay Ewbank   
Tuesday, 15 August 2023

Go 1.21 has been released with improvements including support for built-ins and production-ready support for Profile Guided Optimizations (PGO).

Since its initial development by Google, Go has matured as an open source project maintained by a team at Google alongside many contributors from the open source community. Go was designed as a systems programming language, and has also been used in high profile commercial successes such as Docker.

goicon2

The full support for PGO follows on from the preview support introduced in the previous release. PGO is also known as feedback-directed optimization (FDO), and it improves performance by feeding information back from representative runs of the compiler. The compiler uses the feedback to make more informed optimization decisions for the next run of the compiler.

The Go team says that most programs from a representative set of Go programs are seeing between 2% and 7% improvement from enabling PGO. 

In language terms, Go 1.21 adds three new built-ins to the language. There are new min and max functions that do what you'd expect, and a new clear function that deletes all elements from a map or zeroes all elements of a slice.

There are also a number of improvements that increase the power and precision of type inference. You can now call a function with arguments that are themselves (possibly partially instantiated) generic functions, and as in earlier versions, the compiler will attempt to infer the missing type arguments. What's new is that it for each argument that is a generic function that is not fully instantiated, the compiler will also attempt to infer its missing type arguments.

Type inference now also considers methods when a value is assigned to an interface, and it is now precise when matching corresponding types in assignments.

Go 1.21 also includes a preview of a language change the developers are considering for a future version of Go, making for loop variables per-iteration instead of per-loop, to avoid accidental sharing bugs.

Go 1.21  is available for download now.

goicon2

More Information

Go Download Page

GoLang Org Webpage

Related Articles

Why Is Go Good?

Go Survey 2021

Go 1.18 Released With Generics And Fuzzing

Insights Into Where Go Is Going

A Programmer's Guide To Go

A Programmer's Guide To Go Part 2 - Objects And Interfaces

A Programmer's Guide To Go Part 3 - Goroutines And Concurrency

To be informed about new articles on I Programmer, sign up for our weekly newsletter, subscribe to the RSS feed and follow us on Twitter, Facebook or Linkedin.

Banner


Apache Updates Wicket
03/10/2024

Apache Wicket has been updated to version 10.2, following the major release of Wicket 10 earlier this year. The open source Java web framework is now built on top of Java 17, and has a new module test [ ... ]



Check Your APIs With Zuplo's Rate My OpenAPI
15/10/2024

Zuplo has launched a new suite of tools that rates the quality of your API, based on its OpenAPI specification. We put it through its paces and find it useful.


More News

espbook

 

Comments




or email your comment to: comments@i-programmer.info

Last Updated ( Tuesday, 15 August 2023 )