Go language from Google

 Google announced about new experimental language named "Go". People joke that next will be a debugger named "ogle".

 

So this language is supposed to replace C and is compiled to machine code, but it includes some features of modern dynamic languages, like garbage collection, lightweight threads (like in Erlang), built-in map type (so missing in Java), cool syntax, type safety, adequate packaging (no more ugly #includes), etc. etc.

 

Here are some links: 

 

Language spec: http://golang.org/doc/go_spec.html

Effective Go: http://golang.org/doc/effective_go.html

 

Example of code creating 100 thousands of threads and counting them:

 

package main

 

import ("flag"; "fmt")

 

var ngoroutine = flag.Int("n", 100000, "how many") //command line parameter "n" with default of 100000

 

func f(left, right chan int) { left <- 1 + <-right } //this function runs on thread, reading int from right and writing incremented int to left channel

 

func main() {

  flag.Parse();

  leftmost := make(chan int);

  var left, right chan int = nil, leftmost;

  

  for i := 0; i < *ngoroutine; i++ {

    left, right = right, make(chan int);

    go f(left, right);                                   //this statement starts a new goroutine (light thread)

  }

 

  right <- 0; // bang!                                    //write to the last channel

  x := <-leftmost; // wait for completion      //read from the first channel after it travelled all the chain

  fmt.Println(x); // 100000

}

 

Comments

For those interested, a language in the same space (compiles to machine code but with modern language capabilities), then D is a language that has been around for some time now (though I don't think there are more than ~40 open source projects using it). http://www.digitalmars.com/d/

Itay, one of the reasons I'm excited about Go because the syntax polished so perfectly. They thought about every small detail. And D language still uses breaks in switch to prevent fall through? Completely different league.

Why is this a .NET post?

does it fit ALM, Flex, Java or Python better? :-)

1. I don't find it amusing.
2. I understand... Since .NET is your daily practice at work, it was only a natural decision...
3. I don't find it amusing (!)

you win :lol

I think we need a new section opened for this kind of stuff...
Also, earlier I wanted to post about IE9 and its new JavaScript engine (which is said to be very strong) but I couldn't find the right niche...

go scala, go scala, go...