Ask HN: When to switch startup backend from Python to Golang?
Self explanatory question, but you could replace Python with NodeJS or any script like fast paced language, and Golang with Java or any sturdy compiled statically typed language
I don't want our startup to slow down much but also don't want our life to be hell (performance, code quality, jenga brick backend) later with our choices.
Did any of you start with Golang perhaps and felt you were as fast as perhaps Python would have made you?
Is there a standard canonical best practice around this?
16 comments
[ 3.2 ms ] story [ 47.6 ms ] threadThe performance of your backend can be very low on your priority list.
My experience there comes from working at Twitch. The entire video platform's backend was in Python for a long, long time - at least 5 years before some components moved to Go, piece-by-piece. The Python stuck around for over a decade in some fashion.
There are exceptions depending on what your startup does - if your fundamental _product_ depends upon serving millions of concurrent requests quickly on a really frugal budget, you probably already know that.
Building in Python feels like playing Jenga - easy enough at first but every change after a while is made with a silent prayer and anxiety.
But I think that whether your Python will age well or your Go depends more on the team and their level of experience with either tool. Use something reasonable, and pretty familiar, and stick to it. Don’t do dumb stuff like going crazy with metaprogramming, and avoid excessive abstraction - but those are just always the required conditions for keeping your group functioning well. Any language can be abused; abstraction is not really a property of a programming language choice.
Also, Guido and team are working full time on speeding up Python.
The Python is the less likely think that will suffocate you.
What did you suffer from in past projects with each of these languages?
Django, Flask etc have a lot of magic annotation business which became untenable after 2-3 years. It is really hard to reason about what they do and in what order. Much easier to reason about it with Java and Golang.
Which IDE is that? Those I've seen you hit a key, say F12, when your cursor is on a function or a class and it takes you right to where it's defined in whatever module, or shows you a list of objects with the same name in the project and you pick the one you're interested in.
>Django, Flask etc have a lot of magic annotation business which became untenable after 2-3 years.
Which ones? There is some kind of magic in g, and the application context. Are you talking about those? What did it prevent you from doing, and how did you get around these issues?
We used Django at a startup I was at in 2018, so my memory fails me on the exact issues since it has been so long. I will have to revisit Django and try to find what it was.
If you start with Python, you will use Python. Major rewrites in another programming language are not worth the time, the effort, nor the risk.
You could eventually replace some parts with golang to improve the performances, but that's unlikely going to be cost effective.
So, never.
Judicious use of mypy, unit testing and leaning heavily on the framework can keep things well organised
If you're hitting performance limits you likely have enough revenue to get some extra computing power and this might even be a viable long-term solution. Otherwise you can: - Build a service in the performant language - Embed C, Rust or Fortran into python
A full rewrite in a performant language is an option but almost never the right one in my experience. In any case optimise for development agility right now, which includes writing good organised code. You can cross the performance bridge when you come to it.