print(args) => (print args)
if (cond) { exp1} else {exp2 } => (if (cond) (exp1) (exp2))
array[index] => (index array)
And so on. On average there is probably the same amount, but visually it kind of appears to be more. print(args) => (print args)
if (cond) { exp1} else {exp2 } => (if (cond) (exp1) (exp2))
array[index] => (index array)
And so on. On average there is probably the same amount, but visually it kind of appears to be more.I know that at the end there's no distinction (lisp syntax is AST, and every other source code ends up as AST), and the idea that someone would accept syntax restrictions as a good thing is probably strange to the true lisper, but people care about the syntax. By eliminating syntax and forcing the programmer to write AST directly lisp gave enormous power to the user, but at the end not enough programmers were willing to give up on comfort to acquire all that power.
})
})
});
...trailing almost every function definition is equally absurd. At least with Lisp I only have to deal with one delimiter type and just count the number instead of the })})}); mess of javascript and some other languages.Although I do have to say I think Python got it right in trying to do away with as much of it as feasible.
if (a && !b) {expr} => (if (and (a) (not b)) (expr))
That's a simple expression and I'm not even sure I managed to match the () correctly--
I installed Parinfer it on my project: CLJSFiddle[2], and it's not what I'm used to and doesn't have everything but for a novice it is highly usable - check it out!
[1] https://shaunlebron.github.io/parinfer/ [2] http://cljsfiddle.com
(when (and a (not b))
expr
...
expr) if (a && !b) { expr } => (if (and a (not b)) expr)
Or if (a() && !b) { expr() } => (if (and (a) (not b)) (expr))
Now the amount of parentheses is either 4/6 or 8/10 which is not a very big difference (and caused only by the syntactic sugar for `not`), especially considering that the left example uses `!`, `&&` and two kinds of parentheses (perhaps a `;` as well).My point was more about the two extra parentheses for each && or ||. Imagine converting
if (a && b && c && d || e)
to a LISP. if (a && b && c && d || e) {
doSomething();
}
becomes (if (or (and a b c d) e)
(doSomething))
It's just a little more explicit because operator associativity and precedence aren't worked out for you. (For better or for worse.)EDIT: I think you were imagining something like this:
(if (or (and a (and b (and c (and d)))) e)
(doSomething))
..which is definitely not the art. (if (or (and foobar
(some-predicate-p quux)
(= qwerty 432))
(a-long-function-call-with-two-args bar ytr))
...)
Compared to something like: if (foobar &&
somePredicate(quux) &&
(qwerty == 432) ||
aLongFunctionCallWithTwoArgs(bar, ytr)) {
...
}In general, the reliance of syntax on random punctuation instead of meaningful symbols (a'la APL) or clear, human-parsable text is maddening - LISP and its derivatives do it far less than other modern languages, but still too much for my taste.
I'd also prefer clearly spelled-out syntax in this age of autocomplete rather than a jumble of weird abbreviations while I'm wishing for unicorns, and languages with code editors that do a good job of visually representing the flow of code rather than rely on punctuation, white-space or some unholy combination.
Programming seems kinda primitive compared to other aspects of computer-enabled content creation at times.
I think the reason people find it hard to adjust to the new pattern is that they have been trained all their lives to recognise the pattern where the name of something is distinct and outside of the thing itself. In mathematics obviously people have been used to expressing functions using f(x) since an early age (10?). But physically also. Think of these things:
- The name of a shop or a village tends to be on a sign on the outside.
- The name of a book is on the cover.
- The title of a folder is on the outside.
- The name of an OS file etc.
Naming things is very important. Its the basis of a lot of communication, understanding and abstraction and people are used to the name of something being fundamentally distinct and outside of the thing itself.