Despite Gleidson Henrique’s beautiful response, I’d like to add a few more points based on your questions:
What is Svelte JS? It is another framework to dispute the web component market?
Svelte nay is a framework. Svelte is a compiler who interprets files .svelte
and transcribes in Javascript, which in turn, at runtime, writes the HTML and CSS associated with the currently running component. In addition, Svelte can interpret Javascript and Typescript files as modules and the script syntax of the files .svelte
are virtually identical to the JS standard with some extras.
The way Svelte works, each file .svelte
is a component, whereas in other frameworks, it is possible to have more than one component per input.
If not, what is the relationship between Svelte JS and other frameworks?
For being a compiler that output in HTML, CSS, and JS. It cannot be compared exactly as a framework and has no relation to other JS frameworks. Although, other frameworks can be compiled using Svelte.
What few people know is that this approach is not new, for at least 10 years, there is another project called Haxe. It is a language made on top of a compiler called Neko, written in Ocaml, which also output code native to web and other platforms.
Its function is the same as that of Stencil JS, to "compile" the component for vanilla code?
Practically this, in a generic way, the function of a compiler itself is to interpret a language and transform it into a language that the computer can understand, in this case it just transforms files .svelte
on something browsers can run.
What are the differentials of this tool and what were the needs that stimulated its creation that the other tools do not satisfy?
The difference is that Svelte is a compiler. This allows it to add language features that abstract other features you might do or that other frameworks do. One drawback in this is that because the compiler outputs JS, it limits it to everything you can do in JS.
In my case, I have already done several projects in React and started working with Svelte because it is not a Runtime, to be more productive and mainly because I feel that I am not doing gambiarra.
Svelte can work in a much more natural way with reactive code, transitions and animations, integrates perfectly well with imperative frameworks with D3 and Threejs.
The fact of being a new technology is a disadvantage of Svelte, React, Vue and Angular, are already very widespread and many devs of various teams, feel safe with them, which impacts on the popularity of Svelte.
The team factor is the only point that would make me return to React today, other than that, I can do exactly everything I would do in React, only better, using Svelte.
Nice, but I was a little confused when it came to the DOM speed statement. One thing that made React explode in popularity was to promise to be faster than other libraries by using the virtual DOM. Stating that Svelte is faster because it does not use the virtual DOM seems to be conflicting. You know how he could be faster even using the real DOM?
– Woss
On the home page, under 'No virtual DOM', in the link Learn more, explains just that.
– Gleidson Henrique
But don’t think it would be worth completing the answer with a summary of that, since it seems to be one of his major differences?
– Woss
Okay, I’ll do it later with more time later. But since my answer has already gotten big, I didn’t want to lengthen it further... But again, I say: it’s not that the Virtual DOM is bad, on the contrary it promised to be faster and it really was. But this is compared to the time when it was said! Currently Virtual DOM is still interesting, but Svelte just made a new process to do the same thing, only faster.
– Gleidson Henrique
I found a reply here in the stack that already answers why Virtual DOM is not necessarily faster than manipulating DOM directly. In short: the function of the Virtual DOM is to manipulate the DOM. That is, it is another 'step' in the process until it reaches the Real DOM. If the code that will manipulate the DOM directly is GOOD, it will be faster than Virtual DOM. If the code is pig, Virtual DOM is faster. Svelte generates BOM code to manipulate the DOM, and consequently be faster than Virtual DOM.
– Gleidson Henrique
Hello @Andersoncarloswoss, did you ever see the link I sent about why Virtual DOM is not necessarily faster than manipulating DOM directly? There was some doubt?
– Gleidson Henrique