Google's Go team decides not to give it a try

The Go language will not be adding a "try" keyword in the next major version, despite this being a major part of what was proposed for version 1.14.

Go, an open source language developed by Google, features static typing and native code compilation. It is around the 15th most popular language according to the Redmonk rankings.

Error handling in Go is currently based on using if statements to compare a returned error value to nil. If it is nil, no error occurred. This requires developers to write a lot of if statements.

"In general Go programs have too much code-checking errors and not enough code handling them," wrote Google principal engineer Russ Cox in an overview of the error-handling problem in Go.

There was therefore a proposal to add a built-in try function which lets you eliminate many of the if statements and triggers a return from a function if an error is detected. The proposal was not for full exception handling, which is already present in Go via the panic and recover functions.

That proposal has now been abandoned. Robert Griesemer, one of the original designers of Go, announced the decision in a post yesterday.

What was the problem with try? Opinions in the Go community are mixed, but what emerged is that many Go programmers do not mind the current approach, and did not like introducing a new built-in function that alters the control flow.

"Making an exit point of a function that isn't a return, and is meant to be commonplace, may lead to much less readable code," said one user.

The outcome is a good one insofar as the Go community has proved able to make and withdraw a major proposal without rancour. And as for error handling, no doubt the team will, um, try again.®

Software News

Aug 20
Where will you stand now that Redmond has raised the web-surfing stakes?
Aug 20
You say mode, they say policy, S call the whole thing off
Aug 20
Order banning any further infringement stays, as does Big Red's legal bill
Aug 19
Write once, optimise everywhere amirite?
Aug 19
Hop from 4.12 to 4.14 fixes 'a boatload of bugs'. Hooray!
Aug 19
RoundupFor the love of Windows, please leave that poor text editor alone
Aug 19
Who, Me?Screen says 'Data save failed' so it must be true