Go from Google - Alternative to C++
Google has created the Go language to operate with multi-core processors of today, that is difficult with current languages. To do this he employed several known authors, and that explains the legacy syntax of the language.
- Ken Thompson. Co-author of UNIX, creator of B which took over 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!
Why use C++?
Designed for parallel programs, it must on modern computers provide faster processing.
Its syntax is simple and it can replace the C or C ++ language for all types of applications. It enables faster development.
Google wants to use it to make server software and Web applications such as GMail (the golang.org site is made with Go).
It will also run on the browser instead of JavaScript. The same tasks can operate on both the server and client.
Features
- 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).
CSP (communicating sequential processes) manages communication between program with support for multi-core processors.
Difference with C++
- 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.
Sites and tools
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.
(c) 2009 Scriptol.com