Why all this hate about Python?

On many forums, discussions between devs and several blogs, I saw a lots of articles in which Python is mentioned as a bad or ugly language; but why is it so?

I find Python awesome: building everything fast, easy to read and to learn the basis, etc.

But whenever I ask to my fellow developers, nobody gives me a constructive answer; so what is your opinion about it?

Happy coding !

Ok, here we go (puts on fire-resistant coveralls) ...

For reasons that no one understands, all of the sudden python acquired this
enormous library structure which allowed people to say "I'll make a thing
that does this, that or the other thing" and they found all the stuff that
they wanted, in particular they could make a robot move around.

  • Gerald Jay Sussman, co-author of the MIT SICP course, at an NYC LISP Meetup

Python is an extraordinarily successful language, especially for one created as a hobby project named after sketch-comedy with a design philosophy that is a nineteen line poem.

Python got the holy grail (pun intended) early on - a big set of reusable and well-maintained libraries that you can just grab off the shelf and save yourself thousands of lines of code reinventing the wheel. Its better than a great static type system, better than automated testing, better than object-oriented, functional, or any paradigm one can imagine. With a few great libraries that you can actually use, your massive complex project might just reduce to a 50 line script.

I don't claim to know why python is so enormously successful. I really like python, and I could speculate on some of the properties of modules as a basic unit of encapsulation, iteration and other basic protocols, and so on. But at the end of the day I don't fully understand why, and neither does Gerald Sussman.

This lack of understanding is frustrating to the idea of software engineering. I think that much of the field would like to believe that we can enumerate - at least in part - what properties a language should have in order to result in rapidly developed software which is reusable and maintainable by teams of human beings. Python is missing one of the big ideas here, which is a strong static type system. If that is so important, then how is python so successful? How are teams writing python not drowning in uncaught type errors? How are there so many good libraries available?

There are two major differences between software engineering and traditional engineering fields:

First, software engineering is generally not a regulated profession - at all. There are no standard proficiency tests, degree requirements, or even a truly agreed upon curriculum.

Second, there is no basic theory or set of equations to tell you if a given design will result in a software that is successful in the sense that it can be delivered on time and maintained with a reasonable level of effort by a team of humans. Electrical engineers can use Maxwell's Equations and derived formulas to state clearly and definitively if a given design will generally work. Civil engineers have Newtonian Mechanics. Aerospace Engineers can rely on various approximations of the Navier-Stokes Equation. I would argue that software engineering does not have, and may not ever have, some sort of equivalent set of laws to tell you how successful a project will really be. It's fundamentally a harder problem as it involves human behavior.

So python, with its arguably haphazard success, serves as a reminder of the inherent difficulty in determining a working and general theory of what properties are required to make a software development project a success.

TLDR - python lacks many language features considered by many to result in successful software projects, static typing being a major example. While this may make the language unsuitable for some teams of humans, a great many teams of humans have found success using the language and built a huge ecosystem of usable libraries. There is no commonly agreed upon theory of why this has happened. That's kinda frustrating.

Seems like programming languages are a lot like religions. And developers can become extremely religious. Whenever I read things like this, X is a bad language, Y is really ugly, I consider it to be a good thing. People only complain about the languages we use. If nobody complains about your language, nobody uses it.

As for the constructive answer, I don't know Python so I can't help you :D

It's like Stroustrup said: “There are only two kinds of languages: the ones people complain about and the ones nobody uses.”

I came upon this quote a few years ago, and this is my absolute favorite in the programming world. Perfection doesn’t exist. We developers make countless arbitrary choices in everything we do, therefore it’s absolutely impossible to please everyone.

Let’s just keep coding!!

Oh Stroustrup. I wrote him an email many years ago. I told Bjarne that a programming language which permits you to obfuscate absolutely anything is not a language. It's gibberish. Funny, I never got a reply :) I really was not trying to be rude. All I wanted to do was to point out that the purpose of language is to create mutually intelligible messages. C++ is a danger to that maxim. In twenty-five years of my involvement in software development, usually within a team, I have found nothing wastes more time and money than bucking convention.

True - the cure for that (like for the real thing) is learning about other languages, seeing your languages problems and realizing that there is no true language and that it's all a big hoax ;)

Python was the first language I learnt, and the first I could consider myself any kind of expert in. I love that it has clearly stated design goals, and that one of them is being readable. The dynamic typing definitely makes it faster to get stuff going, which I think can be crucial for new programmers -- getting that reward for your coding is so important for it to be enjoyable. Other languages can make it feel a lot harder to even get something simple working.

