On 2011-08-11, Steven D'Aprano <steve+comp.lang.pyt...@pearwood.info> wrote: > Seebs wrote:
>> I have seen all the counterarguments, and what I've >> mostly become convinced of is this: >> 1. Indentation as flow control was a bad idea. > I'm not aware of any language where indentation is used for flow control. > Python is not one of those languages: it uses for, while, if, etc. for flow > control, just like most other languages. It does however use indentation > for grouping code into blocks -- a different concept. Agh! Point granted. Presumably you knew what I meant, but you're right that I said it wrong. > You are free to hold whatever opinions you like, but have you considered > that the reason people get emotional and angry when others insist that > indentation as flow control should be discarded is because they actually > believe that the "off-side rule" (as it is called) makes for a better > language and a better coding experience? Yes. And when I talk to people who are *able to admit that there exist problems*, and who argue that the benefits outweigh them, I believe that they are probably making a good point. It's the people who insist that there are no problems that worry me. > There are dozens, hundreds of brace languages, and 1-2 dozen using > indentation, including Python. If braces are so important to you, go use > one of those other languages, don't wreck the language we like by taking > away one of the best features of the language. If I had a choice, believe me, I'd do just that. > We're fully aware of the tradeoffs of significant indentation. You are. A couple of other people I've talked to are. Many others are not. > We believe > that brace languages get the trade-offs backwards: they optimise code for > environments which mangle source code. 99.999% of code will never pass > through a broken mail server that strips leading whitespace, or pasted into > broken web forum software that mangles indentation, or go through any other > broken tool that messes with indentation. Brace languages optimise for the > 0.001% case, Python optimised the 99.999% case. This is a really interesting analysis. My experience, though, puts it more at about 99% and 1%. And the thing is... > Because people simply don't like it when their code's indentation doesn't > match the actual semantics, people usually manually ensure that the two > match, braces or no braces. Editors still have commands to indent and > outdent blocks of code. There is no difference between (say) C or Pascal > and Python in that regard. Yes, there very much is. You can't outdent "a block" in Python unless it is already correctly indented. The underlying thing I've noticed is: Braces have problems more often, but the problems are *always* 100% machine-fixable and therefore trivial. It takes milliseconds to get a program fixed so it looks like what it means. Indentation has problems less often, but the problems are *never* machine-fixable. It takes minutes or hours to figure out what was supposed to be there. > There is nothing implicit about indentation. This false dichotomy between > so-called explicit braces and allegedly implicit indentation gets thrown > around all the time, but it is simply *wrong*. Indentation is not implicit. Hmm. Maybe "implicit" isn't quite the right word, but... The end of an indented block is not a thing, it's the lack-of-a-thing. foo bar How many unindents are there between "foo" and "bar"? If you can't answer this from looking between "foo" and "bar", but must instead look at previous lines and *INFER* the number of unindents, then it seems to me that there is something implicit going on here. > And ABC, Boo, BuddyScript, Cobra, CoffeeScript, Curry, F#, Genie, HAML, > Haskell, ISWIM, Miranda, Nemerle, Occam, PROMAL, Spin and XL, plus any > other languages with significant indentation. Point made. > No, most mail servers don't mangle whitespace in the body of the email, or > in attachments. Most don't, that's true. Part of my frustration comes from a 6-month period during which most of my email was sent through a mail server which, for reasons no one was able to determine, was dutifully converting any plain text it received into HTML, and stripping "irrelevant" spaces along the way. :) > Some mail clients do, usually because they default to using > HTML for text. So get a better mail client. I have tried occasionally. Mine does not default to use HTML, but it does sometimes mangle lines. Unfortunately, it's the closest to having other funcitonality I want I've ever seen. > Avoid pig-ignorant web forums > that think that source code can be reflowed or that remove leading > whitespace. Stop using Notepad, and use an editor that offers indent and > outdent commands. I'm not using Notepad. And actually, it's the indent/outdent that bit me worst, so far. :) > If your mail server had a bug that deleted braces from emails, would you fix > the bug, or would you insist that braces were a failed experiment and that > C should stop using { } and start using BEGIN END like Pascal? If *only one program* deleted braces, sure. If "braces get deleted" were pretty much a daily occurrence among people I know (not everyone gets hit every day, but someone gets hit just about every day), and had been for the last 20+ years, I might feel differently. But I think a lot of this just comes down to the underlying human thing: People don't like being dismissed. When people come here and say that, for whatever reason, they are in an environment in which the whitespace thing is a problem, they get insulted and told that all their tools, which they may have been using without any trouble for twenty years, are defective and should be completely thrown out. Heck, arguably I should consider "Stop using Notepad" to be pretty insulting. And at the same time, I think the people who like the indentation policy are probably pretty sick of seeing it bashed. So there's a tendency for gradual escalation, and of course, each new person who comes here is coming here with a thing which is new *to them*, but old *to you*. So CLP jumps all over people who say that this is a problem for them, tells them they're wrong, tells them they're stupid, tells them that their work environment isn't *good enough* for them to be worthy of using Python. And tells them to leave. Well, seriously. If I could, I would. If it were up to me, I'd talk to the people who'd picked Python for some stuff I have to work for, point out the hostility of the Python community to newcomers whose workflows don't happen to have been preemptively built entirely around Python's design decisions, and suggest that maybe we use another language. Heck, since I've been encouraged so much to do so, I think I will. -s -- Copyright 2011, all wrongs reversed. Peter Seebach / usenet-nos...@seebs.net http://www.seebs.net/log/ <-- lawsuits, religion, and funny pictures http://en.wikipedia.org/wiki/Fair_Game_(Scientology) <-- get educated! I am not speaking for my employer, although they do rent some of my opinions. -- http://mail.python.org/mailman/listinfo/python-list