DEV Community

Discussion on: Why all this hate about Python?

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.