That said, the more I program in languages with static typing and powerful type systems (like Rust), the more appreciation I have for how many bugs can be completely eliminated by these languages. I hate that in Python there is always a possibility that everything will crash because a variable of the wrong type gets passed into a function, and there's no way to guarantee this won't happen. Good test coverage reduces the likelihood of this kind of bug, but it's frustrating to have to write tests for things that other languages simply do not allow -- it's a lot more work for me, and will never have the same guarantees a compiler can give me.

I think that people can be unkind when comparing programming languages, often simply to make themselves look smarter. Try not to let these people bother you :)

If you want to know more about different type systems, I recommend Destroy All Software's article here :) destroyallsoftware.com/compendium/... It does a nice balanced job of explaining and comparing different approaches, including Python's.

I hear what you're saying about the dynamic (or, weak) typing. But I've always believed that weakly typed languages are a bad choice for beginners -- for exactly the reasons you've been learning to appreciate stronger typing. Weak typing might lead to more instantly gratifying accomplishments in the beginning, but as the beginner's software grows into something more complex, already established bad type-ing habits lead to some of the more difficult to debug errors rooted in the subtleties of weak typing. As you've pointed out, strong typing removes that ambiguity, leading to clearer code. It might be more verbose at times, and also less tricky and impressive. But when it comes to the actual computing that happens down under, there's really no difference. And when someone else takes on the maintenance of that code, the one thing their going to want is straightforward, obvious code. Cool, trick, obfuscated solutions waste time and money.

Like I've been saying in this thread, Python is good for what it's good for. As for pedagogy, especially for those who wish to be industrial software developers, I don't think Python is it. I believe schools who start out with Python do so because it's the in thing right now.

I think it's really interesting to think about what is a good programming language for people to start with. It's something I have conflicted feelings about.

I think you might be right that Python is not a good first-language choice for people who want to be professional software developers. But I also think that software should be open to more people than that.

I think it's difficult to balance the advantages of learning things "right" the first time, and the concern that people might not learn anything at all if the content feels inaccessible. I worry about people picking up bad habits/not ever learning what is going on under the hood of their Python program, but I worry even more about people giving up on learning to program altogether.

Perhaps the answer is better teaching approaches & materials for languages that are considered more difficult to learn. Perhaps our entire approach for teaching programming needs updated so that the chosen language is less of a big deal. I don't know.

I think you may be right that some schools start out with Python because it's trendy, but perhaps there's a reason for that trendiness. It's definitely more accessible than, say, Haskell.

Great post!

Python 3.5+ supports type hints, but that's only for your linter (and other static code analyzers) versus not having it compile.

It's a step! =)

How often does wrong type bite you though? Many strongly typed languages allow passing null as any type anyway and I find that a far bigger problem than passing foo when a bar is required.

Programming language hate is often pretty shallow. Python lacks where other languages thrive (like strong typing/compiler) but makes up for it by being simpler to use and read in a lot of cases. It's also widely adopted in many important fields which is a big deal regardless of language bike-shedding.

Some languages also receive a lot of hate from their own community and a lot of that is just venting. People keep chugging along with these tools because they're ultimately useful.

If you find Python awesome, keep up whatever you're doing with it and don't pay much attention to the critics. If you're still curious about the criticisms, try picking up something really different and see if you like those too for different reasons.

I learned BASIC, then Fortran, then Pascal, then C. Then I took my first programming language classes and also learned the rudiments of Lisp, ML and Prolog. My first job was mostly coding in C, and Perl. Then I learned Java. Heaven had come down to Earth. Strongly typed, elegantly laid out, (fiercely) object oriented. It was software development in a world built by George Orwell! Ah the peace and serenity of a highly structured life with heavy-handed enforcement ... but it was sort of compiled, sort of not. Development was slow on those old Celeron processors. I put up with it for a long time. And then I saw PHP... sigh. Fast, loose, messy. But development was rapid. PHP 5 came and OO took stronger hold and Symfony came out. As long as I was disciplined I could pretend I was coding in Java and deploy to test systems faster than you can type "git push" (or was that "svn commit"?).

Somewhere in that timeline Python came out and every time I looked at it, I wanted to read the philosophy behind it because it looked like such a step backward. It reminded me of Fortran in a number of ways. And when I read the original Python author's ideas of how and why, I was even more put off. So many changes with no good reason except for, essentially, wanting to not follow the course of history. I like following convention because, when shit just works you save money, time and headaches. It's when it doesn't work, or something is proven to work better, you spend the time and money making the jump.

