Google Inc. this week released version 1 of its Go
programming language. The release was announced on the Go Programming Language
Blog in a post by Andrew Gerrand, developer advocate for Go at Google Sydney.
Go is an open source systems programming language that was
first announced in 2009, after being internally developed at Google since 2007.
In the Go FAQ, Google describes Go as "mostly in the C family (basic
syntax), with significant input from the Pascal/Modula/Oberon family
(declarations, packages), plus some ideas from languages inspired by Tony
Hoare's CSP, such as Newsqueak and Limbo (concurrency)."
Go version 1 (Go 1), which Gerrand referred to as a
"major milestone," is the first release that promises stability with
future iterations of the language, according to the company.
In his blog post, Gerrand noted that Go 1 is "not a
major redesign," but rather provides a new standard for the Go language so
that developers can confidently use it to build stable products. He discussed
some of the primary reasons for the release of Go 1, including "forward
compatibility," updates to the language and its standard library, and the
introduction of a new go command. Gerrand described the go command as "a
program for fetching, building, installing and maintaining Go code."
The Go 1 release also makes the language usable on different
platforms. "Go 1 is the first release of Go that is available in supported
binary distributions. They are available for Linux, FreeBSD, Mac OS X and, we
are thrilled to announce, Windows," Gerrand explained.
A new version of the Google App Engine SDK was released
concurrently with Go 1. Gerrand noted that, like Go 1, the new App Engine
release is intended to provide a stable base for current and future
development.
Description
The syntax
of Go is broadly similar to that of C: blocks of code are surrounded with curly
braces; common control flow structures include for, switch, and if. Unlike C,
line-ending semicolons are optional; variable declarations are written
differently and are usually optional; type conversions must be made explicit;
and new go and select control keywords have been introduced to support
concurrent programming. New built-in types include maps, Unicode strings, array
slices, and channels for inter-thread communication.
Go is
designed for exceptionally fast compiling times, even on modest hardware. The
language requires garbage collection. Certain concurrency-related structural
conventions of Go (channels and alternative channel inputs) are borrowed from
Tony Hoare's CSP. Unlike previous concurrent programming languages such as
occam or Limbo, Go does not provide any built-in notion of safe or verifiable
concurrency.
Of features
found in C++ or Java, Go does not include type inheritance, generic
programming, assertions, method overloading, or pointer arithmetic. Of these,
the Go authors express an openness to generic programming, explicitly argue
against assertions and pointer arithmetic, while defending the choice to omit
type inheritance as giving a more useful language, encouraging heavy use of
interfaces instead. Initially, the language did not include exception handling,
but in March 2010 a mechanism known as panic/recover was implemented to handle
exceptional errors while avoiding some of the problems the Go authors find with
exceptions.
Go
interfaces do not participate in a type hierarchy like Java's. They are better
described as a set of methods, identified by their name and signature. An
interface can be declared to embed other interfaces, meaning the declared
interface borrows the methods defined in the other interfaces, making them part
of the set of methods of the declared interface. A type matches an interface if
it defines the methods (same name and same signature) from this interface.
Visibility
of structures, structure fields, variables, constants, methods, top-level types
and functions outside their defining package is defined implicitly according to
the capitalization of their identifier.
package main
import "fmt"
func main() {
fmt.Println("Hello, World")
}