3 ms·
> There are actually fewer parentheses in Clojurescript than in the similar code in JS+JSX. Side by side sample or it didn't happen. (EDIT: see below) I would
by dragonwriter 7y ago
> There are actually fewer parentheses in Clojurescript than in the similar code in JS+JSX.
Side by side sample or it didn't happen. (EDIT: see below) I would imagine ClojureScript has more parens in the narrow sense, but I can imagine it being "morally correct" if one considers angle brackets, curly braces, square brackets, and parentheses per se as "morally equivalent".
EDIT: so, I found https://www.toptal.com/clojure/clojurescript-tutorial-react-front-end https://www.toptal.com/clojure/clojurescript-tutorial-react-... which has this simple example:
(defn component
[]
[:div
"Hello, world!"])
vs.
function component() {
return (
<div>
"Hello, world!"
</div>
);
}
the JS has two pairs of parens in the strict sense vs. one pair in the ClojureScript, and 5 pairs of balanced delimiters vs. 3 for the ClojureScript, and the JS doesn't minimize parens (but is idiomatic, so it better represents realistic code than minimizing parens would.) So, yeah, while this is a dirt simple example, it does demonstrate that it can be the true.
- iLemming 7y agoIn addition to that: - Clojurescript code is easier to edit, e.g: if you want to wrap the string in <h1> tag there's a lot less typing you have to do. - Cljs code is also "data", it can be send over the network without any modifications or encoding, sent to the REPL for evaluation, etc. - You can "eval" every single part of it: "Hello, world!" string; [:div "Hello, world!"] vector; component function itself - these are all valid Clojure structures. What happens if you copy-paste any part of the JSX into JS REPL?