3 ms·
It's really no different. Consider this function in Go: func Foo(s string) string { println("hello") } And in Clojure: (defn foo [s] (println s
by tensor 8y ago
It'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?