Live data from Hacker News

Python Is Easy. Go Is Simple. Simple != Easy

preslav.me

171–180 of 313 posts

Re: Python Is Easy. Go Is Simple. Simple != Easy

#171

Python is valuable due to the ecosystem of libraries it offers. The language itself is extremely poor. I think this is not something most Python users are aware of since if you are doing ML, data-science or simple scripting there is little reason to step outside of the ecosystem. - Weird scoping rules - Very limited list-comprehensions - Ability to monkey patch things is a liability - Mutability by default - Lack of…

I really cannot agree with most of this.

Weird scoping rules? This will rarely if-ever impact you in the real world.

The list comprehensions in Python are incredible, in fact people over-use them all the time in really gnarly ways. Like [x for x in [y for y in [z... and the consistency with the same system supporting all datastructures (sets, dictionaries, tuples, etc) is very intuitive.

Monkey patching is a liability? This is like saying a car is a liability because I am free to drive it off a cliff. You're technically correct, but you are the one in the drivers seat. The ecosystem does not do or encourage this behavior, with the exception of things like gevent where it is required.

Mutability by default is common in virtually every language. You can't say it is good or bad, it's just a fact of life. There is a cost to immutable datastructures unless the language is designed from the get-go to utilize them efficiently.

Lack of support for functional programming? Functions are first class in Python. You can pass them around all over the place, as args, put them in datastructures, etc. When you combine this with comprehensions and generators it is very powerful and lets you do lazy evaluation of complex transformations. There are lots of built-in tools in the stdlib to do functional programming. This is just straight up false.

Deployment story remains extremely painful - again false, I do not know why people say stuff like this. Create a virtualenv (built into the standard library), and pip install your requirements. If you are using conda and all the other noise you are going to have problems.

Slow execution of pure python code - this is the ONLY area where you are perhaps correct... but compared to what? For a lot of use cases, the speed of Python is not a problem. When it becomes a problem, you off-load that responsibility to something else. There is also something to be said for writing software quickly, which is a perk of Python for sure.

Re: Python Is Easy. Go Is Simple. Simple != Easy

#172

Earlier quoted context omitted.

I think you typed "python" wrong :) Duck typing is a python thing. And the dependency management is a nightmare, constantly breaking. To the article's point - you _must_ run it in a container and defer to the OS to have anything resembling a sane development story.

Ok that's totally fair. What's the Go name for it? In my mind Go interfaces are duck typed.

Probably structural typing?

Re: Python Is Easy. Go Is Simple. Simple != Easy

#173

The sad thing is that many people make language decisions on the beginner topics like syntax , literals, hello world or trivial samples. Sure a 20 line python app will be 40 lines in Golang, but that doesn’t mean 10k lines of python are 20k lines in golang. And there are way more serious considerations than LOC. Golang concurrency is amazing. You can reproduce an entire multi-core application stack with concurrent IO…

My experience translating a codebase from Python to Golang (chat application), is that 20k of Python really does translate to around 40k of Golang to get the same functionality.

And it’s not just due to language but also expressiveness of the library ecosystem.

Re: Python Is Easy. Go Is Simple. Simple != Easy

#174
post #37

Earlier quoted context omitted.

I used Go for many years. My issue is that it's _almost_ a great language, but in its current version it's just a collection of foot guns that makes it difficult to get shit done. Go doesn't have some of the most library functions, so large codebases shared between teams end up with a dozen different implementations of functions like "minimum" or "filter". Good luck debugging a bug in one of the implementations. The…

I could not agree more with this. Go is so frustrating to me because there is so much I like but these things you listed make it miserable for me to use. A basic option and result type could fix a lot of the issues around errors and null pointers. I know languages like Scala, Haskell, and Rust have type systems that are often considered too complex but Go doesn't need all that to add these two.

"Defaults are useful" was IMHO the biggest mistake Go made. I understand that it made the language a lot simpler but this was a simplification that ended up moving the complexity to the user, rather than just removing it.

I have seen so many bugs caused by default values, production outages. Plus the code is harder to understand because you need to consider the default value case, and make sure that it is only left at the default when intended, not by accident. (And the linter probably can't warn you because it isn't wrong to have the default value live in one path through the code).

One of my favourite things in more strongly typed languages is just adding a field to a struct then having the compiler point out everywhere that I need to make changes. The strictness both prevents bugs and saves time. Plus the code doesn't need to worry about invalid structures, you can often write code such that they literally can't exist.

Re: Python Is Easy. Go Is Simple. Simple != Easy

#175

Earlier quoted context omitted.

> a dozen different implementations of functions like "minimum" or "filter" this is too real and my number 1 gripe with go

And it's funny because go has a whole http server in the standard lib, but not minimum?

It couldn't have a minimum before generics. The function was not expressible in the general case. So they either would have had to add `minByte`, `minInt`, `minStr`, ... or make it a builtin generic. And every builtin is an admission that the language was not powerful enough, so those are kept to a minimum.

Re: Python Is Easy. Go Is Simple. Simple != Easy

#176

Earlier quoted context omitted.

> a dozen different implementations of functions like "minimum" or "filter" this is too real and my number 1 gripe with go

And it's funny because go has a whole http server in the standard lib, but not minimum?

There is 'min': https://go.dev/ref/spec#Min_and_max

Re: Python Is Easy. Go Is Simple. Simple != Easy

#177
post #32

Earlier quoted context omitted.

The way I describe it is that Golang is optimized for reading, other languages are often optimized for writing. If you have to deal with someone else’s codebase, then Golang is a godsend. I also like that you pointed out that every Golang codebase looks the same. I think part of that is that Golang’s formatter can’t be customized. I pushed for that to happen in Rust but lost the battle.

I read a lot of code. Reading Go is painful because I have to parse whatever open-coded version of standard algorithms or error handling the developer chose to use that day.

This was exactly my experience when I was working in Go. Each line was easy to understand, but reading actual code was painful because I needed to read so much to figure out what was actually being done. I was basically spending 90% of the time mentally simplifying the code into abstractions so that I could understand the business logic. Then once I understood the business logic I had to zoom back in to check that their inlined reimplementation of various basic data manipulation routines were correct.

Re: Python Is Easy. Go Is Simple. Simple != Easy

#178

Earlier quoted context omitted.

IMO, Go is a mediocre language with great tooling and a great company behind it, and it turns out ultimately if you don't have the latter, the former is irrelevant.

Most developers are mediocre, so having a language that can match the skill level of the average dev is a win for many situations, no?

[deleted]

Re: Python Is Easy. Go Is Simple. Simple != Easy

#179

The sad thing is that many people make language decisions on the beginner topics like syntax , literals, hello world or trivial samples. Sure a 20 line python app will be 40 lines in Golang, but that doesn’t mean 10k lines of python are 20k lines in golang. And there are way more serious considerations than LOC. Golang concurrency is amazing. You can reproduce an entire multi-core application stack with concurrent IO…

Unfortunately, once you go further I personally still find Java (and Rust) "executors" far more easy to use than Golang's channel synchronization.

Re: Python Is Easy. Go Is Simple. Simple != Easy

#180

Earlier quoted context omitted.

This roughly lines up with my feelings. Go is a solid improvement over many languages that we inherited from the 70s, 80s and 90s. But it also retains a certain "we don't need a robust type system; weak-ish static typing is good enough" ethos that made sense in back then, when compilers were hard enough to write that it was easier to justify making the programmer handle more things manually for the sake of simplifyin…

I think the key question is how robust a type system can be while keeping compilation extremely fast. Slow compilation absolutely destroys developer productivity.

Yep this is one of the reasons lots of my friends switched to Go: short compilation time (like good old Pascal days).

Rust & Haskell is a big no :p

Post reply on HN