Live data from Hacker News

Why we switched from Python to Go

getstream.io

81–90 of 406 posts

Re: Why we switched from Python to Go

#81

Why does anyone write web apps in Python? PHP? Ruby? Modern Java and Go are so much faster than the alternatives that it's stupid to consider anything else if performance is important. Golang and Java can manage over a half million HTTP responses a second. Node is pretty fast but why bother when Java is many times more mature in features, tooling, and and supports concurrency... And uses less ram and is usually faste…

Efficiency can be language performance or developer performance or whatever.

Higher level languages might offer lower raw performance and more bugs. But they offer more features per dollar.

That isn't really specific to programming. You might also wonder why McDonalds is popular, even though their food is...meh.

Re: Why we switched from Python to Go

#82

Why does anyone write web apps in Python? PHP? Ruby? Modern Java and Go are so much faster than the alternatives that it's stupid to consider anything else if performance is important. Golang and Java can manage over a half million HTTP responses a second. Node is pretty fast but why bother when Java is many times more mature in features, tooling, and and supports concurrency... And uses less ram and is usually faste…

> All the big companies are using Java and Go almost exclusively for high volume endpoints

Please cite “all the big companies.” Also exclusively? No seriously, that is a bold claim. Google isn’t one of them because most of those hotepots are still written in C++. I don’t know how you can claim this. Based on some occaion company blog posts, changing just one or two endpoints out of say 100?

What about Rust? I also know companies rewrote some hotspots in Rust too.

Re: Why we switched from Python to Go

#83

Why does anyone write web apps in Python? PHP? Ruby? Modern Java and Go are so much faster than the alternatives that it's stupid to consider anything else if performance is important. Golang and Java can manage over a half million HTTP responses a second. Node is pretty fast but why bother when Java is many times more mature in features, tooling, and and supports concurrency... And uses less ram and is usually faste…

I wonder the opposite. Hardly any system needs to process 500k response per second. But nearly all of them benefit from the developer productivity that Python/Rails offer.

My current company has 15 Java & React engineers where 2 or 3 Rails would suffice. Load tops out at maybe a dozen requests/second. Feature development is super-slow. System complexity is off the charts.

Re: Why we switched from Python to Go

#84
post #75
post #55

Oh, terrific, another one. The only solid reason this article gave was the second one and, really, is the only one that would ever make sense: If the language one's using becomes the bottleneck then, by all means, change it[1]. Everything else is fluff and opinions. Every single other reason is stuff that is entirely subjective and/or python already has and even the article itself acknowledges, at least for one "reas…

I don't think that performance is the key reason to switch from Python to Go (although it is nice): as someone who switched from Python to Go, what really made it worthwhile for me was knowing that my code is significantly more likely to be correct when it runs. Go's typing is much nicer than Python's, for this use case. Performance is just gravy.

I hear that. I work in Python, but prototype most things in Go, simply because many classes of problems benefit from the additional structure, and a compiler that can reason about that structure. Also Go has excellent tooling, it has great libraries, it compiles to static binaries, and anyone can read it.

I'm hopeful about Python's type checking though, but so far it leaves a lot to be desired (absolutely no recursive types, lots of bugs, strange restrictions, confusing for variables, etc).

Re: Why we switched from Python to Go

#85
post #69
post #68

Earlier quoted context omitted.

Yeah, plus even if performance is important, the app layer isn't necessarily the best place to optimize. It doesn't really matter how fast you sprint between database calls if the database and its IO dominate your site's performance profile, which they often do...

Everyone seems to say this and also to write really slow websites.

Most websites are written to minimize developer time not processing time.

Re: Why we switched from Python to Go

#86
post #55

Oh, terrific, another one. The only solid reason this article gave was the second one and, really, is the only one that would ever make sense: If the language one's using becomes the bottleneck then, by all means, change it[1]. Everything else is fluff and opinions. Every single other reason is stuff that is entirely subjective and/or python already has and even the article itself acknowledges, at least for one "reas…

It's subjective. Big benefit I see with Go is that you get a fast language (comparable to C++ and Java) while still being very productive to work with.

We actually did try pypy for a few parts of our infrastructure. It's better, but for what we tried only 2x faster.

Re: Why we switched from Python to Go

#87
> Python allows you to get pretty creative with the code you’re writing. For instance, you can:

> Use MetaClasses to self-register classes upon code initialization

Avoid metaclasses....

> Swap out True and False

Not possible anymore

> Add functions to the list of built-in functions

What are the practical reasons?

> Overload operators via magic methods

Useful but also recommend don’t. I can see someone writting numpy would do that, but most applications don’t have a reason

Profile profile profile! Find the bottlenecks.

Re: Why we switched from Python to Go

#88
post #75
post #55

Oh, terrific, another one. The only solid reason this article gave was the second one and, really, is the only one that would ever make sense: If the language one's using becomes the bottleneck then, by all means, change it[1]. Everything else is fluff and opinions. Every single other reason is stuff that is entirely subjective and/or python already has and even the article itself acknowledges, at least for one "reas…

I don't think that performance is the key reason to switch from Python to Go (although it is nice): as someone who switched from Python to Go, what really made it worthwhile for me was knowing that my code is significantly more likely to be correct when it runs. Go's typing is much nicer than Python's, for this use case. Performance is just gravy.

Type errors/misuses aren't my biggest problem and Go's type system isn't very powerful. The Python code is smaller, more expressive, easier to review, etc. I have more confidence in the correctness of pylinted Python code. I wouldn't jump to trade conciseness for compile-time type safety, particularly for applications, because it's easier to create/not see a logic error in heavy code. And depending on what you're doing, Python's type system may be more powerful/appropriate.

Re: Why we switched from Python to Go

#89

> Python, Node and Ruby all have better systems for package management Maybe they have better tools for managing package dependencies but Go doesn't have to deal with interpreter dependencies, which can be a major headache. Go also doesn't have the problem of conflicting system level packages. Honestly no matter how good your deployment practices are, if you have to manage an application's deployment long term you're…

> conflicting system level packages In Python, if you have control over the target system, this is solved with virtualenv. You can install whatever versions of libraries you want in there with pip without causing conflicts with system level packages. If you intend to ship to end-users, yeah, you are kinda screwed. You are stuck using one of the various "freeze" methods, which, in my experience, kinda blow.

We use Nix which is much nicer than pyenv/virtual environment, but it's still a pain compared to Go. This is mostly due to Python's runtime model, and maybe also the tendency for Python applications to have very tall, broad dependency graphs.

Working with nix is also not very easy; docker might fare better here, but probably just a lateral move. In any case, Go outclasses Python on deployments. Also, my company is looking into compiling Python as a means of code obfuscation; Go compiles by default, which (modulo stripping) is probably enough obfuscation for our purposes.

Re: Why we switched from Python to Go

#90
post #87

> Python allows you to get pretty creative with the code you’re writing. For instance, you can: > Use MetaClasses to self-register classes upon code initialization Avoid metaclasses.... > Swap out True and False Not possible anymore > Add functions to the list of built-in functions What are the practical reasons? > Overload operators via magic methods Useful but also recommend don’t. I can see someone writting numpy…

Django uses metaclasses quite nicely actually for the the Forms and Model definitions.
Post reply on HN