When the
UK Government Digital Service (UK Electronic Government Service) took over the
GOV.UK code was mostly written
in Ruby . Since then, we have tried several languages, including Java, Clojure, Scala, Python, and Javascript. Recently, we switched to Go for a number of projects.
Below is a brief report of the experience. How we used Go and what in our opinion it is useful to know to other developers who are thinking about introducing a language into their environment. If you are interested in the details, then we published more detailed information in the blog -
router (
my translation ),
crawler and
CDN acceptance test .
Why go at all?
We are collectively aware that exploring and experimenting with new technologies introduces us to new approaches and expands our vision. New generation programming languages ​​offer new methods for solving problems.
We heard about Go a lot of compliments. The successful experience of using the language in the Google infrastructure and understanding the level of the team behind it gave a lot of optimism, yet the deciding factors for the
experiment were multithreading, speed of execution and undemanding resources. Other languages ​​we used simply could not offer us that.
Easy to understand
The language is defined by a fairly simple and clear specification. This makes it easier to cause initial interest among colleagues to parse the code, and then participate in the development. However, we never felt limited by this simplicity. When you need expressiveness for building your own models, the interface abstraction and composition provide an adequate and reliable arsenal of tools.
The praised standard library of the language turned out to be such. It covers a wide range of everyday tasks, including, for example, access to the file system, building HTTP services, console utilities, working with JSON data and calendar views. The standard library has sufficient depth and well thought out architecture. As far as possible, the library is built on RFC standards, as a fundamental material.
The library is written in high-quality, idiomatic code and is
well documented so that it can serve as a training tool even for experienced developers. In addition, the
course offers
a young soldier and the
utility of standard code formatting.Easy to deploy
Over the past few years, we have studied different Ruby deployment models (like Unicorn workers) and built
our own tools . We cultivate
regular and frequent releases . Technologies facilitating the deployment are extremely in demand in our circumstances, and here Go showed its best.
The language has no special system requirements to support the runtime environment. The program is statically compiled into one binary, which is installed on the machine where it will be executed. There are no runtime dependencies (like
bundle install for Ruby) required on the target machine. And restarting the service is an order of magnitude faster and easier than in Ruby.
')
Ease of use
Usually the team decides which language is appropriate. This is a team decision, not a personal one. Go over the past year has won wide acclaim from our team. Let's try to explain why.
It is easy for them to infect people, from a sysadmin who pretended not to program, to the developer who tried Go as a second language. The success of the language contributes a lot to the caring attitude of its trustees. In particular,
backward compatibility guarantees for 1.x releases are very important for us
.Utilities
go tool greatly simplifies life when solving typical tasks of the project development cycle. C-shaped syntax simplifies familiarity with a language before mastering specific idioms.
If you like the motto
“Make it work. Make it right. Make it fast ” (“ Get it to work. It worked correctly. And it worked fast ”), then you can be sure what you wrote on Go works quite quickly on the first attempt. The speed of execution is high and growing steadily with each release, and the standard library is well equipped. This means that we can concentrate on the characteristics of our code that are important for the team: clarity and readability.
What's next
To us in the GDS, to fully switch to Go, the rest is to deal with a couple of questions. One of them is dependency version management. For key nodes of the system, we must fix the versions of the code and the versions of its dependencies, and provide a reproducible assembly. Language Trustees have
publicly approved vending . We are attracted to the use of
gom and godep as possible solutions more developer friendly.
It is safe to say that we intend to increase our array of Go code.
[approx. lane.] From third-party Go libraries, GDS is actively using
gor to mirror traffic and
vegeta for load testing, which is written on the blog.