Syntax sugar is a sweet way to say "This code is not giving any extra business value".
For example, JSX is for to write the DOM, so instead of writing the dom, we write the JSX that writes the DOM. What is the extra value?. Fast reading the dom?. We could do it with variables. Fast writing the dom? Well, all of them write the DOM but JSX adds a new layer so it's slow.
I didn't think about the performance tradeoff JSX might introduce. I don't have a huge understanding of React (attempted to learn twice while working fulltime and turned to vue eventually. Heard of its virtual DOM).Did you mean it is slower than other frameworks or... than writing the same thing in JS itself?
The concept of virtual dom is cool. However, it is not really usable for every single application.
For example, let's say a classic web: HTML + JQuery. I draw the HTML (that is fast) then I call JQuery to modify the DOM. If the changes are minor, then modifying the DOM directly is quite fast, for example reading field of a form.
The alternative is to create a JSX and to use React to render the HTML (so the browser is doing an extra job). And, if we want to modify the dom, then we access the virtual dom. This virtual dom accesses to the dom, so we are adding a new layer again.
JSX shines when we need to modify intensively the DOM.
No, I don't think you can say syntactic sugar doesn't give any business value.
Can you write the shorter form more quickly and maintain it easier? There's your business value.
We're a place where coders share, stay up-to-date and grow their careers.
We strive for transparency and don't collect excess data.