News for hackers. Stuff that matters.
Re:Maud: A Rust macro for writing HTML by nikonikoniko on Tuesday June 07, 2022 @05:08AM (#31651655)
I find that very interesting, I have the opposite reaction to JSX. Not wanting to use it has been one of the biggest reasons I have moved into using ClojureScript/Hiccup for front-end applications.

I find JSX extremely hard to read and work with and reason about.

Re:Maud: A Rust macro for writing HTML by capableweb on Tuesday June 07, 2022 @05:21AM (#31651734)
After you get a taste of the free world of hiccup/reagent where it's just vectors and maps to create HTML, its really hard to imagine going back to anything else. Being able to use the same programming language in your "HTML template" (which are just core data structures in a specific shape) as for the rest of your programming is just icing on the top.

Small example for people to understand the difference:

    // HTML & JSX
    <div id="person">
      <h1>Niko</h1>
    </div>
    
    // Hiccup
    [:div#person
      [:h1 "Niko"]]
Re:Maud: A Rust macro for writing HTML by dgb23 on Tuesday June 07, 2022 @06:13AM (#31652056)
I think the big differences don’t come out visually.

In JSX you might be struggling with expressing certain things, because JS has a statement expression syntax. So you have to circumvent that. In Clojure everything is an expression already.

In JSX you can manipulate components with HoCs. In Clojure it’s just data, no special ceremony needed.

On the client, if you’re using React, you might use hooks to keep travk of state, which are a special construct that don’t exist in JS. In Clojure, if you use something like reagent, you just use atoms, they have a special purpose implementation, but they look and feel like regular old atoms.

However I have to say, JSX and React are very productive even with those limitations, simply because the tooling around it is so good.

Re:Maud: A Rust macro for writing HTML by nicoburns on Tuesday June 07, 2022 @08:06AM (#31652929)
Hopefully the limitations around expressions in JS will go away at some point and JS will become properly expression orientated. There are already proposals for this, although they currently seem to be stalled.