Golang is a win-win for developers and their customers

    By Oliver Hathaway, Engineer at BJSS

    Oliver Hathaway

    Golang is a paradigm shift away from earlier programming languages. It cuts processing and compile-time, adds flexibility and decreases software footprint.

    Top 10 Skills For Technologists In 2022

    wHY GO IS EMERGING AS A WINNER FOR TECHNOLOGY ENGINEERS AND THEIR CUSTOMERS

    I came to Go from a strong background in traditional full-stack development: C#, JavaScript, SQL server. For those systems, “doing it better” looked like picking the most relevant framework, using the features the way they were supposed to be used, and avoiding inefficient anti-patterns.

    Concerns about eking out a little more performance from a CPU took a back seat to well-structured code that didn’t take a PhD to read.

    Stepping from that into a mature Go development environment and learning the syntax and fundamentals of the language, I found myself writing code an order of magnitude more efficient without surrendering scalable readability or dusting off my old algorithm design textbook.

    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.

    OOP to Go paradigm shift

    171029 - Bristol Office (24)

    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.

    Concurrency

     

    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.

    Throughput

    Build-for-the-Future

    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 legacy .net application 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.

    Footprint

    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.

    An ever-growing community provides a rich and mature third-party package support, with the core language team still adding functionality to the stable codebase. Overall, Go is a language that’s here to stay. And just as front-end web development has JavaScript, back-end API driven systems have Go. It can be applied to other areas, and other languages work for the same role - but in its domain, Go is king.

    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.

    Lead-magnet-recruitment