DEV Community

Why all this hate about Python?

Pierre Bouillon on November 12, 2017

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 wh...
Collapse
 
r0f1 profile image
Florian Rohrer

comic

Collapse
 
oktayacikalin profile image
Oktay Acikalin

Now try that in PHP 😂

Collapse
 
damcosset profile image
Damien Cosset

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

Collapse
 
diogenes1oliveira profile image
Diógenes Oliveira

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

Collapse
 
damcosset profile image
Damien Cosset

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!!

Thread Thread
 
jasongabler profile image
Jason Gabler

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.

Collapse
 
carstenk_dev profile image
Carsten

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 ;)

Collapse
 
appeltel profile image
Eric Appelt

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.

Collapse
 
ronbarakbackal profile image
RonBarakBackal

Really liked your comment ! I actually have one thing that deeply troubles me with python, from my stubborn must-do-anything(like must prove this theorem kind-of-stuff...) : well, trying to do something really scientific in python without Numpy is slow, and it just seems so nice to actually WRITE those things and see they work then just say: Hi, give me that! But not everyone is into this all I-want-to-prove that the fundamental theorem of calculus actually is real thing :-) . Interested how do you think I'll be able to reconcile with python? maybe try to write python like Rust?(even possible)

Collapse
 
jamesbecker profile image
James Becker

Teams of humans, as opposed to... teams of ducks?

Collapse
 
lochsh profile image
Hannah McLaughlin

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.

Collapse
 
jasongabler profile image
Jason Gabler

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.

Collapse
 
lochsh profile image
Hannah McLaughlin

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.

Collapse
 
ronbarakbackal profile image
RonBarakBackal

Hi Jason! I think I agree with you that Python is not a good language to start with. But what is your suggestion for a starting language?
Actually I've seen that Oxford starts with Haskell, which I think is pretty unique. I can tell you I mostly see either Python or Java for starting choice! Usually after covering Python and Java there is gonna be some short C/C++ just to ensure everyone is on the same page.
I tried experimenting with Julia(incredibly easy to math your way to a result), Go and Rust and there was something satisfying about those(I'll say how easy it's gonna be Julia-->Go-->Rust or Julia-->Rust-->Go)

Collapse
 
kenseehart profile image
kenseehart

Python is good for what it's good for. For the rest, I code an extension in the appropriate language for the task and call it from python :)

Collapse
 
alysivji profile image
Aly Sivji

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! =)

Collapse
 
kenseehart profile image
kenseehart

And unit tests. Unit tests contribute much more to reliability than type checking.

Collapse
 
hasnatbabur profile image
Hasnat Babur

Atleast treating white space (indent) as a language structure always seems to me odd.

Collapse
 
kenseehart profile image
kenseehart

The combination of braces to implement structure while using indentation to visually convey structure seems odd to me. Seems like a violation of the DRY principle.

Python removes that redundancy by using indentation for both, that way visual structure is always consistent with actual structure.

Whereas many other languages are redundant in that respect, which does not respect the DRY principle.

Wait, did I already say that?

Collapse
 
antero_nu profile image
Antero Karki

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.

Collapse
 
ben profile image
Ben Halpern

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.

Collapse
 
shacham6 profile image
Shacham6

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.

Collapse
 
aghost7 profile image
Jonathan Boudreau

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.

Collapse
 
shacham6 profile image
Shacham6

Examples for languages with an unsound type system?

Thread Thread
 
aghost7 profile image
Jonathan Boudreau

Java and Typescript.

Thread Thread
 
shacham6 profile image
Shacham6

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?

Thread Thread
 
evanoman profile image
Evan Oman

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.

Thread Thread
 
shacham6 profile image
Shacham6

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

Thread Thread
 
aghost7 profile image
Jonathan Boudreau

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

Thread Thread
 
aghost7 profile image
Jonathan Boudreau

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?

Thread Thread
 
evanoman profile image
Evan Oman • Edited

@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).

Thread Thread
 
aghost7 profile image
Jonathan Boudreau • Edited

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.

Thread Thread
 
evanoman profile image
Evan Oman

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).

Thread Thread
 
