GO Baby GO..

As someone who works with ‘C’, MSIL and Java bytecode to write system level software for our compilers and runtime, I was nicely surprised to see that someone has produced a new language aim at ‘System Level Programming’. Let me introduce you to ‘GO’ Googles new language and of course it is open source.

So why has google created the language? Well it is better to let Google themselves say why? (taken from their FAQ..)

No major systems language has emerged in over a decade, but over that time the computing landscape has changed tremendously. There are several trends:

  • Computers are enormously quicker but software development is not faster.
  • Dependency management is a big part of software development today but the “header files” of languages in the C tradition are antithetical to clean dependency analysis—and fast compilation.
  • There is a growing rebellion against cumbersome type systems like those of Java and C++, pushing people towards dynamically typed languages such as Python and JavaScript.
  • Some fundamental concepts such as garbage collection and parallel computation are not well supported by popular systems languages.
  • The emergence of multicore computers has generated worry and confusion.
  • Enough quotes.. I hear you say.. so what next if you want read more.. drive over to http://golang.org/.. now lets get practical and it up and running, as it is open-source and very young its a d.i.y. job… still it looks easy enough…

    They says its simple build… so lets put it to the test.. let my diary begin…

    Firstly… I’ll be up front and say these instructions are for the Mac OSX and tested on my little MacBook running 10.6 with xcode pre-installed..

    1) First download Mercurial source control:

    http://mercurial.selenic.com/downloads/

    2) Add the following to $HOME/.bash_profile using vim


    export PATH=$HOME/bin:$PATH
    export GOROOT=$HOME/go
    export GOARCH=amd64
    export GOOS=darwin

    Tip: if you don’t have a directory called bin, do a quick “mkdir $HOME/bin”

    3) Startup a new terminal session and check to see if the environment have been set with:


    env | grep "^GO"

    If all goes well you should see:


    GOARCH=amd64
    GOROOT=/Users/spg/go
    GOOS=darwin

    4) Okay, lets download the latest source code for Go!


    hg clone -r release https://go.googlecode.com/hg/ $GOROOT

    The ‘hg’ command gets the source code and hopefully your screen should be something like!


    requesting all changes
    adding changesets
    adding manifests
    adding file changes
    added 4109 changesets with 17125 changes to 2968 files
    updating to branch default
    1676 files updated, 0 files merged, 0 files removed, 0 files unresolved

    5) Now lets build it…


    cd $GOROOT/src
    ./all.bash


    wow.... A lot goes bye.... and then finally... it ends with......
    k-nucleotide
    mandelbrot
    meteor-contest
    pidigits
    threadring
    chameneosredux

    --- cd ../test
    1 known bugs; 0 unexpected bugs

    Wow… I appear to have something installed… it took me… less than fifteen minutes..

    So lets try some of the samples out…


    stephen-gennards-macbook:src spg$ cat hello.go
    package main

    import "fmt"

    func main() {
    fmt.Printf("hello, worldn")
    }
    stephen-gennards-macbook:src spg$ 6g hello.go
    stephen-gennards-macbook:src spg$ 6l hello.6
    stephen-gennards-macbook:src spg$ ./6.out
    hello, world

    Ohhh… my that was too easy… its time to leave the blog and start playing…

    What next… guess its time to watch a video about Go!


    [ad#Google Adsense-3]

    This entry was posted in go, Google and tagged , , , . Bookmark the permalink.