So why do I use Python? I hate coding in it, but there's no denying that compared to any other scripting language (I've encountered) it just works. It connects to devices and networks and databases with the least hassle. Easier than Java and PHP (and of course Perl) in this regard. It's ugly. It's not easy to absorb another's Python work. But It. Just. Works. That's time and money. That means more time for everything else I was supposed to have gotten done yesterday.

You shouldn't pay attention to non-constructive criticism. The sooner you learn this the better off you will be. People also hate PHP but it has enabled more commerce than probably any other language.

We are afraid of what we do not understand, we hate the things we are afraid of. Also some devs really hate it :))

It is hard to find good answers to your Q, most of the hate is for things that Python isn't and shouldn't and don't want to be: a static typed compiled language.

I for one hate it because it took all the libs and love for all the science related stuff. To play with ML algorithms I had to learn a bit of Python.

I also hate it because of the "indent" design, to delimit a set of instructions using something invisible is simply wrong, it didn't bother me much but being so popular it affected many things along the way (IDE, tabs vs spaces war) even new language design specs, snippet from Go's

Some observers objected to Go's C-like block structure with braces, preferring the use of spaces for indentation, in the style of Python or Haskell. However, we have had extensive experience tracking down build and test failures caused by cross-language builds where a Python snippet embedded in another language, for instance through a SWIG invocation, is subtly and invisibly broken by a change in the indentation of the surrounding code. Our position is therefore that, although spaces for indentation is nice for small programs, it doesn't scale well, and the bigger and more heterogeneous the code base, the more trouble it can cause. It is better to forgo convenience for safety and dependability, so Go has brace-bounded blocks.

Embedded snippets seems like a pretty limited use case.

Python's simple syntax make it the best scripting language.

SCRIPTING.

Automation, and small things that should just make life more pleasant. Any attempt of using it to something bigger than that, was met with NO redeeming qualities once or ever.

Problems with dependencies; the lack of type hinting (since the bastards broke backwards compatibllity BEFORE they added type-hinting, the single most important feature in Python 3) makes Python an unreliable, bug-prone, confusing piece of mess (again, solved in Python 3 the issue with the type-hinting, but since we have legacy Python 2, people refuse to upgrade).

After EVERY Python project we have ever done, our primary lesson is: do in Java next time.

Python 3 on the other hand, has the potential of actually being scaleable.
I mean, the mess that is pip is still there, but type hinting is, again, the single most important feature of Python if you ask me.

My negative view of the language comes from terrible experience of people using it as the an actual language, for actual projects. It doesn't feel like it was ever intented to - but people know Python and are lazy to learn any statically typed language, which annoyes me to no end.

But if used correctly - Python (Python 3 to be more specific) is an important and useful tool at you disposal.

Bad programs can be written in any language; Python's flexibility means you need to be more disciplined than in a statically typed language like Java. I've worked on Java teams before that would be nightmares if they were using Python.

That said, if your team's testing, craft, and review discipline are solid, Python is just fine for projects large and small. Similarly, overall design and architecture outweigh a language's straight-line efficiency for most classes of projects.

I've been using Python as an actual language on actual projects for years without any nightmares.

"the mess that is pip" - I'd be interested in more details there. Java is no stranger to dependency hell either, particularly in the world of EE.

I do agree that the migration to Python 3 was completely mishandled. I think things are finally getting there (Django 2 refusing to run on 2.x is a huge step) but wow, what a way to drag things out.

You are correct. A lot of bad software is written in any language.

And yes - with great discipline, great software can be written with Python.
But why even try when there's no real benefit? The language is still very slow when compared to any compiled statically typed language.

I called pip a mess but I admit it was uncalled for. Pip is fine.
What I generally dislike is the way Python handles libraries in general - with them being global and all. It creates mess, with one project requiring 1 version of a library and another project another - what do you do?
The libraries are global, and it affects ALL of your projects at once.
Another problem is that should I create a Python project and want to release it on production, I need to NOT ONLY install Python, but pip with every dependency as well, at a global scope.
With Java - I can compile the my project to include the libraries I use. I need only the JRE on production, and I'm golden :D

For the very least - I despise Python on a project level. A lot of things can go horribly wrong, and a great level of discipline is required to make the most out of it.
I work at place where people use Python only because they needed to get things done QUICK.
They didn't have discipline.
And I'm the one that suffers all of their horrible, horrible choices.
So yeah, more often than not I'm more scarred fron the misuse of Python than anything else.

