“Go” is a new systems programming language created by Google. Syntax is based on C++, and it compiles (like greased lightning apparently) – even has a Printf()! But beyond trivial similarities it is a very different beast:
- Interfaces replace class inheritance, but unlike Java interfaces, no explicit reference to the interface is required – as long as a type provides the methods named in the interface, it implements the interface.
- Garbage collection.
- Arrays are first class citizens – you don’t need to (can’t) use pointers to access the elements – instead you use [], and “slices”.
- A “slice” is a section of an array and behaves very much like an array – you can create a slice of a slice.
- Strings are first class and immutable, so memory allocation is not an issue.
- “Maps” are hash tables and are also first class.
- Threading is part of the language (no RTOS needed). “Goroutines” run in parallel and communicate via “channels”.
- No header files (that would have ruled it out of my book). “Packages” are used to group and reference (“import”) stuff.
- Reflection.
- Type conversion is explicit, no function overloading (that’s an odd one – presume it’s to speed up compile time – expect a lot of awkward function names), no user-defined operators.
Google reckon it’s “fun” to use. Compared to C++ that’s presumably a no-brainer – I’d say Java programmers would probably take to it as easily. Assuming it does what it says on the can.
From a dependency management point of view, I don’t much like the implicit (read “hidden”) implementation of interfaces. But I like the absorbsion of concurrency into the language – should allow modelling of references that disappear into the OS in C++. But it’s not ready for primtime yet – it’ll be a while before we go building a Go backend for Structure101…
Leave a Reply