Wrt $subj, Lua has even better thing - Lua table, which can hold both kv-pairs and indexed items. With function environments that could allow something like:
function comp:render()
return div {
class = "foo",
input {
type = "text",
disabled = true,
value = self.value,
}
}
end
That’s what Lua was made for. Idk why I would “<choose><jsx></jsx></choose>” over “choose { lua }”.React was made for web developers. Most web developers know HTML already. Many of them probably know Lua too, but not as widespread as HTML-knowledge.
JSX is basically HTML in JavaScript, so it's easy because it's familiar. The reason for JSX is to make DOM creation in JS more like DOM creation in HTML.
That said, historically lisps are the most featureful runtime-wise. It’s a real shame we hide behind our complexity but collectively chicken out before really powerful concepts lisps introduced.
I'm just explaining to someone why people chose JSX in favor of X, when they come from a HTML/CSS/JS background.
So, in `div`, `class` is a property, but `input` that immediately follows is a child of the component
It's a similar issue as CSS nesting, by the way :) I'm not saying it's inherently bad, it's just it could be confusing. But could probably solved by a linter: put attributes at the top, nested children at the bottom
To me JSX and hyperscript are both about the same thing. JSX gets compiled to a bunch of createElement calls that looks just like hyperscript. I prefer the look of JSX over hyperscript.
div {…}
Comp {…}
Ns.Comp {…}