aghost7 profile image
Jonathan Boudreau

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.

Thread Thread
 
evanoman profile image
Evan Oman

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

Collapse
 
scottanderson42 profile image
scottanderson42

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.

Collapse
 
shacham6 profile image
Shacham6

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.

Thread Thread
 
evanoman profile image
Evan Oman

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

Thread Thread
 
scottanderson42 profile image
scottanderson42 • Edited

"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.

Thread Thread
 
krudflinger profile image
Clay Kuppinger

Pyenv + pipx + pipenv for all projects.

Collapse
 
jasongabler profile image
Jason Gabler • Edited

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.

Collapse
 
nektro profile image
Meghan (she/her)

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.

Collapse
 
heegaiximephoomeeghahyaiseekh profile image
Jeremy Phelps

I see this is a very old post, but I got here from Google and I have a few criticisms of Python that aren't already here.

I come from a Common Lisp background, and I've spent the past year programming in Ruby. This means I will not be complaining about Python's lack of static typing like most other respondents.

Recently I've been pushed into Python development because the rest of my team adopted it because of a single library that is marginally better than what we had in Ruby.

I find Python to be absolutely awful. First of all, it is NOT easy to read. Programs that would be simple in Ruby (and even simpler in Lisp) turn into mangled nests of for loops in the blink of an eye, because in Python absolutely EVERYTHING has to be written out by hand as for loops. Reading Python code is hard work.

Python has list comprehensions, like Haskell, but I've found that unless the expressions in the list comprehension are completely trivial, using them leads to even less-readable code than if you just wrote a for-loop that does a bunch of appends to a list (or lists) you initialize before entering the loop.

In Ruby and Lisp, you can do a lot by combining functions like "map", "reduce", and "select" (or its Lisp equivalent, "remove-if-not"), and the code stays readable, even if the lambdas/blocks being passed to each of them have several lines of code each.

Python has equivalents to map, reduce, and select, but the language only provides these crippled one-line lambdas (also, no closures), so you end up writing hard-to-read nests of for loops instead. Or worse, somebody throws in a generator! Or you can split the code up into 50 separate functions, but that still doesn't give you the readability you would have had for free in Ruby or Lisp.

So far, I haven't gotten deep enough into Python to have to think about what I'd do in a situation where my Ruby/Lisp solution would involve closures stored in data structures. But I have seen what I end up doing to compensate for the lack of symbols: I create empty classes just so I can use the name as a value.

Python is supposedly a "batteries included" language, but every time I Google for a Python equivalent to a Ruby method that I use all the time, the Stack Overflow answer is always "Just write out the implementation inline, bro!" That implementation always includes a for loop or an even less readable list comprehension.

Example: stackoverflow.com/questions/952914...

I haven't written this many for-loops since my BASIC days.

Collapse
 
waynebhayes profile image
Professor Wayne B. Hayes, UC Irvine

I don't know a line of Python. But I have been using undergraduate students---hundreds of undergraduates--to write research analysis code for me since 2013. Most of them are pretty darn good---I have high standards for entry into my research class.

Most of them have learned Python because that's what our university teaches as a first programming language.

So, you ask, how can I hate Python if I don't know how to write a single line of it?

Because pretty much every python program ever written by any of my students either doesn't work on another machine in the same cluster that's supposed to be configured identically, or stops working on the VERY SAME machine within a few months when some minor version number changes. Really, people. Does it really matter whether I'm using Python 3.6.4 or 3.6.5? REALLY? The third digit in the version number changes, and the code stops working?

I've been told by the local experts, "oh, it's easy to write portable code in Python". They must be using some alien definition of "easy" that's not found in the dictionary, because this is a recurring problem. Every quarter, every time I try to re-run some code that was written more than a few months ago, it fails. Traceback errors, missing library errors...

This is completely unacceptable. I have written code in 1991 that still runs. (In C. And Bourne Shell. And awk, if you must know.) Now I'm not trying to say that C or Bourne Shell or awk or f77 are better....but I'm saying that if students in their 3rd or 4th year of a Computer Science program at a decent university still can't figure out how to write code that lasts longer than a month... there is something seriously wrong.

