2 ms·
> JSX is JavaScript JSX is decidedly not JavaScript, it is an extension to JavaScript. > I do not have to learn a new language to iterate over an array. Sinc
by dsego 7y ago
> JSX is JavaScript
JSX is decidedly not JavaScript, it is an extension to JavaScript.
> I do not have to learn a new language to iterate over an array.
Since you have to use map() and can't use a simple for-loop, not sure how knowing the language itself helps or not. Either way, loops and conditional are really the basics, you pick it up in a day or two for any template syntax.
> I can interact with it using whatever JS libraries I prefer.
Fair enough, but this prevents many optimizations because the render method can produce virtually anything.
> JSX components are functions or classes which are trivially composable.
This doesn't mean something else isn't as equally composable. Components are composable, doesn't mean they have to be classes or functions.
> I can type functions and classes with typescript unlike string templates.
What does this have to do with JSX ? I guess this is more valid claim for TSX. In any case, since svelte is a compiler, it should be possible to type-check components as well. And it doesn't even depend on typescript, so you can get the same static checks with vanilla javascript.
- s_y_n_t_a_x 7y ago> JSX is decidedly not JavaScript, it is an extension to JavaScript. No, JSX is JavaScript. You can write it in function calls or JSX, it's just syntactic sugar. > Fair enough, but this prevents many optimizations because the render method can produce virtually anything. No, using a library doesn't mean the function used from the library isn't pure. Yes it could have side-effects, but the point is you aren't restricted. You can use pure functions or anything else. > In any case, since svelte is a compiler, it should be possible to type-check components as well. Yes. But it doesn't, and you get it for free because TSX is just TypeScript. If wishes and buts were candy and nuts...