5 ms·
It's more like an experienced user of a bicycle will not use stabilizer wheels. For any person who can ride a bicycle they look weird, unneccessary and actually
by lispm 4y ago
It's more like an experienced user of a bicycle will not use stabilizer wheels. For any person who can ride a bicycle they look weird, unneccessary and actually hindering them. After a short learning phase few people will need them any more and will be happy to get rid of them.
Lisp has quasi-standard indentation styles. They make code more readable and writable. The differences between Lisp and most other programming languages: Lisp code is written/read/manipulated as a data structure.
What you wrote has also different indentation styles, but dangling parentheses are seen as not helpful: Lisp users don't count parentheses, they don't match parentheses like that, their code is indentation heavy, code can get very long and code can be generated. Lisp macros are an example of generated code. That means Lisp users also might look at generated code, for example when they check the code a macro generates or when one users a Lisp interpreter during debugging. The Lisp interpreter directly executes Lisp source data structures.
Lisp users read by indentation of lists.
The parentheses in Lisp have a different purpose as curly braces in other languages. In Lisp the parentheses are used to denote a data structure: lists. The syntax for lists (or more correct s-expressions) has its own syntax. Programs are written as nested lists of other objects. Thus the programming language Lisp is defined on top of lists. It's possible and not unusual that code is not written to a file, but generated in memory or by typing to a Lisp read-eval-print-loop, where some will directly treat the input as data, not as text.
We we want to write lists as compact as possible and use indentation to make groupings visible, where necessary.
The Lisp programmer learns to write/read/manipulate lists as a base. Programs are then written as lists.
The usual pretty printer shows this:
CL-USER 20 > (pprint '(defun bottles-verse (n)
(flet
((bottles (:match)
((0) "No bottles")
((1) "1 bottle")
((@x) "@x bottles")
))
(put-line foo bar)
)
)
)
(DEFUN BOTTLES-VERSE (N)
(FLET ((BOTTLES (:MATCH)
((0) "No bottles")
((1) "1 bottle")
((@X) "@x bottles")))
(PUT-LINE FOO BAR)))
- xscott 4y agoYou aren't telling me anything I don't already know. > Lisp [...] indentation styles. They make code more readable and writable. This is a matter of opinion, and you're free to ignore the majority or programmers who don't like Lisp. Trust me though: there are a lot of smart programmers who reject Lisp, and it's not because they "just haven't learned to ride a bike" yet. My only question is whether the people who don't like Lisp dislike it because of parens (which is the conventional wisdom) or because of the arbitrary indentation and closing brace style.
- kazinator 4y ago> This is a matter of opinion But, it turns out, it basically isn't. In the Lisp world there is a tremendous consensus about it; nearly everyone does it in nearly an identical way to everyone else. This is in stark contrast to the way, say, C or C++ people lock horns over formatting. Even if you might not like the particular way it is done, the dogged consistency has to count for something. > arbitrary indentation and closing brace style. Lispm demonstrated how this style is reproduced by a Lisp system's printer. It's codified into a documented algorithm, and one that isn't hugely complicated.
- xscott 4y ago> But, it turns out, it basically isn't. In the Lisp world there is a tremendous consensus about it; nearly everyone does it in nearly an identical way to everyone else. Yes, and that's self selecting. If someone hates that style, that might be one reason they don't stick around in the Lisp world. Besides, something being a consensus has little to say about whether it's an opinion or not. > Even if you might not like the particular way it is done, the dogged consistency has to count for something. Lol, no! Just like consensus, consistency isn't a virtue on its own. You could be consistently doing it wrong. :-)
- lispm 4y ago>Yes, and that's self selecting. No, people could just use their style. We've seen that in some subgroups. Often for example with AutoCAD users scripting in AutoLisp / VisualLisp. > consistency isn't a virtue on its own. You could be consistently doing it wrong. :-) Consistency is a virtue on its own. Consistent coding standards improve readability for a wider group, even if the coding standard would be slightly less optimal according to some other metrics.