Re:An Intuition for Lisp Syntax
by filoeleven on Monday October 26, 2020 @11:22PM
(#24904216)
Let’s talk about text over symbols and readability.
Return the maximum value of the array “numbers”. The languages are listed in descending order of text > symbol.
Clojure:
(apply max numbers)
JavaScript:
Math.max(...numbers);
APL (I couldn't find how to apply this to an arbitrary array):
⌈/ 4 3 2 7 5 1 3
Here’s a guess:
⌈ numbers
The most aymbol-focused is the least readable to me, and Clojure is the only one that returned good results from a Google search to figure out what was going on. Both “JavaScript ...” and “APL ⌈” gave me irrelevant results.
Furthermore, how is this
(if a
true-cond
false-cond)
harder to read than this, aside from familiarity?
if (a) {
trueCond
} else {
falseCond
}
In the latter case, the if/else requires a special syntactical structure. And since it cannot be used as an expression, the common desire to conditionally assign a result spawned the ternary operator: a whole separate syntax that only applies when you want to assign a result to something. In lisps, you just use “if” wherever you need a binary conditional.
Return the maximum value of the array “numbers”. The languages are listed in descending order of text > symbol.
Clojure:
JavaScript: APL (I couldn't find how to apply this to an arbitrary array): Here’s a guess: The most aymbol-focused is the least readable to me, and Clojure is the only one that returned good results from a Google search to figure out what was going on. Both “JavaScript ...” and “APL ⌈” gave me irrelevant results.Furthermore, how is this
harder to read than this, aside from familiarity? In the latter case, the if/else requires a special syntactical structure. And since it cannot be used as an expression, the common desire to conditionally assign a result spawned the ternary operator: a whole separate syntax that only applies when you want to assign a result to something. In lisps, you just use “if” wherever you need a binary conditional.