My only saving grace is that I continue to recruit new undergrads every year, and they are able to "fix" the code.... that quarter. But pretty much guaranteed it'll die again.

This is why I hate Python. In fact, it is rare that I speak of the language without the F-word---usually in ALL CAPS---as a prefix. All my students know I hate Python, but I continue to let them use it because if I want them to do work with me, I have no choice.

Is it easy to learn? Probably. Easy to master? Clearly not. Easy to maintain? HELL NO. (Less politely... give me a f*cking break, no friggin' way.)

That's my 5 years of experience.

End of rant.

Collapse
 
sisterniccy profile image
T.E.

I do not like python for several reasons (even though I have to use it sometimes because certain unnamed IoT people only supply python libs that work). For me, python is like visual basic (or basic) a pigeon language that is missing everything from proper grammar to syntax. Currently, my favorite language is C#, especially after xamarin and mono made it portable. But I'd take C/C++ any time over python if at all possible.

  • The indentation: The indentation in python is plainly terrible. It makes the whole code unreadable. Don't get me wrong, I like indentation, but there has to be something around it to delimit a block, like {} that everybody else uses. Makes it more readable.

  • command delimiter: There really should be something to delimit a command on the end of a line. I so love the C style ';'

  • The typing: This is like speaking without articles... do I have to say more? (this is actually one gripe I have with C# since they introduced a var type)

  • And finally: Interoperability. While python supposedly works well with C/C++, it is a heavenly PITA to implement an interface to it. Calls that should work, like importing a module, crash the program for no apparent reason and so on.

Collapse
 
datacharmer profile image
Giuseppe Maxia

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.

Collapse
 
edh_developer profile image
edh_developer

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#...

Collapse
 
adamloving profile image
Adam Loving • Edited

For me, clarity over cleverness is the primary feature of a programming language. I favor object oriented languages because OO matches how I think about the world (and with Python OO is a crude afterthought).

More reasons I find python confusing and inelegant:

  1. The syntax for lambdas in python is very clunky. Only a comma indicates where the block ends, and it has to fit on one line.

  2. A class name is sometimes required as a function parameter in order to call a base class.

  3. Python users often abbreviate unnecessarily, making it hard to know exactly what modules you’re including

  4. There are some magic built in global functions, like len() which should be member functions of the relevant classes.

  5. Standard libraries are also inconsistent in their naming conventions, like unittest which uses setUp instead of set_up

  6. Decorators like @staticmethod are used to retrofit common language features.

  7. A python dictionary (a very common data structure) has odd initialization semantics.

Here are code examples of the reasons why I hate python.

Collapse
 
aghost7 profile image
Jonathan Boudreau

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.

Collapse
 
jasongabler profile image
Jason Gabler • Edited

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? :)

Collapse
 
tvanantwerp profile image
Tom VanAntwerp

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.

Collapse
 
cathodion profile image
Dustin King • Edited

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).

Collapse
 
tcratius profile image
Me, myself, and Irenne

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.

Collapse
 
bgadrian profile image
Adrian B.G.

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.

Collapse
 
scottanderson42 profile image
scottanderson42

Embedded snippets seems like a pretty limited use case.

Collapse
 
brianminister profile image
Brian Webb

I like Python for prototypes and small batch.

I would like it more, but too many coders seem to assume that python means that you have permission to write bad code.

So my grief isn't against python, but against bad engineering practices.

Collapse
 
leonetienne profile image
Leonetienne • Edited

Easy to read?!
Did you just say python is easy to read?!

Are you joking?!

Python is the most unreadable language i have encountered!
(i mainly program in c++ in VS)
If we're not counting "Brainfuck" that is.

Python is just confusing.
Variables have no defined types, you can write code outside functions, it doesn't use curly brackets, so it relies solely on insets. Also the default ide is more than shit. No line numbers, not even auto correction suggestions or anything like intellisense.

I once had to program in python because of a certain Library Wrapper. After two hours of missing my dearest c++, i just resorted to call my script.py via the system() function in c++ storing the return value in a textfile...

Over all 1/10.

