Go with Google - Yet Another Language! |
Written by Mike James | |||
Friday, 04 June 2010 | |||
Google is now using its new language - Go - for real programming tasks. The real question is why?
It is always puzzling why one computer language takes off and other simply never get near the runway. Why Ruby? Why Java? Why Python? You can ask this question and enthusiasts will give you reasons that sound good - clean, powerful, gets to the point, well structured, minimal grammar and so on. But you have heard it all before in connection with other languages that just didn't catch on.
Of course one reason why a language catches on is because some big commercial concern promotes it. This was clearly the case with C# - Microsoft introduced it alongside Visual Basic .NET and almost overnight created a programmer community that simply didn't exist the day before the launch. Now Google seems to fancy its chance of introducing a new language to the programming world. Google's language is called Go - but there is at least one other language (and well known game) with a very similar name so this might have to change. On the other hand Go fits with -oogle which could be the name for a future IDE or a debugger for the language! Currently the language is a mess of different command line compilers each with its own target platform and pros and cons. Don't expect a comfortable IDE any time soon. So why another language? There is the view point that says you really should have a very good reason for introducing yet another language and to be honest it is difficult to see the rationale for Go. If you read the stated aims of the language then they are all laudable - reduced syntax, easy code entry, fast compile and fast to run. Like just about every other recent language the syntax is like C with a few variations. It is claimed that the syntax has been cleaned up compared to C with fewer brackets and a keyword at the start of each declaration to indicate the sort of thing being declared - var, func, type etc. It is in the main a fairly reduced language, apparently in an effort to make it fast. Features that have been left out include exception handling, inheritance, generics, overloading and pointer arithmetic. Notice that it does have pointers, just no pointer arithmetic. It isn't even particularly object-oriented in the classical sense. Go objects are compatible if one implements a sub-set of another's interface and hence can be used in its place. As types can implement multiple interfaces this is a sort of multiple inheritance even if the language doesn't even support type inheritance of any kind. This creates an implicit type dependency rather than a class hierarchy which is a novel feature of Go. Another absent feature is method overloading. A Go method is called only by name and the signature simply has to be correct. All of these design decisions make the language faster to compile and faster to run. The basic data types include maps (aka associative arrays) and strings. About the only notable basic language feature is that ability to return multiple values which can be retrieved using multiple assignment e.g.: x,y = MyFunc(); What the language seems to be strong on is concurrency. It doesn't have threads but goroutines - a play on coroutines. Goroutines run at the same time on a set of threads. Each goroutine gets its own stack and is essentially isolated from other goroutines. To allow communication, Go provides channels that can be passed as parameters. This makes building producer consumer style parallel programs fairly easy. So at the end of the day what do we have? A lightweight systems programming language which doesn't have much to complain about, with a few idiosyncrasies and fast compilation and execution. Is this enough to justify its existence? Personally I think not but I seem to be in the minority as the TIOBE index shows Go listed at number 18 and rising rapidly. Of course there is on other small detail about the Go language - at the moment it doesn't work well under Windows. There is a Windows port underway but it is poorly documented and difficult to get started with - but it does have the advantage that its a binary install. If you would like to try your hand at Go then see Getting started with Google's Go Go is interesting but not revolutionary. If it catches on it will be another one of those language mysteries mentioned at the start.
<ASIN:0763776270> <ASIN:1590591348> <ASIN:0805316701> <ASIN:0471113530> <ASIN:155860698X> |
|||
Last Updated ( Wednesday, 11 May 2011 ) |