Some of our projects are gaining traction lately. That’s why we need to scale some parts of the infrastructure. 9elements started the search for a language that gives us more performance but that’s also expressive and easy to write. Since Go is used by some high profile projects we decided to give it a shot.
Go is a very simple language: It is typed statically. It is garbage collected so you don’t have to worry about memory issues. It has built-in support for concurrency. The most powerful feature is the absense of classic objects with methods. You have structs like in C. And you have functions that can have receivers so that they can operate on structs, but there is no direct concept of inheritance - though you can imitate it with anonymous fields. The most powerful concept are interfaces. Have you ever seen a bigger Java or C++ architecture where almost every class had an interface so that you can swap out the implementation. Go is like “Hey, let’s get rid of the classes and just focus on interfaces!’
But Go also has some drawbacks: Coming from a Ruby background the language is not very expressive. You can do some meta programming using struct tags (it’s like annotations in Java for structs) together with reflection, but the possibilities are limited. Especially if you’re overusing struct tags your code becomes quite illegible. All in all I think that the pros weigh more than the cons so we decided to use it in production.
Since we’re mostly building web applications it was a natural thing to build a web application. The next step was to check out the Go ecosystem to do so. We’ve taken a look at the following web frameworks:
- Beego - Beego is a full stack web framework. It seems to be pretty popular but we were searching for something more lightweigt.
- Revel - Same goes for Revel.
- Martini - Martini is also one of the more popular Go web frameworks by Codegangsta. But it is abandoned by it’s author due to that it’s source is not very Go idiomatic.
- Negrino - It’s by the same author like Martini, but it is broken down to smaller components and written in Go idiomatic code.
Eventually we went with Negrino since it is lightweight and we didn’t want to swap out a monolithic framework (Rails) with another monolithic framework. We wanted something small that does a few things really well. We went with GORM for the database management, which seemed to be the best object relational manager (didn’t we say earlier doesn’t have objects?) out there.
The application we’ve written is a small service that does autocompletion for German cities and ZIP numbers and it also provides the geolocations for it. We were able to drive down response times from 50ms to 7ms which is quite awesome. All in all it was a great experience to rewrite that service in Go and in the future we’ll probably use Go as a great sidekick technology for Rails.
If you like what you’re reading and you also want to play with these technologies - 9elements is hiring.