Programming - - By Craig Buckler

It’s All Go for Google

Google Go Gopher mascotIt’s incredible to think how far web development has evolved since the mid-1990s. Attempting server-side application development back in those dark times generally involved nasty CGI, a dash of Perl, Notepad editing, and a lot of luck.

Today, developers are spoiled for choice with PHP, Java, C#, VB, Ruby, Python and a multitude of other platforms and languages. Evidently, Google did not consider that to be enough and have created their own new programming language named ‘Go’.

Go started as one of Google’s 20% projects. Google developers are permitted to spend one day per week on a project of their choice — that idea has led to GMail, AdSense and other successful systems. The Go team’s objective was to build a fast, fun and productive development language. It had to offer the performance and security of compiled programs with the ease and speed of interpreted language development.

Syntactically, the language is reminiscent of Object Orientated C. Here’s the usual “Hello, world” example:


package main
import fmt "fmt" // package implementing formatted I/O.

func main() {
	fmt.Printf("Hello, worldn");
} 

Go offers functions, loops, conditional expressions, pointers (without arithmetic) and all the other structures you would expect. There are a few interesting features:

  • End-of-line semi-colons are optional.
  • JavaScript-like anonymous / lambda functions and closures.
  • Python-like array slices and mapping.
  • Support for parallelism (concurrent execution) using “goroutines”. This alone could be an attractive option; few developers delve into multi-threaded coding and Go appears to make it easy.

Compiling

Google provide two compilers: 6g for 64-bit and 8g for x86 systems. Both are designed to be fast and moderately-large applications will compile in under one second. Even the whole package library containing 120,000 lines of code compiles on a standard laptop in less than 10 seconds. There is also an alternative compiler based on GCC called Gccgo.

Unlike Java and .NET, Go compiles to a native binary rather than managed or intermediate code. That’s an unusual decision and many will argue it’s a backward step. In theory, managed code is safer, more portable, and potentially faster because it can be optimized for the processor it’s running on. In practice, few Java and .NET applications are known for their speed.

Does Go Have a Future?

Google are releasing the Go source code under the BSD license and hope an eager development community will evolve.

The language is experimental and is not recommended for production environments — there is no IDE integration, standard libraries are sparse, and there are few code examples. However, the project appears to be mature and the developers used it to build the web server which runs the project’s official website, golang.org.

With Google’s backing and resources, you can be assured Go has a future. Personally, I think the language has potential but it will be some time before it can lure developers away from their current platform of choice. There’s also one option Google are considering which is a little more dubious … see Why Google Should Not Give Chrome the Go-Ahead.

Will you try Go? Is it the future or another minority development language?

Link: The Go Programming Language.

Sponsors