News for hackers. Stuff that matters.
Re:Svelte Is Unappealing by ng12 on Tuesday March 24, 2020 @03:40AM (#22672855)
But it's still the code you wrote, it just executes using the React runtime. Svelte actually rewrites your code to inject the Svelte boilerplate to get it working.
Re:Svelte Is Unappealing by cygned on Tuesday March 24, 2020 @03:47AM (#22672875)
Isn’t that what a compiler typically does anyway? I don’t see the challenge here.
Re:Svelte Is Unappealing by MatekCopatek on Tuesday March 24, 2020 @03:58AM (#22672921)
You 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.
Re:Svelte Is Unappealing by cygned on Tuesday March 24, 2020 @04:04AM (#22672941)
I 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.
Re:Svelte Is Unappealing by degif on Tuesday March 24, 2020 @04:13AM (#22672977)
You 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.
Re:Svelte Is Unappealing by ajdegol on Tuesday March 24, 2020 @04:44AM (#22673112)
The 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.
Re:Svelte Is Unappealing by degif on Tuesday March 24, 2020 @06:05AM (#22673442)
Yeah, 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.
Re:Svelte Is Unappealing by kreetx on Tuesday March 24, 2020 @04:12AM (#22672970)
You are not supposed to look at the output code. The only relevant thing is if it does what it's supposed to do.
Re:Svelte Is Unappealing by bryanrasmussen on Tuesday March 24, 2020 @05:15AM (#22673225)
some 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.
Re:Svelte Is Unappealing by cygned on Tuesday March 24, 2020 @05:20AM (#22673249)
As an example, I'd argue that the output of the Svelte compiler is surprisingly understandable.

https://svelte.dev/repl/f104bac93c9c48f5bd18322e3b9b9425?ver...

Re:Svelte Is Unappealing by tpetry on Tuesday March 24, 2020 @05:43AM (#22673329)
Are 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?
Re:Svelte Is Unappealing by jbergens on Wednesday March 25, 2020 @03:21AM (#22682617)
Great demo, even though I don't agree that it is easy to understand.

I have to try a larger program and see what it emits but I don't think junior developers will think it is easy. And trying to find your bugs if you connect things to the wrong component/part might be very hard to spot. I still think React dev tools are way nicer.

Re:Svelte Is Unappealing by bryanrasmussen on Tuesday March 24, 2020 @05:39AM (#22673308)
in 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.
Re:Svelte Is Unappealing by chrismorgan on Tuesday March 24, 2020 @05:51AM (#22673360)
All 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.
Re:Svelte Is Unappealing by kreetx on Tuesday March 24, 2020 @06:22AM (#22673525)
Sure, but are people looking at the artifacts that other frameworks generate? I think generated code is mostly interesting to the framework devs themselves and not to most others.
Re:Svelte Is Unappealing by bryanrasmussen on Tuesday March 24, 2020 @07:05AM (#22673805)
as I said, seldomly, but I did have to spend several days recently looking over webpack output to figure out what was wrong.

Also I remember one time in a previous consulting job a developer who was not very good had used an instruction to not show something if env was prod, but forgotten to end if, which caused module compilations using the horrendous babel/gulp setup to break in the middle of one module but finally start working again in another one, meaning that there were parts of the applications that were trying to refer to a module # 31 or something like that which was no longer present in the big object that was put out of compiled modules. (this is like 3-4 years ago now)

Since it was not showing something if env was prod, if env was dev no problem.

That meant I had to take the output of the prod build and walk through comparing with dev build to figure out what modules were not compiled in, and then figure out from that were the likely error was and then looking in those places with git blame to say what was done wrong.