Java + Gradle (or any of the major build tools) = 😍😍😍😍😍

"But why even try when there's no real benefit? The language is still very slow when compared to any compiled statically typed language."

Because straight-line execution performance is, for most applications, far less important than architecture and team productivity. For a web site, caching, CDNs, and concurrent processing will take you much further than your language choice will (within reason: don't write your web site using DOS batch, please). Python is Fast Enough. And when it isn't, it's very good at calling your favorite compiled code for performance sensitive pieces.

Additionally, it can be far more productive than a language like straight Java.

"What I generally dislike is the way Python handles libraries in general - with them being global and all. It creates mess, with one project requiring 1 version of a library and another project another - what do you do?
The libraries are global, and it affects ALL of your projects at once."

You use virtualenv, as it is the tool that was created specifically to address project-specific libraries. Global libraries are a solved problem.

"Another problem is that should I create a Python project and want to release it on production, I need to NOT ONLY install Python, but pip with every dependency as well, at a global scope.
With Java - I can compile the my project to include the libraries I use. I need only the JRE on production, and I'm golden :D"

As above, no, you do not need to install these at global scope. In fact, you can run different versions of Python with different projects in the same scope as well. J2EE can have more of a problem with global system libraries (remember log4j vs. commons logging in Tomcat?) than does Python.

"For the very least - I despise Python on a project level. A lot of things can go horribly wrong, and a great level of discipline is required to make the most out of it."

Great discipline is required with every language to make the most out of it. Python is no different here.

"I work at place where people use Python only because they needed to get things done QUICK."

Yes, that is a very real benefit of Python.

"They didn't have discipline.
And I'm the one that suffers all of their horrible, horrible choices.
So yeah, more often than not I'm more scarred fron the misuse of Python than anything else."

This again is not a Python problem, it's a management and team problem.

From my perspective, I'd rather code in a language such as Python instead of a language with an unsound type system. I've got some side projects in Rust and Scala but I don't know if I will ever find a job in these languages.

Examples for languages with an unsound type system?

What's unsound about them?

My only complaint about Java is the nullable reference types, really, and I have no complaints at all with typescript (but to be fair I didn't use it all that much). Why do you dislike them?

Wow, the more I read this site the more I want to take on the Java evangelist role. Haven't come across a single advocate, only hate.

I like Java! I really do. I certainly like it more (god, so much more) than Python

I'm not "hating" on the language, I've just stated my preference of python over it because of its type system.

I remember when I was learning Java that I had to use upcasting (some of the nio apis, etc). Whats the point of a type system if you're upcasting?

@aghost7 you are absolutely right, I have just noticed a general lack of enthusiasm and happened to mention in reply to your comment, which was not hateful. I apologize.

For upcasting do you mean implicit upcasting? We typically do that in order to "program to an interface" which helps facilitate a clear separation between the implementation of a module and how it interacts with other modules (ie loose coupling).

Sorry, I think I meant downcasting. I've had to use this on several occasions when I was writing Java. I think the worst I've encountered in the standard library is casting object to something else.

Hmm, yeah usually you want to avoid downcasting at all costs (most Java devs consider it a code smell). Java is certainly far from perfect but Java 8 and 9 make it muuuuch nicer to work with (especially if you like Scala).

If you're referring to streams I'm afraid that there's still some catching up to do (based on the last time I looked at it) when compared to Rust or Scala.

Streams, Optionals, Futures, Method References, and Lambdas everywhere are all great additions but it definitely lags behind Scala in some ways (never tried Rust).

There are mostly 2 things I don't like about python.

  • It's incompatible with itself. (2 vs 3)
  • It's syntax is confusing and goes against assumptions that other programming languages make, making it super difficult to learn coming or going to anything other than Python.

The second point is my main gripe with the language. So much of it seems to be different just because it can. There's a common phrase discussing learning new languages in that learning a new one becomes easier the more you know. And this is true for natural languages, as well as programming languages. Except python.

Consider the following code from the front page of python.org. I'm going to go over it line by line.

def fib(n):
    a, b = 0, 1
    while a < n:
        print(a, end=' ')
        a, b = b, a+b
    print()
fib(1000)
  • def fib(n): This line is kinda okay actually and the most "normal". By looking at the rest of the snippet we can see that def is used to define a function, it's going to be called fib, and it takes a parameter n. (I use JavaScript a lot so I'm not offended by the loose type system, although I do enjoy languages with one.) The : here I'm also a fan of because one thing I do appreciate about python is the tab structure for code blocks. It forces a style guide at the compiler level helping the portability of scripts in a huge way.
  • a, b = 0, 1 I thing this assigns a to 0 and b to 1 but that's honestly a guess. I guess python supports SIMD but I'd much rather these assignments on different lines as the current syntax brings in a lot of unnecessary confusion.
  • while a < n: the a < n should be inside parentheses but that's more of a pet peeve I guess, so you do you, python
  • print(a, end=' ') is an alias for print(a, end='\n') but I did not know that until I had to look it up in the documentation to help a friend.
  • a, b = b, a+b I don't even know where to begin on how much this doesn't make any sense.
  • print() According to python.org, the output of this little script is 0 1 1 2 3 5 8 13 21 34 55 89 144 233 377 610 987 so this line seems useless. fib(1000) We called a function. Yay!

All this is only the tip of the iceberg when it comes to how much I don't like python's syntax. But that is the clarification I want to make. I don't hate python or anyone who uses it. If it gets your job done and you enjoyed making it, then I'll love python right with you. But, me personally, I never want to write python.

One more note I want to add before I close because it's probably the thing I hate most about the syntax is this:

signal = True
if (signal):
    response = "Hello"
print(response)

In any other language this does not work variables are supposed to have a concept of scope, which python seems to have forgotten about because it just lets you define variables out of thin air.

If I were going to complain about syntax, I'd start with meaningful white space, which I'm generally opposed to.

In terms of implementation, one could point to the consequences of the global interpreter lock, with regards to threads.
docs.python.org/3/c-api/init.html#...

Version compatibility madness.
Shall I write my code for 2.x or 3.x?

I love Python. What drives me mad is that I can't easily deploy my apps because of version issues.
There are many companies that only run the Python that comes with their OS, and so sometimes I am stuck with 2.7 or even 2.6 compatibility.
I wish Python 3 would become the only version in the field. It's been a while already.

I haven't heard the hate you mention. I love the language, though of course there are things that annoy me sometimes, or things that I would change. In my mind it strikes the right balance between beauty and pragmatism, and between performance and usability.

I think its ability to be used as a JavaScript replacement, especially in the browser in the browser, will grow with things like Brython, but I'm currently focusing my learning on JavaScript stuff, because I don't think it's there yet (at least not among the employers I'm likely to be applying for soon).

