5 ms·
Every time I hear criticism of Python's whitespace (indentation), I am reminded once again of how much I appreciate and enjoy it.
by clemesha 17y ago
Every time I hear criticism of Python's whitespace (indentation), I am reminded once again of how much I appreciate and enjoy it.
- jacquesm 17y agoTo me it's a mixed bag. It's like a 'price of admission', if you've been conditioned a life long to look for matching braces (or at least begin, end pairs), and if even languages that are strictly speaking markup languages seem to feel the need for delimiting the end of a block in some way you alienate a large number of people before they've even written a single line. Compound that with the difficulty of passing code snippets using various media and it is easy to see why so many people argue against this. You can get used to it, sure. But that's not a very strong argument. I think there would have been ways to get out of this. Especially when programming using tabs you'd better be very careful not to hit a delete by accident while walking near the end of a block of code. That can really mess you up. edit: also, for that reason alone any discussion about the relative merits of python vs something else first has to get pas the 45% where we talk about the whitespace. And some people will go to extreme lengths to prove its 'goodness' even when clearly it is not only good. Being objective about something you like is very very hard.
- brodie 17y agoIncreased readability and code clarity are well worth the price of admission.
- jacquesm 17y agoReadability is a subjective thing. I find C dead easy to read, that's because I've read lots and lots of it. Any other language is harder for me. edit: on another note, in a delimited language the indentation can be created fully automatic, in python it can not, placing most of the burden of making sure the indentation is correct on the human. This lack of 'redundancy' has bitten me several times already.
- brodie 17y agoRight, it is subjective, but requiring indentation imposes a higher baseline level of readability: what you see is what you get. This is important when you're working with more than just your own code. It's like a forced style guideline, and it gets even better when everyone conforms to Python's other optional style guidelines. It reduces friction.
- jacquesm 17y ago> It reduces friction. Between python programmers, yes. But it increases friction between those that are 'in' and those that are not (yet). And even some of those that are 'in' have their reservations. I completely understand the reasoning behind it, but the number of times that I've run in to practical problems because of having some kind of delimiter is 0, the number of times that I've run into some kind of trouble with python because of not having delimiters is starting to add up. This may be a factor of inexperience, time will tell. But it is definitely a new 'source' of bugs, and sources of bugs are in my opinion things that you avoid like the plague when designing a programming language. Even in 'C' (or C++, or anything that derived it's syntax from those languages) I always found it both wrong and inconsistent to be able to say: if (a) b++; To me that's asking for misery, you could remove that whole if(a) line and the whole thing would remain syntactically correct. I think of the { } just like I think of guardrails on the highway. They don't make stuff prettier, sometimes you can't look across, but they certainly keep you safer.
- jbellis 17y ago> Between python programmers, yes. Optimizing for any other audience would be ... strange, especially at this point in python's lifecycle.
- jacquesm 17y agoTrue, it is absolutely beyond that. But I think that it would have helped significantly in an earlier stage, I even think that PHP would have been run into the ground. In the long run that may still happen, there definitely is shift happening.