InfoQ

News

Google Experiments with a New Language, Go

Posted by Abel Avram on Nov 11, 2009

Community
Architecture
Topics
Language ,
Dynamic Languages
Tags
Concurrency ,
Google ,
Parallel Programming

Go is a Google experimental open source new language resembling C but adding features like reflection, garbage collector, dynamic types, concurrency, and parallelism.

Presenting Go on the Tech Talk Channel, Rob Pike, one of the main developers working on Go, said the language is experimental because “we don’t think this is the answer to everything, but we are playing and we think it is the time to tell the world about it.” The language has concurrency constructs included in the language and aims to let developers easily create parallel tasks. According to the authors, some of the language’s goals are:

  • Combine the efficiency of a static language with the easiness to write of a dynamic one. Practically, the developer can choose to go static or dynamic.
  • Safety. The language is type-safe not allowing implicit casts, only explicit ones. Also, the language is memory-safe by not providing pointer arithmetic and doing garbage collection.
  • Provide a good support for concurrency and communication.
  • Have an efficient, latency-free garbage collection.
  • High-speed compilation.

Some of the interesting features are:

  • The language has pointers but not pointer arithmetic.
  • It has interfaces.
  • It has synchronous channels. These channels are used to communicate between threads and is the basis for concurrency. Go encourages sharing memory by communicating it, not communicating via shared memory. Only one thread can have access to a shared value at a time, the values being passed between threads through channels.
  • Goroutines. This is another construct used for concurrency. A goroutine is simply a function or a method prefixed by the “go” keyword. A goroutine is associated with a thread and communicates with other goroutines through channels.
  • Parallelization. Goroutines and channels can be used to run computations on multiple CPUs.
  • Reflection. One can reflect on all types, channels.
  • Embedding. It is a simple way of inheritance.

The language has two compilers so far. One comes with different names for different platforms, 6g – 64-bit x86 or AMD64, 8g – 32-bit x86 or AMD32, and 5g for ARM platforms. The other compiler is gccgo. 6g has a mark-and-sweep garbage collector while gccgo has none, but a new one based on IBM’s Recycler is under work for both compilers. There is no IDE nor a debugger yet. 

One of the Go’s aims is to have a fast compiler which seems to be attained. The 6g compiler is faster while the gccgo is slower but creates more optimized code. The compiler generates only machine code, no bytecode for a VM, and they say it runs almost as fast a C code being 10-20% slower than similar C code.

There are already many libraries available for basic functions but many more are needed. Godoc generates documentation from source code similar to javadoc. Go is an open source project released under BSD license.

Resources: Go website, Go presentation by Rob Pike.

13 comments

Watch Thread Reply

