Also it was very tempting to have JSX compile into literal strings, effectively being a composable variant of tagged template literals with better IDE support, so that <a href={123}/> compiles to a function that returns `<a href="123"></a>`. It would have simplified the conceptual model significantly, and the implementation almost as much.
But because it would still be joining a bunch of strings together, it's literally about the same speed as the current implementation (which just adds the whole tree to a single array and joins it only once), so there's no real gain there.
And we lose script/style/tag hoisting, which is necessary for components to work the way they do, unless the JSX system is hacked in another (less simple) way to allow for it than currently.
Comments
Also it was very tempting to have JSX compile into literal strings, effectively being a composable variant of tagged template literals with better IDE support, so that <a href={123}/> compiles to a function that returns `<a href="123"></a>`. It would have simplified the conceptual model significantly, and the implementation almost as much.
But because it would still be joining a bunch of strings together, it's literally about the same speed as the current implementation (which just adds the whole tree to a single array and joins it only once), so there's no real gain there.
And we lose script/style/tag hoisting, which is necessary for components to work the way they do, unless the JSX system is hacked in another (less simple) way to allow for it than currently.