JSX is well defined and does not support any of HTML's looseness. It's predictable. It makes the code easier to follow. And if you don't want to use it, you don't have to. I see no issue.
JSX is well defined and does not support any of HTML's looseness. It's predictable. It makes the code easier to follow. And if you don't want to use it, you don't have to. I see no issue.
Nesting dozens of items is fine. That single line was more of an HN comment format limitation. This might be a better judge of readability:
C#
JSX
You may prefer one or the other but most would admit they are pretty similar its just that the former hasn't needed an entire new language inlined into it. Given JSX has all its angle brackets, end tags and escaping expressions with {}, it can actually be more verbose.
> I'm sure there's a law somewhere that says the less abstraction the better, that can be applied in this case
JSX is literally an extra level of abstraction. You are not writing html but calling a function to create a data structure element and JSX totally obfuscates that. I pity poor programming newbies trying to understand what JSX is actually doing "so you are telling me <div> is a function...but?".
In the functional form its just your normal language, nothing is disguised, everyone can see what it is doing and no post-processing magic is required e.g.
public class DOM
{
public static IElement div(object attributes, params IElement[] children)
{
return new Element(...);
}
}You would have to write the transpiler anyway, since on a larger team if you're working with a designer, you would probably get HTML from them and soon get tired of manually translating it to function calls.
I'd bet this is how JSX got started in the first place.
What limitation are you talking about?
var element = DOM.p(
{id : "thing"},
DOM.div(),
DOM.div()
);And yet I'm still in the anti JSX camp. I think it has something to do the gear switching that comes with opening up the mixing of data and logic but I can't articulate it farther than that,
Your brain can only juggle a handful of bits of data at a time. If you see someone doing something that looks like this doesn't apply to them, it's most likely because they've memorized the code. And to memorize code, that means it can't change much or very often. Which makes them dangerous. They have a bias toward maintaining the status quo, no matter how awful it is. Don't be that person.