2 ms·
I think I like Clojure's Hiccup/Reagent a bit better. It gives you a structure that's basically the same as vanilla HTML, but it uses vanilla Clojure data type
by tombert 3y ago
I think I like Clojure's Hiccup/Reagent a bit better. It gives you a structure that's basically the same as vanilla HTML, but it uses vanilla Clojure data types and keywords to do it.
Doing this makes testing trivial, and you also don't need to worry about closing tags as much. As far as I can tell, the compilation is fast enough to where the overhead of translating to HTML doesn't seem to take any amount of time.
Plus I just really like Clojure :)
- cynicalsecurity 3y agoCompilation of HTML. Now this is something.
- tombert 3y agoIs that really any different than JSX? I'm assuming that JSX doesn't just directly do `"<div>" + user.name + "</div>"`. Presumably it maps it to some kind of data structure and eventually compiles that into something that can be rendered.
- bcrosby95 3y agoJSX is compiled into plain old Javascript react code. Or at least it used to, but I don't know if it still does - I don't use react these days: https://legacy.reactjs.org/docs/introducing-jsx.html https://legacy.reactjs.org/docs/introducing-jsx.html
- bcrosby95 3y agoYeah, I really enjoy Hiccup's solution. Writing declarative structures for declarative "code" (html) in a declarative language (Clojure) just makes everything mentally work right for me. Whenever I had to write JSX I have a lot of weird internal "switching" going on in my head.