4 ms·
the parens seems pretty necessary for that expression, I can't even tell what it's doing... it's joining the vector 1,2,3 with a space to make "1 2 3 ", right?
by cp9 11y ago
the parens seems pretty necessary for that expression, I can't even tell what it's doing...
it's joining the vector 1,2,3 with a space to make "1 2 3 ", right? so what is that count doing there? I'm not saying that lists are the end all be all of syntax (clojure has vectors for a lot of things specifically to reduce the parens), but you need something there to make it clearer
- aaron-lebo 11y agoI could have explained the syntax. If you are familiar with Python, it more or less is equivalent to something like: " ".join([1, 2, 3]).count().println() Which, imo, reads much better than: (println (count (join " " [1 2 3]))) Of course, Clojure has the threading macro, but this language emphasizes it.
- kazinator 11y agoOr, rather, maybe it will read better, about a generation after the first crop of high schoolers start being taught f(x).sin().log() instead of log(sin(f(x))).
- aaron-lebo 11y agoI get what you are saying, but when you are talking about programming languages as opposed to math or another domain, more people are familiar or comfortable with the former, hence the reason for numerous posts like the original having to explain why lisp's syntax is a good thing.
- kazinator 11y agoPosts explaining why Lisp's syntax is a good thing have to deal with moving the left parenthesis to include the function: log(sin(f(x)))) -> (log (sin (f x))) They don't have to evangelize function composition being indicated by nesting.
- Someone 11y agoThat should be x.f().sin().log() and that is exactly what they type on their calculators: [3] [1/x] [sin] [log] (either that, or I am getting old. Modern graphing calculators may have different input modes)
- codygman 11y agoClojure is weakly typed? That python won't work since it is strongly typed.
- aaron-lebo 11y agoKey word being like. That syntax works in Ruby, Python, or JS with the right methods defined.