6 ms·
As someone who writes Lisp (well, Clojure) every day and does not particularly enjoy it, I find the common complaint about parentheses to be a non-issue. In fa
by cespare 12y ago
As someone who writes Lisp (well, Clojure) every day and does not particularly enjoy it, I find the common complaint about parentheses to be a non-issue.
In fact, I'm not sure I've heard of anyone who wrote any significant amount of lisp code and came away talking about parentheses. This seems to be mostly a reaction from people who've read a bit of Lisp without using it.
Then again, I just noticed that I type ( and ) with my third and fourth fingers, so maybe it would be worse if I typed properly :)
- jsmeaton 12y agoI 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.
- 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.
- aerique 12y agoIf you write Lisp every day why not remap the ( and ) to a non-shifted position? I use the [ and ] keys but I use Common Lisp, not Clojure.
- soegaard 12y agoFWIW In DrRacket the key ] inserts either ], }, or ) to close whatever is open.
- wtetzner 12y agoI find it odd that people use their pinky to type parens. When my fingers are on the home row, '(' is above my middle finger, and ')' is above my ring finger. Typing them with my pinky would require me to contort my hand.
- dragonwriter 12y ago> When my fingers are on the home row, '(' is above my middle finger, and ')' is above my ring finger. If your fingers are on the standard home keys (index fingers on "F" and "J"), '(' is between the middle and ring finger and on the normal (inward) path of the ring finger as it extends, ')' is between the ring finger and pinky and on the normal path of the pinky as it extends. OTOH, if you keep your right index finger on the "K", which is less standard, then those become naturally on the middle and ring (and it may make sense for programming, but less for general typing -- the standard home position is based on where the letter keys are, but the extra symbols on the right are more used in programming than general typing, so moving the right hand one key out makes some sense.)
- dedward 12y agoIt's not odd... it's traditional touch-typing. It should be your ring-finger for ( and your pinky for ). Many people seem to type it the way you have just suggested (middle/ring) - myself included. I'm currently re-training myself to do that properly.. it feels weird at first, but I'm starting to get the feeling it will actually be faster. Your touch typing can always be better, right?
- dmpk2k 12y agoIn fact, I'm not sure I've heard of anyone who wrote any significant amount of lisp code and came away talking about parentheses. Whelp, now you have. Hi! :) Although I sometimes miss the goodies homoiconicity brings, I much prefer the increased syntactic structure of other languages.
- jahnu 12y agoIt's a zombie complaint. I feel it's actually easier with parenthesis because with always well formed lisp you get the benefit of incredible tools like paredit-mode which make it easier to type than in other languages and I say this as someone who does full time c++ with a fair bit of python, javascript and html and I only do lisp stuff as a hobby.
- agumonkey 12y agoI was looking for a way to summarize lisp syntax benefits. Most BNF-heavy languages are statically appealing. They have layout and differentiators that makes it nice to look at. Lisp is a building material, the expressions are objects, the syntax is object. You don't want to look at it, you want to model with it, live. And with the "metacircular" (sorry for the sophisticated looking lingo) mindset, you can program how you interact with it (protorefactoring ala paredit/redshank etc). Most people can't judge s-exp properly because they're not playing with it only looking at dead printouts; and the few who does are using a textbuffer[1], avoiding one important programming rule : automate everything. Lisp syntax has a simple and potent programmable API giving you a lot of power for free. [1] I even watched a lisper using emacs without paredit at a meetup and it was painful.
- therockhead 12y agoFor me it is the prefix notation and still find nested expressions difficult to read.
- derengel 12y agoWhy don't you enjoy it?