Go (programming language)
![]() | |
Paradigm | compiled, concurrent, imperative, structured |
---|---|
Designed by | Robert Griesemer, Rob Pike, and Ken Thompson |
Developer | |
First appeared | 2009 |
OS | Linux, Mac OS X |
License | BSD |
Website | http://golang.org/ |
Major implementations | |
gc, gccgo | |
Influenced by | |
C, Oberon, Limbo[1] |
Go is a compiled, concurrent programming language developed by Google[2] with work that carried over from the Inferno operating system.[3] The initial design of Go was started in September 2007 by Robert Griesemer, Rob Pike and Ken Thompson[1] and it was officially announced in November 2009. Go implementations are currently only available on Linux and Mac OS X.[4]
Since the launch of Google's programming language, Go and Go! have become the subject of a naming controversy that is still to be resolved.[5][6]
Description
The syntax of Go is close to that of C except for the type declarations; other syntactical differences are the missing parentheses around for and if expressions. The language supports garbage collection. The concurrency model of Go is modeled after Tony Hoare's CSP, like previous concurrent programming languages such as occam or Limbo,[1] but also has features of the Pi calculus such as channel passing.
Features not included in Go are exception handling, type inheritance, generic programming, assert, and method overriding.[1] Of these, the Go authors express an openness to generic programming, explicitly argue against assertions, while defending the choice to omit type inheritance on efficiency grounds.[1] Unlike Java, maps (also known as hashes or dictionaries) are an intrinsic part of the language, as are strings.
Implementations
There are currently two Go compilers. 6g (and its supporting tools, collectively known as gc) are in C, using yacc/Bison for the parser. Gccgo is a Go compiler with a C++ front-end with a recursive descent parser coupled to the standard GCC back end.[7]
Examples
The following is a hello world program in Go.
package main
import "fmt"
func main() {
fmt.Printf("Hello, World\n")
}
Example of the Unix echo command:[8]
package main
import (
"os";
"flag"; // command line option parser
)
var omitNewline = flag.Bool("n", false, "don't print final newline")
const (
Space = " ";
Newline = "\n";
)
func main() {
flag.Parse(); // Scans the arg list and sets up flags
var s string = "";
for i := 0; i < flag.NArg(); i++ {
if i > 0 {
s += Space
}
s += flag.Arg(i)
}
if !*omitNewline {
s += Newline
}
os.Stdout.WriteString(s);
}
Naming Dispute
A few days after the announcement of the language Francis McCabe, developer of the Go! language requested a name change of Google's language to prevent confusion with his language. McCabe created Go! in 2003 but has not trademarked the name.[9]
References
- This article incorporates material from the official Go tutorial Let's Go, which is licensed under the Creative Commons Attribution 3.0 license.
- ^ a b c d e Language Design FAQ
- ^ Google-go-language
- ^ http://code.google.com/p/go/source/browse/src/libmach/5.c
- ^ Installing Go
- ^ http://www.informationweek.com/news/software/web_services/showArticle.jhtml?articleID=221601351
- ^ http://code.google.com/p/go/issues/detail?id=9
- ^ Go FAQ: Implementation
- ^ http://golang.org/doc/go_tutorial.html
- ^ http://www.informationweek.com/news/software/web_services/showArticle.jhtml?articleID=221601351
External links
- Go Programming Language Homepage
- Go language FAQ
- The Go Programming Language on YouTube
- IRC : #go-nuts connect on irc.freenode.net
- Mailing list / Newsgroup