Live data from Hacker News

All the things I hate about Python

medium.com

31–40 of 87 posts

Re: All the things I hate about Python

#31
after 5-6 languages and coming back to Python I would say the worst things are

- large and inconsistent stdlib api,

- extremely wordy but somehow still vague documentation

- overwrought build/packaging system (although tooling has improved)

- endless runtime gotchya debugging in production

- almost all the baggage of OO boilerplate but none of the benefits of type-checking.

- half-baked functional paradigms

Re: All the things I hate about Python

#32
Totally agree with this person's assessment on types.

I took over a smallish half-completed web application written in python a couple of years ago. Nothing major - simple business-y analytics/data viewing app with some fancy charts and tables etc - perhaps a couple of thousand lines of code interfacing to backend database unique to our business. It had some tests, but nowhere near 100% coverage. I needed to finish it off and then get it into production.

Long-story short, trying to understand someone's half-completed python and make changes to this was a HUGE nightmare for precisely the reason the article outlines: python expects you to remember all the minutiae of all the code you are calling. If you cant remember, then you need to suck it up and pick your way through the code and mentally keep track of what is going on at every stack frame.

So instead of thinking about the actual problem you're trying to solve, python forces you keep track of all the little bullshit that you shouldn't need to care about. And even then, you cant be 100% sure you got it right until you exercise that code (either through 100% test coverage, or - shudder - at run-time at 3am on a Sunday when a user in Japan logs on).

So far from being productive and "easy to use", python for us was a nightmare of low-productivity and frustration in only a very small application being worked on by just 2 or 3 remote developers. I cant imagine the levels of pain and suffering for larger projects & teams!

The "solution" is apparently extensive & specially crafted comments that specifically explain the types used (that of course needs to be kept up to date) - I find this fairly odious (why not just use a typed language if you need to put the types in the comments?!)

I know now that Python is looking at type hints as part of the language (PEP 484 - https://www.python.org/dev/peps/pep-0484/) that should help a lot.

Still, its not all bad. As a result of the pain of this application (which incidentally was damn slow in production due to the processing we had to do on the data in the python backend before we sent it to the browser), we decided to learn golang and use that for future work instead and have not looked back.

Golang has the same feeling of fast-paced "throw things at the screen" productivity, but is obviously typed (so you know about errors before your users do) and orders of magnitude faster.

Re: All the things I hate about Python

#33

Totally agree with this person's assessment on types. I took over a smallish half-completed web application written in python a couple of years ago. Nothing major - simple business-y analytics/data viewing app with some fancy charts and tables etc - perhaps a couple of thousand lines of code interfacing to backend database unique to our business. It had some tests, but nowhere near 100% coverage. I needed to finish i…

Not looking at, has type hints as part of the language.

Re: All the things I hate about Python

#35
Oh yes, python packaging sucks. That may not be well understood. But the languages that handle distribution very well are just a few, that i know of (jvm based, .net based, go, possibly js with all the tools that exist) and there'll be some that i don't know. But for most languages, distribution of a software with dependencies is a great pain.

Re: All the things I hate about Python

#37

after 5-6 languages and coming back to Python I would say the worst things are - large and inconsistent stdlib api, - extremely wordy but somehow still vague documentation - overwrought build/packaging system (although tooling has improved) - endless runtime gotchya debugging in production - almost all the baggage of OO boilerplate but none of the benefits of type-checking. - half-baked functional paradigms

[deleted]

Re: All the things I hate about Python

#38
post #11

This starts off with a misunderstanding of what "strongly typed" means. Python is strongly, but dynamically typed. Static typing means you know the type of something at compile time. Dynamic typing means you don't. The upside to dynamic typing is that the compiler doesn't have to prove much about your program; the downside is that it can't really prove much of interest either. Strong vs weak typing is about how much…

Python objects are duck typed, and c/c++ structs are strongly typed. Duck typing is closer to weak typing than strong typing. Tagged unions are dangerous in C/C++, but python’s object type is strictly weaker than a union.

In fact, C and C++ are both strongly typed, but they are both memory unsafe.

However, C++ provides enough static typing to make it easy to write memory safe (but single threaded) programs.

Also, tools like valgrind get you 99% of the benefit of memory safety, which is good enough for debugging. C++ lets you override the allocator, and build in inexpensive (fast enough for production) checks for most use after frees, memory consumption profilers / leak detection/ etc.

I’d argue that python is memory unsafe in practice, since we get segfaults from third party dependencies in python about as often as we see them in c/c++.

Crucially, C and C++ provide enough tools to get static type safety on the error handling path.

Errors like ‘assert “” is not None’ and missing field exceptions in python error handling code are frequent, but unheard of in C/C++.

If you use std::string, adding a in integer does something well-defined (rtfm). Adding an int to a char widens the result to the int type (foiling attempts to use it like a char without a downcast, if you use -Wall -Werror). Adding an into to a char* does pointer arithmetic, which can be used safely, but there are better string / buffer types you can implement in an afternoon, so do that instead.

Re: All the things I hate about Python

#39
post #4

To me, the core points seem like table stakes knowledge that one should have before jumping into development with ANY language, not just Python. Every language is a tool that is good at some things and not good at others. Cue the standard if all you have is a hammer, every problem looks like a nail. A few core things: The GIL problem is frustrating. I generally just try to avoid writing threaded code and instead exec…

My issue in favor of Python is the clarity and brevity I cannot find in other programming languages. For example, doing a web service with Flask is a relaxed task with minimum code that after months continues to be clear and without a lot of context needed. NodeJS/express? My stomach cannot pass callbacks nor promises (I am aging, sure).

In terms of progress I love what .NET has achieved and found that libs like Nancy [1] are good to explore.

Disclaimer: I am not working as a professional programmer anymore so I look for fun and "move faster" tools.

[1] http://nancyfx.org

Re: All the things I hate about Python

#40
Hate those things all you'd like, but that won't stop you or others from using it and doing so regularly. None of these points are show stoppers for many scenarios. That's good enough. Python is the best second language for everything and first language at many things.
Post reply on HN