4 ms·
> Even after a short while, you'll find these brackets seem to become automatic and mentally disappear Is this really true? It's by far the most off-putting th
by zmmmmm 8y ago
> Even after a short while, you'll find these brackets seem to become automatic and mentally disappear
Is this really true? It's by far the most off-putting thing about Lisp dialects to me. Trying to get nested parentheses to match is extremely tedious when I have to do it in non-Lisp languages. It seems horrific if my whole programming experience is one long exercise in "why doesn't this bracket match!?!?!!". I know it can't be this bad because too many people have no problem with it, but it's the only thing I can think when I see some Lisp source code with 50 nested parentheses ...
- TeMPOraL 8y ago> Is this really true? Yes. There comes a moment in which you suddenly stop minding parentheses. For me it was when I started reading SICP and doing its exercises on paper. After writing a couple Lisp expressions by hand, something clicked in my brain, and since then I don't need to count parentheses anymore. I strongly suspect following the Lisp style of indentation and placing parens (closing parens go together, instead of one per line like in Algol-derived languages) is vital to achieving that.
- jwdunne 8y agoThis was my experience too. I also found The Little Schemer, ANSI Common Lisp and Practical Common Lisp useful books. Also using Emacs for a while helps since you have to work with Lisp eventually, especially if something goes wrong (and there's a lot of packages that'll take contributions if you end up using and fixing those too).
- narwally 8y agoI think it's just an exposure thing, it takes time to adjust to if you're not used to it, but after a certain amount of time the parens fade into background noise. The hardest part is having to learn a tool like Paredit to intelligently restructure lisp code, but tools like Parinfer are making that transition easier. After working with mostly Python and Clojure since 2015, I now have a similar gut reaction to curly brace languages that most people have to lisps. I find ClojureScript much more readable and aesthetically pleasing than Javascript.
- pixelperfect 8y agoAfter a while the parens became something I enjoy having. I like being able to structurally edit code, and comment out paren expressions by prepending them with '#_', I feel like I can edit Clojure code much faster than JavaScript code.
- TeMPOraL 8y agoI have the same feeling. After spending a couple years writing Lisp code (CL and Clojure), the "normal" Algol-like syntax now feels unwieldy.
- zmmmmm 8y ago> I strongly suspect following the Lisp style of indentation and placing parens Definitely - I have started writing JavaScript braces for nested callbacks in that style as well because it makes much more sense.
- mr_custard 8y agoYes, it's true. Only takes a few days. I understand why people are disturbed when they first see a Lisp; but really, truly, honestly: It's a total non issue. I never think about it and I use Clojure every day. It's the same as getting used to any other language syntax.
- zmmmmm 8y agothanks! good to hear :-) I will definitely have to take the deep dive one day into one of these modern Lisp variants.
- rorygibson 8y agoMost editors have a plugin for "paredit" mode that auto-balances the parens for you. (And code with 50 nested levels of parens is Bad Code, just like too much nesting in a C-like language)
- narwally 8y agoParinfer is also really nice. It rearranges your parens automatically based off of your indentation. I still prefer something like Paredit, or Smartparens for the power user features, but Parinfer is really intuitive and just works without having to learn new editing commands or hotkeys. It's my go-to recommendation now for people coming to lisp for the first time because it makes working with lisp code very similar to working with an indentation-based syntax like Python. https://shaunlebron.github.io/parinfer/ https://shaunlebron.github.io/parinfer/
- pmoriarty 8y agoYou don't even have to think about parenthesis matching when your editor does it for you. When using Emacs, the editor can ensure the parenthesis always match. It can also show you which parenthesis match, and if you insist on allowing having non-matching parenthesis, it can show you exactly where they don't match. So even in that case you don't have to worry about it because the editor will point it out to you. Parenthesis are probably the most trivial and unimportant thing about Lisp, and people get way too hung up about them. What's far more important is the power that Lisp gives you, how easy it is to program what you want in it, and how elegant and easy to understand the solutions you come up with are. Instead of having some kind of spaghetti code monstrosity full of ridiculous boilerplate as you would in other languages, you could have a nice and simple solution in Lisp. Isn't that worth allowing some extra parenthesis in to your code?
- tensor 8y agoIt's really no different. Consider this function in Go: func Foo(s string) string { println("hello") } And in Clojure: (defn foo [s] (println s)) The Go code has two () pairs and one {} pair. The Clojure has two () pairs and one [] pair. There aren't more overall parenthesis, they are just in a different place. Any decent editor will catch missing parens just as they would missing braces in other languages. There are some cases where you do get a few more parens, e.g. with mathematical operators, but overall it's not that different, it's almost completely user perception.
- pmoriarty 8y agoHonestly, I wish Clojure had more parenthesis. As a Lisp fan, square brakets make me grrr. I don't want to have to think about which delimiter I need where. Knowing that it's always going to be a parenthesis makes my life so much easier.
- narwally 8y agoThat's true for writing code, but I think the man benefit is when you're reading it. Parenthesis tell me that there is a function application occurring, and square brackets tell be that bindings are being initialized. Then parenthesis, square brackets, and curly braces help me easily find lists, vectors, maps, and sets just from a quick visual scan of the code. Clojure also does a nice job of eliminating unnecessary parens, such as the ones surrounding pairs in a let binding. So instead of this: (let ((x 1) (y 2)) (+ x y)) In Clojure, it becomes: (let [x 1 y 2] (+ x y))
- pmoriarty 8y agoI don't think I've ever been confused as to which were the bindings in a let block. It's obvious from the indentation and the parenthesis. Granted, it's a bit easier to pick them out with square brackets, but for my taste I'd rather just have homegenous delimiters everywhere.
- kbp 8y ago> Then parenthesis, square brackets, and curly braces help me easily find lists, vectors, maps, and sets just from a quick visual scan of the code. How often do you want to do that? Wouldn't you be more interested in what the variable is called or who it's passed to?
- axle_512 8y agoYou don’t see them in the same sense you don’t see multiple closing braces in java or c. The style in lisp is to keep all the closing paren on the same line: )))) But in java or C you’ll sometimes see a function that ends like: } } } } (Hmm my newlines didn’t cone thru on those braces) Not exactly apples to apples comparison, but it illustrates how you can start to unsee those parens.
- profalseidol 8y agoIn a decades old java code base where so many has touched the code. It can look like this: } } } } } } } }
- invalidOrTaken 8y agoBelieve it or not, it's easier in lisps, because the uniform syntax enables more aggressive tooling. I have more trouble with paren-matching in, say, js, than I do in clojure.
- Matthias247 8y agoInstall a rainbow brackets plugin for your editor if available. That mostly solved the paren matching Problem for me in all languages