Mathematical notation often gets brought up as an example of there being problems with Lisp syntax. I have problems with that. For one, how often do you actually write...
foo := 7 * 3 + 4 - 5;
Instead of:
foo := 20;
Which, in Lisp syntax could be as simple as:
(set! foo 20)
I could see an exception being made for something like:
constant MEMORY := 640 * 1024;
But the Lisp equivalent:
(defconstant! MEMORY
(* 640 1024))
Isn't _THAT_ much worse.
With more complex examples we still see that the difference isn't too terrible, especially as we try to make code more readable. An example of code whose readability is questionable could be:
r := (t - l) / (n - 1) * n;
Which, when we choose names with a little more meaning could become:
Of course, that line is a bit long (just a bit, but I'm not interested in actually going and typing out a very long line), so it could be reformatted to something like:
And yes, indeed, when we start looking outside of mathematics, sometimes a little bit of sugar can even reduce the amount of brackets needed in Lisp syntax beyond the brackets needed in non-Lisp syntax:
Speaking purely of mathematics, writing a function which turns infix syntax into Lisp syntax isn't too daunting anyway, it's even an exercise in good old SICP, so with very little effort we could write a macro to let us do the following:
(set! foo
(infix bar + baz * (quux - zot)))
Or, for the RPN aficionados:
(set! foo
(rpn bar baz quux zot - * +))
Of course this is very much personal opinion, but I would even go as far to say that infix notation isn't even that popular, as we can see with the following examples:
new_student := new Student("Name", points);
new_student := Student new ("Name", points);
if (length(students) > 30) {
error("Too many students in class!", length(students));
} else {
addStudent(new_student, class);
}
(length(students) > 30) if {
"Too many students in class!" error length(students);
} else {
new_student addStudent class;
}
All of that being said and done, I doubt I will change anyone's mind, but I personally really like Lisp syntax (as in good old, double open brackets on the let, Lisp syntax), and I just hope to see arguments which are a little stronger that the old classic 'we learn 1 + 2 in school, not (+ 1 2)'.
I totally agree with you about infix notation actually! I don't find it particularly bad to read (- 3 4) vs (3 - 4) and the first has the benefit of achieving some clarity of what's happening under the hood (- is a function being called with 3 and 4).
The main example for I has in mind was actually data science/analysis where you often chain together data manipulations. I only picked arithmetic functions because it seemed like it made it really clear which functions were being called, without needing any knowledge of clojure/lisp beyond basic s-expr syntax.
With more complex examples we still see that the difference isn't too terrible, especially as we try to make code more readable. An example of code whose readability is questionable could be:
Which, when we choose names with a little more meaning could become: Of course, that line is a bit long (just a bit, but I'm not interested in actually going and typing out a very long line), so it could be reformatted to something like: Which isn't _TOO_ much different from: And in fact, the Lisp syntax could make certain errors more visible, such as when we compare the following two snippets: And yes, indeed, when we start looking outside of mathematics, sometimes a little bit of sugar can even reduce the amount of brackets needed in Lisp syntax beyond the brackets needed in non-Lisp syntax: Speaking purely of mathematics, writing a function which turns infix syntax into Lisp syntax isn't too daunting anyway, it's even an exercise in good old SICP, so with very little effort we could write a macro to let us do the following: Or, for the RPN aficionados: Of course this is very much personal opinion, but I would even go as far to say that infix notation isn't even that popular, as we can see with the following examples: All of that being said and done, I doubt I will change anyone's mind, but I personally really like Lisp syntax (as in good old, double open brackets on the let, Lisp syntax), and I just hope to see arguments which are a little stronger that the old classic 'we learn 1 + 2 in school, not (+ 1 2)'.