All Pythonistas should switch to Go … or okay, maybe just half
Your average software engineer is still in love with Python. Married, even.
But not those from Google, Uber, Dropbox, Soundcloud, Slack and Medium. Programmers in large companies have long fallen in love with the language with the cute mascot.
That’s not to say that Python isn’t good. It’s good!
But whether it’s for APIs, web services, or data processing, while most developers still use Python, top performers are increasingly embracing Golang or Go. Because it rocks.
Google was originally written in python – yes, Python is still cool – but around 2007 engineers were looking for a better language to perform typical tasks at Google. They were having problems like these, according to one Rob Pike talk in 2012:
- Slow constructions: Producing new code took forever. Sounds familiar to me!
- Uncontrolled dependencies: Have you ever tried installing a software package, only to find that you need to install at least five other dependencies and countless sub-dependencies to make it work? Turns out even Googlers have this problem.
- Each programmer using a different subset of the language: In Python, one developer can use the NumPy package, another prefers SciPy, etc. When programmers want to mix their code into a single package, things get complicated.
- Poor understanding of the program: People who say they understand the code the minute they read it are lying. At least if it’s not a very simple “Hello World” program. And code documentation often doesn’t help – in most cases, it doesn’t even exist, or it’s poorly written.
- Duplication of effort: Have you ever copied a piece of code from one part of the program, just to copy it somewhere else? Bad practice. But most programming languages make it easy to do.
- Cost of updates: With such a mess as described above, does it really surprise you that updating your software is going to take a lot of time and brainpower? Uncool.
- Version variation: With duplicate code floating around everywhere, engineers can update only one version of the original snippet and forget about the rest. So you end up with a version that contains both new and old code. Sounds chaotic? He is.
- Difficulty writing automatic tools: It is possible to write programs that write code themselves – in fact, most programs do at some point. But with modern programming languages, this is still difficult to achieve.
- Multilingual versions: You know the problem: Python is great for small to medium-sized scripts, C ++ is great for large programs, Java is great for web development, Haskell is great for lazy but robust code. The result is that a single program often contains snippets from several different languages. But for compilation, debugging, and for the sake of cleanliness, it is much better to write a program in a single language.
The trio therefore set out to design a clear, simple and readable language. A language that would eliminate, or at least mitigate, these all too common problems in software engineering.
The root of many of these common problems is the complexity of modern languages. Think about Python or C – have you ever tried reading all the documentation? Good luck with that.
On the other hand, the biggest characteristic of Go is its simplicity. It doesn’t mean that you can’t create complicated code with it. But Go is very deliberate not to have features that bring more complexity without solving the problem.
For example, Go does not have classes like other object oriented languages. A feature widely used in other languages, classes are ideal for making an object inherit properties from another object. The problem is, if you try to change the structure of one object without changing the structure of others, you break the code. Go has an alternative, called struct, which favors composition over inheritance.
Other key features of Go are:
- Security type: In C, you can use pointers to do just about anything, including crashing the program. Go don’t let you mess around like that.
- Readability: Like Python, Go puts readability first. This makes it more beginner friendly than most languages and makes code maintenance easier.
- Documentation: In particular, junior developers find it cumbersome to write blurb on your code so that others can use it. With Godoc, this process is much more automated than in most languages - and developers don’t have to waste precious time writing what they’ve done.
- Orthogonality: This means that if you change an object in your code, no other object will change because of it. In this sense, a the radio is orthogonal because the volume does not change if you change the station. Unlike C, for example, if you change one thing others can depend on it and change as well. Go is orthogonal because it simplifies things.
- Minimality: In Go, there is only one way to write a piece of code. Compare that to Python, where you have millions of ways to write something!
- Convenience: Important things should be easy to code, even if that means other things are impossible to do in Go. The logic here is that you want to increase a developer’s productivity by making recurring tasks quick and easy. And if there is a more complex problem – which is rare anyway – they can always write it in another language.
It may all sound boring and uncreative. And in a way, it’s true – it’s not a language with great features that you could use to impress others, a plethora of ways to solve a problem, no limitless freedom. Go is not a language that is there to explore, to do research with.
But it’s amazing when you’re trying to build something that works. When you are part of a team with many different people from different backgrounds working on the same code. When you are tired of all the mess you have with other languages.
… With a thriving community
Because of its simplicity, Go is one of the most collaborative languages out there today. Gone are the days when programmers would sit in their little cubicles and never meet others.
Now we have StackExchange to solve all of our coding issues. And we have Slack, Zoom, Google Meet and more to keep in touch with our team. But modern languages are still suited to the little nerd in the cabin.
Come on that changes that. Although it is twenty years younger than Python, it has a vibrant community.
It is therefore not surprising that they put respect, openness and friendliness at the top of their code of conduct. While other languages, like Python or C, also have comparable community statements, there is less emphasis on these core values.
It is therefore not surprising that the community plays an explicit role in the annual Go polls, unlike many other languages.
The data speaks for itself
According to Survey 2020 Go, the language of Google is primarily used for web development, network and system programming. The landscape for Python is quite similar:
The only striking difference is the amount of Python used for data analysis and machine learning. And on these areas, others hot new languages emerging.
Apart from that, you can see that many uses of Python could be replaced by Go. This includes 50% in web development, 38% in system administration and DevOps, and 19% in network programming. Even if you assume that a lot of developers do all three of these tasks, you can safely assume that half of the Pythonistas are doing things they could do in Go.
Indeed, developers are aware of the enormous potential that Go has to offer. According to Hackerrank, about a third of all programmers wanted to learn Go in 2020.
The trend is real – and since Go is very easy to learn, we should see a shift from Python to Go in the next few years. For most businesses, especially those that aren’t as big and well-funded as Dropbox or Medium, rewriting all of their code on Go will cost too much. But for new projects, you should at least give it a try.
In larger companies, developers are already building their success with Go. When are you going?
This article was written by Rhea Moutafis and was originally published on Towards Data Science. You can read it here.