That is why I used JSX as a counterexample. Basically I'm questioning Elm's choice to stick with the raw dom-creation-function-style vs adopting a JSX equivalent.
That is why I used JSX as a counterexample. Basically I'm questioning Elm's choice to stick with the raw dom-creation-function-style vs adopting a JSX equivalent.
Elm is a functional language, and you build the desired DOM structure with functions. Why should it be any other way?
JSx looks sort of like HTML, but HTML isn't even the target here, just DOM nodes.
Lisp-style 'S-expression' syntax for describing documents never took off. We have to take something from that - it seems the vast majority of developers don't enjoy that syntax, irrelevant of how 'simple' its just-functions nature makes it.
JSX also 'targets DOM nodes', but I don't see what that has to do with anything.
The closer correspondence between how JSX looks, what you see in your browser DevTools, and how it seems that most developers prefer to mentally model documents ... is where the win comes from IMO.
The reality is the vast majority of React code I see uses JSX, even though it's optional. It's been hugely successful in React world and I don't think that should be ignored by Elm.
I love Elm and think it or something very close to it should become way more mainstream, but I do find its bracket-heavy DOM syntax off-putting in comparison.
EDIT: That said, I do agree with the leading commas in laying out models as opposed to the trailing. Scanning the models of an Elm file is far faster than, say, a JS file, subjectively at least.
div []
[ div [] [ button [ onClick Increment ] [ text "+" ] ]
, div [] [ text <| toString model.counter ]
, div [] [ button [ onClick Decrement ] [ text "-" ] ]
]
JSX isn't the only syntax that took off, there are for example indentation based syntaxes for HTML, theoretically: div
div
button onClick: Increment
text "+"
div
text <| toString model.counter
div
button onClick: Decrement
text "-"
already much nicer (and if it was all wrapped in parens it wouldn't make much of a difference).Given that Elm is "just" for making HTML apps, this does seem like something the language should focus on.
It turns out that it's less work to always have delimiters than it will be to have to add them anyways to disambiguate.
Thus, no structural, recursive syntax for document editing has "taken off".
Word processing is still done in Microsoft Word by most of the planet. HTML e-mails are written in some WYSIWYG client program. Web forums use variations on markdown (with raw HTML only as an escape hatch).
People do work with *ML by hand, but largely reluctantly.
If you do have to roll up your sleeves and work with the serialized syntax, you're far better off it its is S-expresions.
> If you do have to roll up your sleeves and work with the serialized syntax, you're far better off it its is S-expresions.
Convince the masses, because they don't seem to agree.