While it might sound silly and reductionist, it is ostensibly the single hurdle I could never overcome when it came to lisp languages. The majority resides with the fact that it could work without them, so I see it as an ancient artifact.
While it might sound silly and reductionist, it is ostensibly the single hurdle I could never overcome when it came to lisp languages. The majority resides with the fact that it could work without them, so I see it as an ancient artifact.
TL;DR: Once you start programming in Lisp for long enough, you end up loving and embracing the parentheses.
0. They allow for an extremely simple syntax, which in turn allows the source code to easily manipulate source code. No simple syntax, no really easy way to write macros. And macros are one of the most essential keys to Lisp's power. You can argue that, without extremely simple syntax, a Lisp language is not possible.
1. Syntax, being so simple, is extremely easy to learn. Yesterday i explained Lisp's syntax to a friend, in 3 minutes.
2. No need to care for special operator precedence rules. The precedence of operators is obvious by looking at the code.
3. IDEs, like SLIME, can easily traverse the code in many powerful ways. Due to this syntax, the IDEs can "understand" expressions and expressions within expressions. This means that the IDE can 'understand' any part of your code, not just big constructs like functions, methods or classes.
4. IDEs will also easily complete the parentheses for you, and will warn you of a missing parenthesis.
5. It is also dead simple to understand which parenthesis closes which one. It can be done with most source code editors -- Even a simple program like Notepad++ can do it, Visual Studio Code can do it, etc.
6. Parentheses also enable IDEs to automatically apply "pretty" format to the code rather easily.
7. As anything, you get used to it. Many people, for example, think that, in Python, whitespace as a block delimiter is a bad idea, however I never had any problem with that, it was just fine. Unless you are using Windows Notepad to edit code...
Programming in a Lisp is like writing a prose. Your brain is occupied with ideas, you just need to type them down. You don't need to think about structure (until later), it's a flow - you're looking for right words (functions), you can immediately try them out in the REPL, pretty much like a writer would review usage of a word in a thesaurus or a dictionary.
But to be fair I met a few people who claimed that even after months of using a Lisp, they just couldn't get the parentheses. I dunno, guess some people's brains maybe just not suited. You can call it dyslisplexia or whatever.
I almost never have to think about the parentheses while editing, any more than I would braces in a c-like language. It's really freeing. It's also fully integrated into Cursive so there isn't even a setup step if you're using that already.
If you dial back the color of parenthesis and brackets to a lighter grey, the experience is almost like writing python with parinfer.
Another reason Lisp programmers tolerate parentheses hell is that Lisp development has often paralleled that of emacs and emacs-like editors that make manipulating s-expressions extremely intuitive.
var x = fib(a, b);
with (let x (fib a b))
And count the delimiting symbols. I count 5 in the first example. In the second, I see 4.Let's try something a bit harder.
function(a, b) {
return a * b;
}(6, 4);
vs. ((fn (a b)
(* a b)
) 6 4)
10 first, 8 second.Yes, "why all the [symbols]" indeed.
((a, b) => a * b)(6, 4);
...against the Clojure: ((fn [a b] (* a b)) 6 4)
Not a lot in it, really, is there? (#(* %1 %2) 6 4)24
;)
It's a 1-argument function, so applying it to 2 arguments would give an error. Minus the arity error, 1-argument * is an identity.
On the other hand, you can trivially create a macro that would implement the exact es2015 syntax (or at least a very close match), but why would anyone do this?
Heck even Clojure seems to agree, just the simple act of using vectors for various things (ie function parameters) helps with the readability
((fn [a b]
(* a b)
) 6 4)And if I'm frank, the JS examples are easy to read because you're familiar with the syntax. When you first started to learn C style syntax, it was likely just as confusing. I've spent a fair bit of time with lisp now, and the parenthesis are no more or less confusing than any of the symbols used in other languages. They're just scope delimiters.
Fortunately, you can redefine them. Emacs can be customized at will, and using Lisp :)
I have no idea why it hasn't caught on. As far as I'm aware, there's no Clojure implementation. Lispers like their parentheses.
I have done two major (commercial) software projects in Python, with a good amount of code, several months of work, and I've never had ANY kind of problem with the indentation/whitespace.
Any Python IDE (like Pycharm) will easily highlight you where each section of code sits relative to the indentation level, so it's really pretty simple. Really, really simple.
"Elegant weapons... for a more civilized age."
I'm not even a lisper.
Because there is no parenthesis problem; there's a newb problem. The people who complain about parenthesis haven't used a Lisp long enough, that's all. Parens are a feature, not a problem, and everyone eventually figures that out and stops complaining or they move on to a language more suited to them.