Live data from Hacker News

Why We switched from Python To Go

medium.com

21–30 of 79 posts

Re: Why We switched from Python To Go

#21
post #4

> #2 Static Type System It's really weird to see one of the reasons for their switch to Go was because it's a statically typed language. If you want static typing, you don't choose Python in the first place. You know it beforehand and it shouldn't come as a surprise for you. > For example it has http, json, html templating built in language natively So does Python with urllib and json modules. I don't know if it has…

>If you want static typing, you don't choose Python in the first place. You know it beforehand

Well, people begin using languages for different reasons and it's possible that there was never a conscious explicit choice of "dynamic vs static". Instead, they were actually interested in some specific task library (content management system, numeric computing, scrape webpages) and the underlying language happened to be Python.

For example, a programmer might stumble into Python because he was using Django, or work colleagues used Numpy/Scipy, or the easiest HTML parser was Scrapy. That the language happened to be Python and it happened to be "dynamic" is incidental. In Django's case, that project is 4 years older than Golang. Maybe Java Spring was too verbose but the new Golang with static typing (and less-verbose type inference) hits the sweet spot.

Probably the most widespread example of "dynamic vs static" not being a choice is Javascript. Millions of us didn't program Javascript because it's dynamic; we used it because it's the only language available on all the browsers.

Also, some programmers may not realize they want static typing until they experience pain points with dynamic languages on large projects. (E.g. easier refactoring.)

Re: Why We switched from Python To Go

#22
post #14

Earlier quoted context omitted.

About the static type system: When people say they like Go's static type system sometimes they are comparing it to something more verbose like Java. Think about someone that knows Python and have to use Java, then they think that all static type languages are as a pain in the ass. So they begin disliking static type systems when they really just hate the Java's one. And so the moment they are using Python and start p…

Java the language is verbose, sure... but the type system?

I think yupyup is referring to the fact that all types must be explicitly annotated.

(I favor this and explicitly annotate most of my types in Haskell and Scala. Makes reading easier. But I did occasionally find it annoying in Java when it was mandatory.)

Re: Why We switched from Python To Go

#23
post #4

> #2 Static Type System It's really weird to see one of the reasons for their switch to Go was because it's a statically typed language. If you want static typing, you don't choose Python in the first place. You know it beforehand and it shouldn't come as a surprise for you. > For example it has http, json, html templating built in language natively So does Python with urllib and json modules. I don't know if it has…

I haven't used Jetbrains' go ide, but extrapolating from my time with intellij and pycharm it seems that their ides work significantly better with static type systems. (Find usages, rename function, etc are less accurate.)

Re: Why We switched from Python To Go

#24

"How we rationalized after the fact that we wanted a new toy" There are many good reasons to switch from Python to Go, but that article misses them all.

What are those reasons in your opinion?

Keeping your engineering team happy by allowing them to play with a new toy.

Re: Why We switched from Python To Go

#25
post #19
post #4

> #2 Static Type System It's really weird to see one of the reasons for their switch to Go was because it's a statically typed language. If you want static typing, you don't choose Python in the first place. You know it beforehand and it shouldn't come as a surprise for you. > For example it has http, json, html templating built in language natively So does Python with urllib and json modules. I don't know if it has…

"If you want static typing, you don't choose Python in the first place. You know it beforehand and it shouldn't come as a surprise for you." People change. Dynamic typing was popular some years ago, but opinions have changed.

Projects change too. What's good for a small project might not be for a big one.

Re: Why We switched from Python To Go

#26

"How we rationalized after the fact that we wanted a new toy" There are many good reasons to switch from Python to Go, but that article misses them all.

What are those reasons in your opinion?

You identified that your code has few data parsing and manipulation, and a lot of concurrency bottlenecks after auditing your system and making measurements.

You have a lot of technical debts in your concurrency code and don't think you have the skills to solve them internally while Go would let you do it.