Python as a language is mostly fine. I've used it for plenty of tasks. It's especially great for simple projects where you just need to get up and running quickly.

But I find it cumbersome for larger projects. As insane as the JavaScript ecosystem is, I really love the ease of using npm or yarn and a package.json to manage and install dependencies. Virtualenvs and requirements.txt are clunky and confusing by comparison. Also, importing modules from different directories is much more troublesome in Python than in JavaScript, where you can just give the file path.

Python has strengths, but it's also got weaknesses. For some things, it's my goto. For others, I really don't want to touch it.

ego's don't like it when something hard is made accessible and easier for a more inclusive community of people. It undermines all their hard work and they believe makes them less valuable.

While I agree with the sentiment that Python can get more hate than it deserves, this is a pretty reductive summary of a large number of legitimate criticisms of Python as a language.

Python, being a tool, makes different tradeoffs from other available tools. The "ease" with which you can write Python comes with certain tradeoffs which are serious language features, not arbitrary protectionist gatekeepers for an elitist group of developers.

The main reason why people don't like Python is because they didn't give it an honest try. The main issue people generally have with it is completely superficial and goes away once you spend time in it for a while.

I bucked that trend. I gave Python a nice try. I still don't like it, but I use it regularly for what it's well suited for. The problem is that everyone wanta to scream from the top of the highest mountain that their personal choice is the golden egg that everyone's been chasing. A fool's myopia.

I would counter your premise by saying that the main reason people like something is generally because it was their first love, or close to it. Gosh, have I been swayed by @agazaboklicka 's "comfort zone" post? :)

While I like Python, it has some major flaws which prohibit me from using it

  • it's slow (compared to Java or Kotlin it's DOG SLOW)
  • it's dynamically typed

The only bad part I have read about python is that it doesn't do multi-core threading or something like that which is handy for processing a crap load of data. Other than that, beats me, I like python, who cares what other people think.

Python is great. Much more elegant than two of the bigger languages out their, that will remain nameless.

Maybe the people you ask miss {curly braces}?