Go language from Google, a Ford T with a Ferrari engine

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 was intended to replace C++ for low level programming, that neither Java nor C# can do. But that does not mean it is actually used for that. It is amusing that the creators have wanted to keep a syntax that programmers are accustomed to, that of C, but the majority use Go to replace Python!

Go programming language, Ford T with Ferrari engine
Modern features and 40 years old syntax!

To design it, several veteran of programming were hired, and that explains the legacy syntax of the language...

These developers have nothing to do with C++, which was created by Bjarne Stroutstrup on the basis of the C language, which explains different choices of design, such as composition instead of inheritance.

The goal of Go is to stay as close as possible to the C language while significantly improving productivity and replace it. 
It 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, and with some borrowing from Pascal (1970)!
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 or Ruby because its compilation speed is suitable for scripting, while it produces fast binary executables. It so can replace all languages ​​for command line programs.

Another quote, from the author, Rob Pike:

The key point here is our programmers are Googlers, they’re not researchers. They’re typically, fairly young, fresh out of school, probably learned Java, maybe learned C or C++, probably learned Python. They’re not capable of understanding a brilliant language but we want to use them to build good software. So, the language that we give them has to be easy for them to understand and easy to adopt.

Why use Go? The user experience...

The experience is rather negative among individual programmers, having used other modern languages. Go is primarily designed for a team where adding / replacing a programmer is recurring. It allows to be rapidly productive even for beginners.
Its syntax and the way it treats objects intend it primarily for programs on servers  as a replacement to Perl, Python or PHP. It then allows both a fast development and quicker scripts.
Has builtin concurrency and garbage collector. The use of a garbage collector is generally not suitable for the making of an OS, drivers, but it has been specially optimised to achieve pause of less than 100 microseconds!

It may be used to make server software and for example to build a CMS and generates HTML pages, a field where it is superior to Python or Java.

It is simpler than C++, more adaptable than Java, quicker and safer than Python, has an extensive (server side) and 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 does the clear description of errors it displays too, unlike other languages such as. C++.

A syntax from the C language

The syntax improves productivity.

CSP (Communicating Sequential Processes) manages communication between program with support for multi-core processors.

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 (the latter are now obsolete).
Its main advantage is its huge library to build graphical user interfaces.
Go as Java allows you to test a program or script development immediately, but it produces binary code, so is faster and more compact.

Go vs. C++

Even if it uses a syntax of the 70s, programming is simplified by Go compared to C++. Some common causes of errors coming from the syntax are removed.
Multi-threaded operation becomes quite easy thanks to a single command.
The garbage collector eases memory management.

Comparing syntax...

Displaying a message.

Go

import "fmt"

func main() {
    fmt.Println("Hello, World!")
}

C++

#include <stdio.h>

void main() {      
  puts("Hello, World!");  
}
Variable declaration. The type may be defined by inference in Go.

Go: two equivalent declarations.

var i : int = 10
var i = 10

C++

int i = 10;
Declaring a string.

Go

var str = "Hello in Go"
fmt.Println(str)

C++

string str = "Hello in C++";
puts(str);
Constant...

Go

const a = 1

C++

const int a = 1;
Declaration. May be grouped. There is permutation with respect to C++, but no obvious advantage.

Go

var b int = 2
var x, y, z int
var i, j, k int = 5, 10 , 20
b += x 

C++

int b = 2;
int x, y, z;
int i = 5, j = 10, k = 20 b += x;
Inside a function, a variable may be declared implicitly. It is always explicitly declared in C++.

Go

x := 2

C++

int x = 2;
If structure. We may include a declaration before the condition. This brings nothing more and makes the code less readable.

Go

if x < 1 {
  fmt.println("ok")
}

if x = mult(y, 100); x < 1000 {
  fmt.Prinfln("ok")
}  

C++

if(x < 10) {
  puts("ok");
}
  
x = mult(y, 100);
if(x < 1000) {
  puts("ok");
}  
The switch structure. The difference with C++ is the disappearance of closing break, omission of which makes it possible to combine several cases to the same processing. But you can have the same result with the reserved word fallthrough that has the opposite role of break..

Go

switch x {
 case "a":
     fmt.Println("a")
 case "b":
     fallthrough
 case "c":
     fmt.Println("b or c")
 default:
    fmt.Println("x")
}

C++ 11

switch(x) {
  case "a": 
    puts("a"); 
    break;
  case "b": 
  case "c": 
    puts("b or c"); 
    break;
  default:
    puts("x");  
}
The for loop is the only control structure for iterations. Note the disappearance of parentheses. This makes mandatory the braces.

Go

for i:= 0; i < 10; i++ {
  fmt.Println(i)
}

C

int i;
for(i = 0; i <= 10; i++) 
  puts(i);
For replaces while and it seems not a good choice. "while i < 10" is understandable, but "for i less than 10" does not make sense.

Go

var i  = 0
for i < 10 {
  fmt.Println(i)
  i += 1
}

C

int i = 0;
while(i < 10) {
  puts(i);
  i += 1;
}
An infinite loop is very simplified. While Rust chooses unnecessarily to invent a new structure, but none offers security, it is only reached with mandatory increment at end of the loop as does the Scriptol language.

Go

for {
  if condition {
  	break
  }
}

C++

while(true) {
  if(condition) 
    break;
}

For ... each. It is achieved with range. But it is simpler en C++ 11.

Go

var arr = []int { 5,10,20 }
for i, v := range arr {
  fmt.Println(v)
  ...
}

C++ version 11

int arr[] = { 5,10,20 };
for(x : arr) {
  puts(x);
  ...
}
Declaration of a function. Note that JavaScript uses the reserved word function, Python def, Rust fn and Go func. Each wants to distinguish itself, but why not call a function function?
Go syntax to declare a function is simple, while Rust being unnecessarily complicated and stupid.
If several arguments have the same type, the type is declared once. But they remains static in the two languages and do not offer multiple dispatch as in Julia.

Go

func mult(x int, y int) int {
  return x * y
}

C++

int mult(int x, int y) {
  return (x * y);
}
However a function can return multiple values ​​as a tuple while C++ must use an array or a tuple object, but not a direct assignment.

Go

func ftuple(x int, y int) (int, int) {
  return x * 2, y * 2
}
x, y = ftuple(10, 15)

C++

int[] ftuple(int x, int y) {
  return { x * 2, y * 2 };
}
int z[] = ftuple(10, 15);
x = z[0]; y = z[1];
Data structures are declared in verlan mode. The authors of the language do not drive a car. They drive a vehicle of type car, it's much better.

Go

type Point struct {
    x int
    y int
}

C++

struct Point {
    int x;
    int y;
}
Example of script: displaying letters of a string with a for loop.

Go

package main  
import ("os";"flag";)

func main() {
  var s = "Demonstration"
  for i := 0; i < s; i++  {
    fmt.Println(s[i])
  }
}

C++

#include <stdio>
#include <string>

void main() {
  string s = "Demonstration";
  for(i : s) {
     puts(i);
  }
}

 

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.
In general that facilitates the distribution of programs, but it has also disadvantages. Modules imported directly cease to be compatible and require rewriting the software.

Controversy about the name

At the public launch of the language, 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!
But this language is called Go! and not Go, and actually the word "go" is in the public domain: it is the name of a Chinese board game that has existed for thousands of years! (And also a verb in english).

Sites and tools

Programming and data languages Asm.js - Basic - C - C++ - C# - Dart - Go - Java - JavaScript - Julia - Pascal - PHP - Prolog - Python - Ruby - Rust - Scala - Scriptol - Swift - TypeScript - HTML - Wasm - XML - XAML - SQL