You have data about your deployment and weighted security updates easiness against self enclosed binaries and the later is more appealing.

You evaluated the cost of a rewrite in the current used language vs the new one, including training and documentation and it was in favor of Go.

You have embarrassingly parallel operations the market / your resources forces you to optimize and the serialization cost of data makes it impractical with multiprocessing.

You want a sweat spot between verbosity, high/low level, productivity and performances and don't mind having something average in every of those aspects as long as it's balanced.

You are aware of the cons of Go (very heavy error handling, skinny stdlib, youth of the ecosystem, etc) and it's still worth it.

You made a prototype of a basic task you had in the previous tech, with the last version of the previous tech and Go and the ratio "cost / result" is clearly in favor of Go.

You have experts in Go in your team and their talent would largely compensate the lost of the talent in previous tech.

You deeply checked Java, Erlang, C#, Haskell, Rust and JS as alternatives and your team agreed Go would still be better.

You checked solutions to your problem (e.g: for python, you tried crossbar before being sure you can't do your microservices properly) and damn, Go still solves them better.

You know how much RAM your service can afford, and spawning goroutines likes it's going out of style will be the proper ratio of easiness vs cost.

Basically all this posts says is "x is good so it's cool we have it". Good reasons to switch are never black and white, they are justified by experience and data, in a specific context, relatively to pros and cons of other solutions.

Anything else is just geeks being geeks and wanting cyber poneys. I understand that, I do it all the time. Loving your job and trying new stuff is a perfectly reasonable motive in my book

But I'm not going to write a blog post about it pretending I had technical reasons while I did clearly zero measurements and I am just quoting what other people say about Go.

The blog post sounds more like they had lunch and they said "dude, we should totally rewrite that in Go" and went for it. Then they measure a newly created service against legacy code and say it's better. Well, guess what, if you make a successful rewrite of anything with the same people, it will be better because you had the experience of the previous one.

The clue here is when they said they had less code in Go than in Python. This is clearly a red flag.

Plus if you had only 35% gain of perf from your Go system, something is wrong. With pypy only I can gain up to 800% of speed on my 2.7 system without changing a line of code. In 3.6 with libuv and asyncio you can also get a huge gain on IO operations.

Done properly, you should have way more gains from a Go rewrite. Or your problem didn't need Go.

No research has been done here.

Re: Why We switched from Python To Go

#27
post #2

Next up from The Author: 5 Reasons Why We Switched from MySQL to Postgres Why We Switched from Postgres to Oracle 11 Reasons For Switching From Oracle To KDB 7 Reasons Why We Switched from Go to Fortran-77 Grammar errors are provided for free by The Author.

Well Medium strikes again. Every post on this platform seems to be utter bs.

Re: Why We switched from Python To Go

#28
post #9

Point 3 Goroutines are more performant than python threads if you don't understand the difference between a thread and a routine.

How about asyncio in python 3 and gevent etc. in python 2?

Callbacks (asyncio & gevent) are not the same as coroutines. You have to experience the callback hell to understand the difference.

Re: Why We switched from Python To Go

#29
post #28
post #9

Earlier quoted context omitted.

How about asyncio in python 3 and gevent etc. in python 2?

Callbacks (asyncio & gevent) are not the same as coroutines. You have to experience the callback hell to understand the difference.

asyncio and gevent are coroutines, at least in all the senses that goroutines are.

In fact, so are regular post-PEP342 generators.

Re: Why We switched from Python To Go

#30
post #2

Next up from The Author: 5 Reasons Why We Switched from MySQL to Postgres Why We Switched from Postgres to Oracle 11 Reasons For Switching From Oracle To KDB 7 Reasons Why We Switched from Go to Fortran-77 Grammar errors are provided for free by The Author.

Thought the same. Plus: "Surprises" that should be obvious for everyone working with the discussed technologies...

I guess we'll have: "This will surprise everyone, but Postgres can actually handle GIS data better than MySQL".

Post reply on HN