5 ms·
Isn’t that what a compiler typically does anyway? I don’t see the challenge here.
by cygned 7y ago
Isn’t that what a compiler typically does anyway? I don’t see the challenge here.
- MatekCopatek 7y agoYou typically write in one language and the compiler produces something lower-level out of it. In this case, you write vanilla JS and get (different) vanilla JS.
- cygned 7y agoI argue that transpilation done by tools like Svelte or Babel is just compilation in a broader sense. I don’t see the seemingly relevant difference here.
- degif 7y agoYou can write and run React/Preact based applications "as is" without using a transpiler like Babel (you just typically do to minify code and use more fancy javascript features). You can't run a Svelte based application without precompiling it using the Svelte compiler.
- ajdegol 7y agoThe essential feature of it is that it’s a compiler. Things in general get easier to debug over time as they get improved, the basic concept is actually a very powerful. I’m a fan of svelte for the small things I’ve tried it on; there’s always growing pains with learning curves.
- degif 7y agoYeah, I do agree. That was not a critic of Svelte, just a comment about that there is a difference between compilation (Svelte) and transpilation (Babel). I do use Svelte in every day job myself and prefer it to React (which is also great) just because writing Svelte "feels" like what Javascript has intended to be.
- kreetx 7y agoYou are not supposed to look at the output code. The only relevant thing is if it does what it's supposed to do.
- bryanrasmussen 7y agosome times, not very often it is true, you need to look at the output to figure out why your code is not doing what it is supposed to do.
- cygned 7y agoAs an example, I'd argue that the output of the Svelte compiler is surprisingly understandable. https://svelte.dev/repl/f104bac93c9c48f5bd18322e3b9b9425?version=3.20.1 https://svelte.dev/repl/f104bac93c9c48f5bd18322e3b9b9425?ver...
- bryanrasmussen 7y agoin comparison to what comes out of some webpack things I've looked at, yes it looks more readable. Offhand I don't agree with all their undefined lets there, but not a big issue either.
- chrismorgan 7y agoAll those undefined lets are part of how Svelte components are constructed, and it can’t be done in any other way across the board. It may not be how you’d write such things manually, but for compiler output it’s sane. For simple cases like that one, the create (c) lifecycle method could essentially be shifted up into the let statements, but for some more complex cases that couldn’t be done, and if hydration is enabled it definitely can’t be done, because those variables can then be filled in one of two ways, creating (c) new nodes or claiming (l) existing nodes.
- tpetry 7y agoAre you kidding? It's at some point understandable when looking a minute at it, but this only a small hello world app. How will you be able to understand the generated code with a few dozen components and much more logic?