And this one point is just because i love how easily you can import libraries via pip3

Collapse
 
aoeu256 profile image
Alexis Rodriguez

The types of variables are constrained by the operations you use in the function definition, and of course its name. For example,
def myadd(a, b):
----return a + b
Rather than thinking about a and b as numbers [isinstance(a, Number)], think of them as variables that have the +(add) operator i.e: ['add' in a.class or hasattr(a, 'add')]. Another thing you can do is look at its callers, or setting a break point inside the function.

Collapse
 
davips profile image
davips

Refactoring is a nightmare. Add an extra argument to a function and expect to get errors in the distant future when an infrequent condition is met during execution and some remote part of the code calling the function with the old argument list will break.

Collapse
 
aoeu256 profile image
Alexis Rodriguez • Edited

If you add the extra argument as an optional it will work nice much of the time.

def func1(a, b, extra = 5):
----func2(5, a+b, extra=extra)

Doctests are good documentation and easy to write (just copy and paste your console session), but its true its hard to exercise EVERY code path. You can also automatically create some doctests by doing using a createTest decorator i.e: f = createTest(f) for all f in user defined modules, but no guarantees.

As long as your not doing some complex polymorphism, pylinters can catch many although not all errors. I believe some of them use "Type Inference".

I wonder how do Smalltalk and Lisp solve this problem? Did they go the Erlang route and reload code on errors?

Collapse
 
kenseehart profile image
kenseehart

Python is certainly my favorite language for pretty much every project, large or small. I've been using it very effectively as my primary language for over 20 years.

However, I find that I agree with much of the criticisms of python.

The two main weaknesses of python are:

  1. It's very easy to learn
  2. It's very flexible and does not impose it's will on you

This is a horrible combination.

The problem is that people can quickly become quite productive with python before gaining an understanding of the essence of the language, and before learning what does and doesn't work.

For a project to be a success it is extremely important to have expert python engineers on the team, and make sure there is a policy of code review on all commits. Code review is the most important, because most bad habits in python would be spotted by an extra pair of eyes.

Experience in other languages doesn't necessarily help. Python is unique. Many of the most common pitfalls in python are indeed considered best practice in other languages.

A couple examples of this:

Java makes a clear distinction between data attributes and methods. If you think you need encapsulation, you must hide data attributes and use getters and setters to manipulate them indirectly. Otherwise when you change the implementation, you will have a huge refactoring task in front of you.

In python, there is absolutely no reason whatsoever to preemptively wrap your data attributes in getters and setters. You just use the attributes. Change them to properties later if it becomes necessary. Python's flexibility allows you to do this seamlessly without any refactoring outside the class being modified. In python, your best bet is to keeps things simple and concise.

In one project I found over 3000 lines of code specifically dedicated to completely unnecessary encapsulation of ordinary attributes. There was no benefit, and it made the resulting code brittle and slow.

In C++ any medium to large project has a build as a centerpiece. The model is that you have source code which you process to create something that you run. In python you basically just run the source code. Sure it's compiled to bytecode, but that's a hidden caching operation that you usually don't need to think about. And yes, in many cases you have some kind of deployment, but it need not be complicated, that shouldn't significantly impact how you think about the architecture.

So there was this project involving a million or so lines of code. The architecture involved an ad hoc package manager that would concatenate a bunch of python modules into various larger files, encrypt the result, and then use a messy import hook implementation that would load these monstrosities. The order in which things got imported was critical because lots of code would execute on import. When it came time to upgrade to python3, a nightmare was at hand.

On the other hand, I've seen plenty of beauty in python projects. The most successful always involved keeping code quality as a high priority, ubiquitous unit testing, and a high level of collaboration including code review.

Collapse
 
asadullah_hamzah_6defb735 profile image
Asadullah Hamzah • Edited

The answer is simple, python is not.

Wanna build something simple, which requires a library? Boom, mostly results into error from pip. Try to install numpy as a beginner, and get:
Image description
Thought that's the beginning? Welcome to the infamous "import imp" line:
Image description
Think you can resolve that? Here you go:
Image description

That, of course, are just some examples. I'd rather use Assembly than switch back to python, because it was a pain to even load up the language without burning my CPU down.

