4 ms·
I saw "Reasons Python Sucks" on HN and I thought I was going to finally see an updated list of well-informed and articulated concerns about Python. Instead, th
by jMyles 8y ago
I saw "Reasons Python Sucks" on HN and I thought I was going to finally see an updated list of well-informed and articulated concerns about Python.
Instead, this list is bizarre, misinformed, and largely incorrect. Other commenters have already pointed out several specifics. Two things I haven't seen yet that I'll add:
> And I pity anyone who miscounts spaces and accidentally puts in three spaces instead of four somewhere -- this can take hours to debug and track down.
This is just absolutely batshit ridiculous. You'll get an IndentationError pointing to the exact line in question. In all my years of working with people at all levels, I've never seen anybody spend more than a few minutes working out an IndendationError.
> <Pass by reference/object> is one of the big differences between procedural, functional, and object-oriented programming languages.
This is a non-sequitur, and it's plain to see. It's possible (in fact common) to write with all three of these orientations in python, and object transit has absolutely nothing to do with it.
- heavyset_go 8y agoCame to a similar conclusion. I use Python a lot, and it certainly has its problems. However, the article's analysis doesn't even begin to scratch the surface of this topic in an informed manner. Instead, we're presented with paragraphs written by someone who can't read a stack trace: In [7]: def foo(): ...: print('foo') ...: print('bar') File "<ipython-input-7-47f5b52e9e07>", line 3 print('bar') ^ IndentationError: unexpected indent
- mangodrunk 8y agoIsn't that a strawman? Wouldn't a more apt example be: def foo(): nums = [...] sum = 0 for x in nums: print(x) sum += x I don't know python well, but it seems like there could be subtle issues with indentation that wouldn't cause a compiler error, but would cause the wrong output.
- jMyles 8y ago1) This is not the case that the author presented, though - it was specifically about 3 spaces instead of 4. This tells me that the author simply doesn't hang out with python people. 2) On the substance of your concern: I think the evidence is clear (although I'm aware of no study) that having both syntactical control characters (typical curlies) and style-only indentation is more likely to lead to the outcome that you present, because the eye will always gravitate to read by indentation, whether it's syntactical or not. So have the indentation be the syntax makes this problem more easily avoided, not less. IE: def foo() { nums = [...] sum = 0 for x in nums { print(x) } sum += x }
- maemilius 8y agoThe difference here is that the former (your example) is automatically correctable whereas the latter is not. If I highlighted that entire function in my editor of choice and hit TAB I'd get exactly the "correct" indentation. Almost any modern editor can automate this for you. It's one of the benefits of having a syntax for blocks. Yeah, it's extra typing for something you're going to do anyways, but now the computer can manage the style for you. Also, and this is just my personal experience, I've learned to read by those control characters. I have a really hard time reading python because I'm subconsciously looking for the control characters! I really think that part is really down to how you learned to program and what language you use on a daily basis. As an aside, I think something like this is much more demonstrative of the issue you're suggesting: def foo() { nums = [...] sum = 0 for x in nums { print(x)} sum += x } It's still automatically fixable, but it's way less immediately apparent that something is wrong with the indentation.
- jMyles 8y agoRight, so you do your automatic fix and you end up with indentation that's the same as the python example. Isn't this a case for syntactical indentation?
- heavyset_go 8y ago
- noobermin 8y agoI think it's very clear the author uses atypical tools or workflow. Nothing wrong with that, they just have to accept the fact that most hackers use tools that auto indent their code intelligently and find a way to get their method/scheme/whatever in such a way to deal with it like others do.
- gnulinux 8y agoI 100% agree with you, but as a minor counterpoint, let me present you where an indentation might be a problem. I teach python (to my friends lol, not professionally) and a new learner apparently debugged this "for hours" (probably just 20 minutes). class A: def some_method(self): return # something def some_func(foo, bar): return # something def some_other_method(self): return # something They intended to make `some_other_method` a method of class `A` instead they ended up writing `some_func` the wrong place and python parser was happy. For everyone except extreme python beginners debugging this will take 10 seconds. But just a datapoint.
- jMyles 8y agoYes, now that's a legitimate demonstration of a possible weak point of syntactic indentation. But it's easily fixed with code collapsing tools or a structure viewer (both of which are provided in all of the major python IDEs).
- SilverSlash 8y agoA list of well informed and articulated concerns about python probably wouldn't be titled "Reasons Python Sucks".