needed ?? by Erik Gollot Posted Nov 11, 2009 11:45 AM
Re: needed ?? by Luis Espinal Posted Nov 11, 2009 10:16 PM
Re: needed ?? by Luis Espinal Posted Nov 11, 2009 10:22 PM
might be nice... by Stephen Johnston Posted Nov 11, 2009 1:28 PM
Re: might be nice... by totoro totoro Posted Nov 11, 2009 3:36 PM
Horrible Name by Nick Main Posted Nov 11, 2009 2:41 PM
Re: Horrible Name by Bruce Rennie Posted Nov 12, 2009 8:24 AM
Re: Horrible Name by Luis Espinal Posted Nov 14, 2009 5:49 AM
Just Another C++(C) Killer (JACK) by Oleg Olenin Posted Nov 12, 2009 4:34 PM
Re: Just Another C++(C) Killer (JACK) by Luis Espinal Posted Nov 14, 2009 5:58 AM
Re: Just Another C++(C) Killer (JACK) by Nathan Youngman Posted Nov 16, 2009 8:27 PM
Re: Structural typing by Daniel Kristensen Posted Nov 18, 2009 5:00 PM
It sounds like a C or even C++ competitor by Dominique De Vito Posted Nov 16, 2009 9:34 AM
  1. Back to top

    needed ??

    Nov 11, 2009 11:45 AM by Erik Gollot

    we really need a new language !
    It is the central problem of computer science nowadays, sure !!

  2. Back to top

    might be nice...

    Nov 11, 2009 1:28 PM by Stephen Johnston

    I hope it's nice... it's time for C++ to die in a grease fire.

  3. Back to top

    Horrible Name

    Nov 11, 2009 2:41 PM by Nick Main

    Surely Google could have come up with a more search-friendly name ?

  4. Back to top

    Re: might be nice...

    Nov 11, 2009 3:36 PM by totoro totoro

    >>I hope it's nice... it's time for C++ to die in a grease fire.
    or java

  5. Back to top

    Re: needed ??

    Nov 11, 2009 10:16 PM by Luis Espinal

    needed?


    Maybe not by you. If people had stopped every time somebody questioned a need for a new language or software technology, we'd still be coding COBOL on punch cards.

  6. Back to top

    Re: needed ??

    Nov 11, 2009 10:22 PM by Luis Espinal

    needed?


    Maybe not by you. If people had stopped every time somebody questioned a need for a new language or software technology, we'd still be coding COBOL on punch cards.


    I'll elaborate further:

    In all *hard* engineering disciplines, engineers learn all the attributes of each and every type of material and tool available, they study the attributes resulting from their combination, the limitations of those combinations, and new ways to combine stuff to go over those limitations (or to bring about new properties.)

    But in software, unlike our *hard* engineering colleagues, we have it backwards. It's not just one, or a small minority, but a large group that always groans at the sight of something new, however exploratory and tentative that might be (as if we have come up with all the tools necessary to tackle all the technical problems we have with sufficient satisfaction.)

    Given that the constructs we create are far more complex, and inherently more fuzzy and chaotic that what's done in the other engineering disciplines, it just doesn't compute to do software engineering AND NOT ACTIVELY pursue new lines of research and implementation to (hopefully) get better solutions to the problems we face.

  7. Back to top

    Re: Horrible Name

    Nov 12, 2009 8:24 AM by Bruce Rennie

    Ha! Here's the really funny part: someone's already used the name. Apparently Google didn't even google it.

  8. Back to top

    Just Another C++(C) Killer (JACK)

    Nov 12, 2009 4:34 PM by Oleg Olenin

    Why not to support D language?

    PS I was discussing with my colleagues Go today, they did not know about it, and when I was introducing it I mixed up Google with Microsoft. So my direct words were - "Have you heard about some new language from Microsoft called Go?".
    I think my mistake has more sense than to be only mistake :)

  9. Back to top

    Re: Horrible Name

    Nov 14, 2009 5:49 AM by Luis Espinal

    Nope. The other language you are referring to is "Go!" not "Go" :)

  10. Back to top

    Re: Just Another C++(C) Killer (JACK)

    Nov 14, 2009 5:58 AM by Luis Espinal

    Why not to support D language?


    Marketing? A tactical business decision? Or maybe the features of Go are specific for problems they've found within Google for which maybe D is not sufficient or perhaps not the best fit? Perhaps they have encountered specific technical difficulties with which this specific language is more suitable?

    I mean to ask that question, you should at least present a comparison between D and Go. That way the question can have some ground with which readers can ponder on the answer.

    I'd be honest that I don't know squat about D, but one feature in Go that I really, really, really like is that a class does not have to explicitly implement an interface to be used as a subtype of it.

    That is one hell of a powerful, flexible (and even natural) feature right there. I think any discussion between languages should at least have a comparison of main features and the brevity (or verbosity) with which main tasks can be accomplished.

  11. Back to top

    It sounds like a C or even C++ competitor

    Nov 16, 2009 9:34 AM by Dominique De Vito

    Well, at first glance, Go looks like a language from an inside Google startup.

    But it has some chances to grow :
    - fast compilations,
    - native compilation + byte-code generation for VM (=> different markets are targeted)
    - may be more easier to master than C or C++ (for example, there is no pointer arithmetic)
    - it looks like to provide a better support for concurrency and communication than C or C++ (multi-core CPU are targeted).

    Then, Go looks like a better C, or even, C++ : it may be replacing (in the future) C++ internally used inside Google.

    Dominique
    www.jroller.com/dmdevito

  12. Back to top

    Re: Just Another C++(C) Killer (JACK)

    Nov 16, 2009 8:27 PM by Nathan Youngman

    I don't know anything about D either, but at least I'm aware of it. From Pike's presentation, he said there hasn't been any new systems languages in a decade (or something along those lines, paraphrasing here). Oblivious?

    Totally agree on the approach to classes that avoids fixed hierarchies, there are some pretty cool features in Go.

  13. Back to top

    Re: Structural typing

    Nov 18, 2009 5:00 PM by Daniel Kristensen


    I'd be honest that I don't know squat about D, but one feature in Go that I really, really, really like is that a class does not have to explicitly implement an interface to be used as a subtype of it.


    Structural typing can be very handy for dealing with code you don't have control over, but I much prefer the approach taken by e.g. Scala where structural typing is not the default, but an option you have when you need it. After all, interfaces often have more semantics associated with them than what is conveyed by the method signatures, and when you use structural typing you lose this part. So if I have to choose one of the two, I prefer nominative typing.

Educational Content

Brian Marick on 4 Challenges and 5 Guiding Values of Agile Software Development

Brian Marick takes us through a quick tour of the most important values and challenges to adopting Agile successfully (they aren't the typical challenges and values we hear in the community).

Are You a Software Architect?

The line between development and architecture is tricky. Does it exist at all? Is an ivory tower actually needed? There's a balance in the middle, but how do you move from developer to architect?

Agile – A Way of Life and Pragmatic Use of Authority

The word 'authority' sometimes produces an allergic response in hard-line agilists. Freedom and authority – both are bad if misused and both are good if used in right spirit for a noble cause.

Getting Started with Grails, Second Edition

"Getting Started with Grails" brings you up to speed on this modern web framework. Companies as varied as LinkedIn, Wired, and Taco Bell are all using Grails. Are you ready to get started as well?

Using ITIL V3 as a Foundation for SOA Governance

Those familiar with only ITIL V2 often scoff at the thought that ITIL could serve as a governance framework for SOA. With ITIL V3, the focus of the framework shifted towards service-orientation.

Adrian Colyer on AspectJ, tc Server and dm Server

SpringSource CTO Adrian Colyer discusses AspectJ, SpringSource's dm Server and tc Server products, OSGi and Scrum.

Adam Wiggins on Heroku

Heroku's Adam Wiggins talks about Rails, Background Jobs, Add-Ons, Ruby, and how Heroku manages to work around Ruby's inefficiencies using Erlang and other languages.

SOA as an Architectural Pattern: Best Practices in Software Architecture

For Grady Booch the foundation of a good architecture is patterns, SOA being just one of many patterns. In this Second Life presentation, Booch attempts to bring more clarity on what architecture is.