Collapse
 
ollie_turner_8e71c4aa3920 profile image
Ollie Turner • Edited

While Python is widely celebrated for its simplicity and versatility, it also presents several challenges that can complicate its use and maintenance, especially for those transitioning from other programming languages. Here are some notable issues, along with comparisons to languages like Java, C#, and JavaScript that often handle these aspects more gracefully:

Multiple Python Versions: Managing multiple installed versions of Python can lead to confusion and wasted drive space. Unlike Java or C#, where the version management is typically more straightforward, Python's complexity often results in issues when installing packages, as it’s unclear which version they are being installed into.

Pip Versioning: Each Python version can have its own pip, creating fragmentation in package management. In contrast, languages like JavaScript use npm globally, minimizing these conflicts and streamlining dependency management.

PATH Limitations: While multiple versions of Python can be installed, only one can be referenced in the system’s PATH at a time. Other languages, such as Ruby, manage environment configurations more effectively, allowing developers to switch versions without breaching character limits.

Dependency Management: Python's dependency management can lead to file duplication and conflicts, with leftover sub-dependencies complicating the ecosystem. In languages like Go, dependency management is handled more transparently, avoiding such issues and ensuring a cleaner workspace.

Virtual Environment Management: The existence of multiple tools for virtual environment management (e.g., venv, pyenv, conda) adds unnecessary complexity. In comparison, languages like C# use a unified approach with .NET, reducing the need for multiple environment managers and simplifying project setups.

Inconsistent Best Practices: The lack of a unified approach among Python developers regarding best practices can lead to varied implementations. Other languages, such as Java, have established conventions and frameworks that promote consistency and ease collaboration.

Lack of Pre-Installation Warnings: The Python installation process does not adequately inform users about potential pitfalls. In contrast, many other languages provide clearer guidance during setup, helping developers avoid common mistakes from the start.

Default Installation Issues: The default Python installation is often not suitable for project work, leading to conflicts later. Languages like C# encourage the use of dedicated project environments from the beginning, which reduces the need for corrective measures down the line.

Compatibility Information: When installing packages, Python does not always provide information on compatible versions, which can lead to time-consuming troubleshooting. Other ecosystems, like Node.js, typically make version compatibility explicit, helping developers avoid unnecessary headaches.

Inconsistent Library Behavior: Variability in how libraries behave across different Python versions can lead to unexpected issues. Languages like Java have stricter versioning and backward compatibility rules, which contribute to a more predictable development experience.

Performance Concerns: Python can be slower than other languages for CPU-intensive tasks. In contrast, languages like C++ or Rust offer better performance for compute-heavy applications, making them more suitable for certain use cases.

Whitespace Sensitivity: Python’s requirement for precise whitespace and indentation can make scripts difficult to read and maintain. Other languages, such as C# or Java, allow for more flexible formatting, which can improve readability without risking syntax errors.

PATH Configuration Challenges: Setting up the PATH variable correctly can be frustrating in Python. In contrast, languages like Ruby provide clearer tools for environment management, easing setup for new developers.

Global Interpreter Lock (GIL): The GIL restricts true concurrent execution in multi-threaded Python programs. Other languages, like Java or C++, allow for true multi-threading without this limitation, enabling better performance in concurrent applications.

Collapse
 
si_shaunryan profile image
shaun ryan • Edited

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.

Collapse
 
evanoman profile image
Evan Oman

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.

Collapse
 
mellen profile image
Matt Ellen-Tsivintzeli

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}?

Collapse
 
secas_jaime profile image
Jaime A Secas

The good thing about python is that any idiot can use it.
The bad thing about python is that any idiot can use it.

Collapse
 
pbouillon profile image
Pierre Bouillon

Ahah, true !
I oftenlty talk about Python as "Easy to learn, hard to master"

Collapse
 
helpermethod profile image
Oliver Weiler

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
Collapse
 
fire501i profile image
Thomas Holt

Python is kinda all over the place syntax-wise in my opinion. I like languages that make use of parentheses and braces and that sort of thing. Python was actually where I started learning too.