On wednesday Google released an open source programming language called Go. Apparently it's intended to be a systems programming language like C++.
Some features:
- extremely fast compile
- garbage collection
- supports google protocol buffers
- two compilers: gccgo (gcc backend) and 6g (plan 9 based)
- concurrent programming
Simple hello world style program in Go:
Code: Select all
package main
import fmt "fmt"
func main()
{
fmt.Printf("Yay\n");
}Here's some differences they list from C++:
They say that right now there's no safe way to call Go from C or C++ code, but there's a C compiler (Plan 9's GC) which can link with Go (so you can call C from Go). Also, there's pointers but no pointer arithmetic and no operator overloading.* Go does not have classes with constructors or destructors. Instead of class methods, a class inheritance hierarchy, and virtual functions, Go provides interfaces, which are discussed in more detail below. Interfaces are also used where C++ uses templates.
* Go uses garbage collection. It is not necessary (or possible) to release memory explicitly. The garbage collection is (intended to be) incremental and highly efficient on modern processors.
* Go has pointers but not pointer arithmetic. You cannot use a pointer variable to walk through the bytes of a string.
* Arrays in Go are first class values. When an array is used as a function parameter, the function receives a copy of the array, not a pointer to it. However, in practice functions often use slices for parameters; slices hold pointers to underlying arrays. Slices are discussed further below.
* Strings are provided by the language. They may not be changed once they have been created.
* Hash tables are provided by the language. They are called maps.
* Separate threads of execution, and communication channels between them, are provided by the language. This is discussed further below.
* Certain types (maps and channels, described further below) are passed by reference, not by value. That is, passing a map to a function does not copy the map, and if the function changes the map the change will be seen by the caller. In C++ terms, one can think of these as being reference types.
* Go does not use header files. Instead, each source file is part of a defined package. When a package defines an object (type, constant, variable, function) with a name starting with an upper case letter, that object is visible to any other file which imports that package.
* Go does not support implicit type conversion. Operations that mix different types require casts (called conversions in Go).
* Go does not support function overloading and does not support user defined operators.
* Go does not support const or volatile qualifiers.
* Go uses nil for invalid pointers, where C++ uses NULL or simply 0.
Sounds interesting.
Unfortunately there's already been a programming language called Go! for around 6 years, Google should have probably googled the name first.
At the very least, anybody creating a language without checking http://99-bottles-of-beer.net (has 1304 languages) first is stupid, they've had an entry for Go! since 2005: http://99-bottles-of-beer.net/language-go!-289.html

