Go from Google, alternative to C++ and Python
Google has created the Go language to operate with multi-core processors of today, that is difficult with current languages. As always, this new language was created in response to the dissatisfaction caused by the shortcomings and disadvantages of current languages. In this case, it is intended to replace C++ for system programming, that neither Java nor C# can do.

Modern features and 40 years old syntax!
To do this it employed several veteran of programming, and that explains the legacy syntax of the language.
- Ken Thompson. Co-author of UNIX, creator of the B language which was followed by C (by Dennis Ritchie).
- Rob Pike, created the Plan 9 system for Bell.
- Robert Griesemer has contributed to the V8 JavaScript compiler and GCC Chrome.
Its goal is to stay as close as possible to the C language while significantly improving productivity.
Go borrows features from C, Java, Pascal, Python and even incorporates features from Scriptol!
Google says in the presentation:
"We claim that Go is a modern language."
And it's true for its features, not for the syntax which dates exactly from 1969 and the B language!
It is used in production at Google since May 2010, but beside the fact that it replaces C++ very effectively, it also tends to be used in place of Python because its compilation speed is suitable for scripting.
Why use Go? The user experience
Designed for parallel programs, it can on modern computers provide faster processing.
Its syntax and the way it treats objects intend it primarily for system programmers as a replacement for C or C + +. It then allows more rapid development.
Has builtin concurrency and garbage collector, that must be added to theses languages.
It may be used to make server software and for example to build a CMS and generates HTML pages. The golang.org site is made with Go. It seems that the number of applications that developers find are unlimited as it is the case with C.
Whatever their previous language (but a priori a system language), programmers have a positive experience with Go. It is simpler than C++, more adaptable than Java, has an extensive well designed library and provides the services required to Web applications, such as WebSocket, closures.
And programs are compiled instantly which facilitates the development, as the clear expression of errors too, C programmers know what it is about.
Features
- No semi-colons required but to separated statements.
- map is a hash table and is part of the language.
- Multiple threads that communicate with each other.
- Variables are declared as in Pascal:
var name type
Ex: var x int; - Functions can return multiple values at once.
- There are no parentheses around the conditions in if or for as in Scriptol.
- break and continue may specify a label.
- The switch case structure may include different types or comparators as in Scriptol.
- A case statement can contain several alternatives:
case 0, 1, 2: - A slice is a structure that includes a part of a list and point to it.
- The go command calls a function by starting a different thread.
- chan is a channel for communication between goroutines (which are functions of concurrent threads).
- UTF-8 format for strings.
CSP (Communicating Sequential Processes) manages communication between program with support for multi-core processors.
Difference with C++
Even if it uses a syntax of the 70s, Go simplifies a lot programming compared to C++.
Many common causes of errors coming from the syntax are removed.
Multi-threaded operation becomes quite easy thanks to a single command.
The garbage collector avoids memory management by the programmer.
- There is no class and inheritance. The interfaces are close to objects of JavaScript.
- Memory is managed automatically by a garbage-collector.
- Pointers have a type set.
- Arrays are passed by values and not pointers.
- Imports of packages as in Java rather than headers.
- No type conversion without using a function.
- nil replaces null.
- The pointer symbol -> is replaced by dot.
- No do while.
- No break in the switch case (as in Scriptol).
- Increments - and + + can not be used in expressions.
- Constants can be declared without a type.
- new is a function and not an operator.
In terms of libraries, Go goes directly against C++, not only there is no file header, but you can even include external modules directly from a remote site, because all the information for the integration is stored in the modules.
But it has disadvantages: the development of Haunts game written in Go was stopped because the OpenGL Module imported directly from GitHub has ceased to be compatible ...
Go vs. Java
Java was designed as a language for the Web and became popular thanks to that. It can run on the server or the client with applets.
Its main advantage is its huge library to build graphical user interfaces.
Go might adopt a different approach, using Webkit to the interface, Native Client or be integrated into the browser as JavaScript to run Web applications on the desktop.
Go vs. C Sharp
C# was created by Microsoft as an answer to Java and is designed to run on the .NET platform. The platform suffers from a lack of compatibility. It runs on Linux, but with reduced features compared to the version of Windows.
C# also works in Silverlight for Web applications.
Controversy over the name
A ticket has been created on the forum of the language on issue 9.
The author of an totally unknown language claims that the name Go is already that of his own language.
The fact is that a book has been written on it, under the title Let's Go!
Note that this language is called Go! and not Go, and that the word Go is in the public domain: it is the name of a Chinese board game that has existed for thousands of years!
Sites and tools
- The official Golang.org website.
- Online Go. Web service to execute a Go program through the browser. The program is compiled on the server, executed and the result displayed.
- List of resources.
- App Engine for Go. On the Google's cloud, you can build web applications using Go server-side.
- Go review. A comparison with other C-like languages.
Sample code
Hello World! program:
package main
import fmt "fmt"
func main() {
fmt.Printf("Hello, world\n");
}
Displaying chars of a string:
package main
import ("os";"flag";)
func main() {
var s string = "Demonstration";
for i := 0; i < s; i++ {
os.Stdout.WriteString(s[i]);
}
}
The lack of parentheses after the for is voluntary.
