Picking a Language for a project
Whenever a team embarks on a project and has to pick a language or framework to build it in, the first response that springs forth is “what skills do my team have? How easy is it going to be to hire people to maintain this system?”. This results in many a potential Scala data engineering project written instead in Python.
And most of the time, this is entirely the correct answer – it’s rare that the cost of picking a language outside of your comfort zone pays for itself in a world where time to market rules supreme. I’d make the case that under certain circumstances, the value of the gains from picking Go dwarf all else.
OPP to Go paradigm shift
Moving from a single-threaded language paradigm, where adding async/awaits satisfies all urges towards multi-threading, to a concurrency first language is like stepping out of a car and into an aeroplane.
You’re thinking in a different dimension. All the traditional controls and levers at your fingertips do different things, and even your objectives feel different.
New concerns arise as you ensure that contexts close down Goroutines in the correct sequences only after channels are drained. This is on top of ensuring that you’ve provided a clean separation of concerns with recognisable patterns.
But just like learning to drive, it goes from a conscious exercise of remembering how to do the right things in the correct order to a subconscious matter of getting the system to go in the direction you want it to and muscle memory do the rest. After that, the sky is the limit.
Go’s most significant feature is concurrency. It gives first-class support to spinning up new threads. Under the hood, the magic of the thread scheduler means that running 100,000 simultaneous threads on an eight-core machine is par for the course rather than plan B when the office heater packs in.
Creating a new thread is so cheap, in terms of memory and cycles as well as lines of code, that anything that doesn’t need to be synchronous may as well be asynchronous. This scale of concurrency comes hand in hand with a change in mindset, sharing information by communicating instead of communicating by sharing information.
Whilst Go offers locking and mutexes - it works best when information is shared between threads with channels.
Development in Go isn’t all about intricate concurrent loops and channels. One of its strongest use cases, a stateless API, makes it feel like developing in a single-threaded imperative language.
With a couple of lines of code, a command-line hello world becomes a webserver - with each inbound request creating its own thread behind the scenes.
For a straightforward microservice, this allows staggering amounts of concurrent throughput for a trickle of CPU time - and this is where the language truly shines.
The microservices architectural pattern lends itself to a polyglot approach, with different services written in different languages slotting together neatly. With Go, a simple service that applies business rules to inbound requests and passes messages on requires no special packages outside of the core libraries.
Everything works out of the box and comes together as quickly as describing it - effortlessly scaling to loads that would come with an eyewatering price tag in any other system.
In one use case I’ve seen, a large international business turned a bloated .net monolith into a streamlined Go microservice with precisely the same business logic, dropping from 400 32-core machines to eight 2-core VMs at the same load.
Golang’s pre-packaged compiler doubles as a package manager, test runner, and powerful performance benchmarking/analysing tool. It gives you everything you need out of the box short of an IDE.
One of its neatest features is that the compiled binaries form a single file with all dependencies built in. Not only does this mean you don’t need to install runtimes, but it allows a service to be built directly into a scratch docker container with a minuscule footprint. Coupled with a container orchestration platform, the gap between designing a system as a microservice and building it becomes a matter of describing functionality.
Blazing a trail
Go is a pioneer in the world of massively multithreaded concurrency. But in its footsteps comes the likes of Java’s Project Loom, which seeks to rebuild the JVM’s threading model, providing the same first-class support to coroutines.
Learn go with us and boost your career
Delivering high quality, streamlined code is a developer’s job. Selecting the best programming language for the task is key to success. This can mean moving away from the old ways of Python and its ilk and moving with the times. Concurrency, greater throughput, and a smaller footprint make Go an attractive choice.
If you are interested in learning Go while working within one of the UK’s leading technology consultancies, we’re currently hiring for Go developers to join our growing betting and gaming team. No prior Go experience? No problem. All you need is a passion for technology engineering and a desire to learn. Click the link below to learn about our current opportunities.