4 ms·
I agree with a lot of these things, but actually disagree that Python is good at exemplifying some of them. For example, semantic whitespace is arguably implic
by smt88 7y ago
I agree with a lot of these things, but actually disagree that Python is good at exemplifying some of them.
For example, semantic whitespace is arguably implicit, hard to read, invites density (compared to an extra line for braces), and (again arguably) is ugly.
Yes, some of these things are subjective, but it's hard for me to confidently recommend Python to someone with these values.
- dragonsh 7y agoMay be different people have different experience with Python. After c and Perl had been using it for over 15 years and among the languages I have seen Python code is one of the most readable one so far, again subjective as I like sparse and empty spaces in architecture with minimalist design. For me whitespace is same in Python code. Whitespaces forces programmer to make code readable. Obviously today with tools like gofmt, rustfmt it seems easy and those are inspired by Python. Python PEP process has been adopted by many programming language. Try JCP process and see what I am talking about.
- thayne 7y agoI'd be fine with python requiring indentation, what bugs me is the lack of an end delimiter. IMO it makes things like aut-indentation, auto-formatting, copy-pasting chunks of python code etc. a worse experience.
- ummonk 7y agoIf C and Perl are your comparison points, obviously python will seem better...
- dragonsh 7y agoI have tried golang, Java, C++, js and recently rust. I can still confidently say python code is the most readable of them all. Indeed so much so that python style is adopted by swift language and it does look cleaner than others. Obviously I like concise perl, Haskell code too they have a beauty of their own, but that does not make python whitespace is bad. It's just people who feel it's a burden to explicitly follow whitespace hate python indentation based on my observations. Since suddenly instead of braces or statement end one need to use a visual sense of beauty along with logic.
- ummonk 7y agoIn what way has Swift adopted Python style?
- t0mbstone 7y agoI can't even tell you how many hours I've lost due to someone committing an incorrectly indented line in python. This often happens during merge conflicts, for example. Because logic in python is interpreted via indentation, it's very difficult for python to realize when a line is indented incorrectly. It just assumes that if a line is indented a certain way, it was intentional. In programming languages like Ruby or Javascript, indentation is stylistic and has no effect on the logic. You can actually use the "auto-indent" feature of many editors, and you can use linting tools to ensure formatting. If you have an extra "end" or an extra ending bracket, your IDE can immediately warn you. Not so with python!
- psv1 7y ago> very difficult for python to realize when a line is indented incorrectly. It just assumes that if a line is indented a certain way, it was intentional. How is this different from some language not realising that a statement should be inside of the curly brackets instead of outside?
- dreamcompiler 7y agoNo compiler can read your mind. But in a language with brackets, the compiler can at least determine scope even when things are poorly-indented. In Python it can't in a lot of cases. It's like static type checking: The class of errors the compiler can catch is larger when it's present. Likewise, with visible scoping characters, the class of errors the compiler can catch is larger than when they are invisible.
- psv1 7y ago> But in a language with brackets, the compiler can at least determine scope even when things are poorly-indented. Yes, but can it determine scope if things are poorly-bracketed? Because that's the fair comparison.
- smt88 7y agoPoor bracketing almost always causes syntax or compiler errors. As long as you have a language that's block-scoped (which is true of modern JavaScript and most other popular languages), you'll get an error if you make a bracketing mistake. That's not true of indent mistakes. Semantic whitespace is lossy -- there's data contained in those brackets that some people think is low-value that it's expendable for the sake of saving keystrokes, but it does have value in practice.
- coldtea 7y ago>For example, semantic whitespace is arguably implicit, hard to read How is it implicit and hard to read? If anything it's very explicit, instead of just a single { and } to denote "the next part is the body", it explicitly requires visibly indenting the body. That's easier to read, and is the expected "good practice" in C and similar "brace" languages anyway (you're not supposed to use { and } without also indenting your code there either). Python's semantic whitespace is more visible than having a { and } in C e.g. and not indenting, or having a for/if/etc without braces with a single statement attached and not indenting. Not sure what's ugly about: def double(n): return n*2 compared to: function double(int n) { return n*2; } or worse: function double(int n) {return n*2;} (especially with larger bodies -- in fact this non-required whitespace property is where 90% of the "obfuscated-C" ability is based on)