3 ms·
True, and to me the ease of use increases by getting rid of what I perceive to be superfluous parens. I'd rather write the first code block and have mean the sa
by lowboy 14y ago
True, and to me the ease of use increases by getting rid of what I perceive to be superfluous parens. I'd rather write the first code block and have mean the same as the second. This is a trivial example, but when LF + indentation become significant it eases deep nesting.
Ideal:
if (empty? x)
foo
bar
Less ideal:
(if (empty? x)
foo
bar)
The clojure comp shortcut looks good to me, but why even need the outside parens if it was the only line in that block?
(comp foo bar baz quux) x
Ideally, that should be valid as well. I know this kind of reduction won't work in a lot of cases, but I appreciate syntax sugaring like this where I can get it.
- wonderzombie 14y agoSugar is nice, but it ought to make the code clearer. I worry that in trying to make this appear simpler, in reality it would be substantially less so. I think significant whitespace works for a language like Python, but I'm less convinced that it's a great idea for a Lisp. As it stands now, the trade-off is some unfamiliarity and discomfort up front for rather elegant consistency for the entire time you use the language. When you're optimizing for the people who'll use the language, the former is a lot less significant. :) One thing worth noting is that Clojure does introduce constructs which use square brackets, braces, etc. It's a little nicer to use brackets for grouping, in lieu of parens for lists or declaring function params.
- lowboy 14y agoI agree with your priorities on how long term concerns trump up-front discomfort when learning a language. But to me it would be of long term benefit to never see parens that could be otherwise indicated by sig whitespace patterns like the empty/foo/bar indented block we have above. The elegance seems to come from having a simpler parser, and one less thing to explain to people when they're learning the lanuage. As a user of a language and not a developer of a parser, the first doesn't concern me and the second should be trumped by long-term concerns. Using significant whitespace to eliminate syntax is elegant in its own way as well. Again, maybe this is just because I'm not a lisper, but keeping implicit parens that follow a well-established pattern should be a trivial mental task for a developer. Could you provide a piece of lisp code as a contra example?
- deleted 14y ago[deleted]
- wonderzombie 14y agoI guess what I'm trying to say is that syntax is probably the least significant difference between a Lisp like Clojure and your average imperative C-like. So you can make incremental improvements to the syntax, but since it's not going to significantly alter how and what kinds of programs you write the way immutability and purity do, I don't see it as all that worthwhile.