3 ms·
> - Special syntax for reactivity is not javascript Well, JSX syntax isn't JS either. And hooks semantics is not JS. Learning new syntax is easy but we should
by tuukkah 5y ago
> - Special syntax for reactivity is not javascript
Well, JSX syntax isn't JS either. And hooks semantics is not JS.
Learning new syntax is easy but we should consider how much the new semantics cause mistakes and to what extent they are incompatible with tools such as linters.
- brundolf 5y agoAs I see it, the main issue with new syntaxes is the fact that they break compatibility with existing tooling. JSX is not fundamentally different in this regard, except for the fact that it gained so much mindshare that it brute-forced its way to getting first-class support in editors, language servers, different frameworks, even TypeScript. I don't predict that very many new JS-adjacent syntaxes will get that treatment from the industry.
- tuukkah 5y agoTrue, although Svelte's syntax is chosen cleverly in a way that is not incompatible with existing tooling. (Starting a statement with $: is syntactically legal JS and a no-op.) Another question is how much of Vercel's resources would it take to contribute Svelte support into all the major tools.
- brundolf 5y agoIt's not technically incompatible, but it's mostly parseable nonsense in the plain language. So it really only serves to make sure syntax highlighters still work, which is just one of many aspects of tooling Considering JSX's current level of support involved cooperation from multiple FAAMNGs, I doubt Vercel could match it
- tuukkah 5y agoCan you give an example of tooling that is not compatible with encountering the $: label? I can only think of a linter complaining about an unused label "$" or a redefined label "$". Compare this e.g. with how React linting has to know which functions are actually (custom) hooks, and they cannot have any idea about the semantics of custom hooks.
- brundolf 5y agoI'm sure it will let you make that label, but it won't be able to make any sense of it. Maybe I was slightly wrong that only syntax highlighting will be helped by the "standard" syntax, but the point remains that none of the (existing) tooling can properly make sense of those parts of the code. That $ isn't really a label, it's a reaction, which your linter knows nothing about and can't help you with; at best it can "work around" it.