6 ms·
I would assume it'd be the same as people complaining about significant whitespace in python. No one who actually programs in python complains about the whitesp
by jsmeaton 12y ago
I would assume it'd be the same as people complaining about significant whitespace in python. No one who actually programs in python complains about the whitespace.
- lutusp 12y ago> No one who actually programs in python complains about the whitespace. I wouldn't say "no one." I read comments regularly from people, usually students, who get into trouble with whitespace in Python, especially if they mix tabs and spaces in the same source file.
- jsmeaton 12y agoIf you're mixing tabs and spaces in the same source file, chances are that you're not a very seasoned python programmer. I would imagine a large segment of students also complain about parens in lisp. Though to be fair, there would be some people that use python day-to-day that don't like significant whitespace. I'd bet there'd be at least a few lispers that don't enjoy wrangling parens.
- jahnu 12y agoI find it a pain and error prone when having to change indentation in python code. E.g. when adding an 'if' in front of a block of code. So easy to miss a line or mess up the indentation in the block itself and then you might not spot an error until run time.
- djur 12y agoI was under the impression that Python emits an error about inconsistent indentation at compile time (the initial parsing and interpretation of a script file), not runtime (+x time units later, after the program has started). Is that incorrect?
- lutusp 12y agoSuch errors are caught at compile time. I think the prior poster was speaking in a general sense in which runtime means any time after source file editing.
- jahnu 12y agoI'm talking about something like this.. def foo(): do_this() and_this() later I change it.. def foo(): if something(): do_this() and_this() oops... and_this() should have been in the if block and I won't find out till I run it. (imagine a much bigger more complex example of the above function) In large pieces of code this can be easy do. If you are forced to use parenthesis it's much more difficult to make this error. One could argue that experience prevents you from doing this but I have sadly found this not to be the case in practice.
- lutusp 12y ago> If you are forced to use parenthesis it's much more difficult to make this error. By "parentheses" you mean delimiters, which create visible boundaries to defined areas in code. Parentheses are an example of delimiters, but not all delimiters are parentheses. Bash has if ... then ... else ... fi Ruby has if ... else ... end C/C++/Java have (logical test) { controlled area }, nested to any practical depth. And so forth. Python doesn't. > One could argue that experience prevents you from doing this but I have sadly found this not to be the case in practice. This is an argument against complex functions that do a lot, as opposed to breaking program logic up into smaller blocks that are easier to understand and control. The old argument against this practice was that a large function that did everything was faster than the same logic broken into smaller blocks. A modern compiler will generally prevent this from happening.
- jahnu 12y agoWell I used the word parenthesis since the topic was Lisp. > This is an argument against complex functions that do a lot Functions large and complex enough to make this problem significant seem to be the reality I have to deal with when programming in the large. It's only my opinion but a language feature that improves my real world experience at no cost is a bonus.
- andreasvc 12y agoIt's not a pain if you use an editor which lets you indent a whole block of code at once; e.g., in vim, use shift-V to select lines of code, then >> or << to in- or dedent. This is handy for all programming languages, of course.
- Symmetry 12y agoHaving groups of lines with the same indentation act as text objects helps too. http://vim.wikia.com/wiki/Indent_text_object http://vim.wikia.com/wiki/Indent_text_object
- na85 12y agoI program in python (and C/C++) and really dislike python's whitespace handling. I think giving semantic meaning to one of the least-standardized aspects of text (tabs/spaces) is a bad decision through and through.
- ayrx 12y agoThat's the thing. Python does standardise it. 4 spaces, no tabs.
- jahnu 12y agoNot quite... http://legacy.python.org/dev/peps/pep-0008/#tabs-or-spaces http://legacy.python.org/dev/peps/pep-0008/#tabs-or-spaces Spaces are the preferred indentation method. Tabs should be used solely to remain consistent with code that is already indented with tabs. Python 3 disallows mixing the use of tabs and spaces for indentation. Python 2 code indented with a mixture of tabs and spaces should be converted to using spaces exclusively. When invoking the Python 2 command line interpreter with the -t option, it issues warnings about code that illegally mixes tabs and spaces. When using -tt these warnings become errors. These options are highly recommended!
- ayrx 12y agoPEP 8 was published in 2001, a good 13 years ago. That's about as standard as you can get.
- bad_user 12y agoI developed in Python for several years and I disliked whitespace, because sometimes I want the flexibility to format code in a way that makes more sense given the right context and the whitespace was always in my way. Plus, its whitespace-based syntax was used as an argument to not evolve the language, being one reason for why they haven't added proper anonymous functions. I can't comment on LISP's parens much, for now it doesn't bother me, but Python's whitespace did and I tried liking it for about 3 years.
- andreasvc 12y agoPython has proper lexical closures in the form of inner functions. Can some please enlighten me why one would still insist on multi-line anonymous functions? For documentation purposes it's a) better to give something a name, b) have a multi-line function in a separate place instead of inline in the form of a lambda. Concerning whitespace, serious (large) projects have a very specific style guide, which includes prescriptions on whitespace. Python doesn't add any extra restrictions to that and in other languages a mismatch between whitespace and braces is a frequent source of bugs, so significant whitespace avoids that as well.
- bad_user 12y agoOnly by not working with anonymous functions can anybody come up with such an impression. Python has at least 3 features that are not needed in languages that have proper support for anonymous functions and that are more expression oriented: 1. for comprehensions 2. the with statement 3. decorators You cannot work efficiently with higher-order functions until you have anonymous multi-line functions, period - also, Python's single-line lambdas would be a lot more useful if Python wouldn't have been so statement oriented, unfortunately in practice they are useless. In regards to your points: a) no, I don't buy that b) ordering matters, we read code as we are reading text, top-down, left to right
- andreasvc 12y agoCan you please explain to me what's important about these functions being anonymous? Why, specifically, they shouldn't be given a name? How do you define working "efficiently with higher-order functions"? Given that Python fully supports higher-order functions, I am really curious what you could mean. I didn't downvote you, but it may have to do with your pointed assertion here, without anything in the way of an argument. As to "ordering matters"; sure, but as the functions a nontrivial program calls are inevitably described as a graph, they must necessarily be defined in some arbitrary linear order anyway.
- deleted 12y ago[deleted]
- Grue3 12y agoI program in Python for a living and I curse significant whitespace every single work day. Especially when I try to copy paste some code into the shell. It's one of the worst misfeatures of the language, and it wouldn't even be necessary if there was an "end" keyword.
- klibertp 12y agoUse IPython and %cpaste magic. Works well.
- Grue3 12y agoI use IPython. %cpaste doesn't work all the time if you're copying from the middle of a function. And even if I just paste a one-liner that starts with a few spaces, why the hell does it even bother to complain about that? Oh wow, this one line of code (which happens to be the entirety of code I'm asking you to execute) is indented wrong, tell me something I don't know! What a PITA.