I really do not understand the appeal of Svelte, it seems to be making all the same horrendous mistakes as Vue (bad templating/DSL that shoehorns control flow and bindings into DOM representation, esoteric lifecycle hooks etc) and the only advantage it clearly has over other frameworks that I can see is simple components can generally be written more concisely. Are there actually any tangible benefits to using it ove…
Comparing Svelte and React
201–210 of 338 posts
Re: Comparing Svelte and React
#202I'm a big fan of Svelte. I've raved about their documentation before, but it bears repeating: this should be the gold standard. You can read it all in a day. There are examples to follow right next to the documentation. Svelte is both succinct and powerful. I find this in contrast to React which is often baffling and incoherent. I say this as someone that has used React professionally for 6 years. They've changed the…
I think many people adopted React because Facebook was behind it, and using it in production, the ecosystem is huge, there is a react- package for everything you can image, there is also react-native, I don't like it, but there it is, you can reuse the knowledge to build native mobile apps. Now Svelte, I haven't been following, but I think the creators are working in what's going to be next and even better framework[…
Re: Comparing Svelte and React
#203I'm a big fan of Svelte. I've raved about their documentation before, but it bears repeating: this should be the gold standard. You can read it all in a day. There are examples to follow right next to the documentation. Svelte is both succinct and powerful. I find this in contrast to React which is often baffling and incoherent. I say this as someone that has used React professionally for 6 years. They've changed the…
Re: Comparing Svelte and React
#204Earlier quoted context omitted.
Please don't. It looks awful. And I think it's not necessary. Typescript should inherit it's type depending on what you are passing into "users".
I assume you don’t like invocation? That’s not the point here. In svelte you can’t* define type variable that’s bound to the same type in whole component. I can’t enforce that properties `items` is `T[]` and `selectedItem` is `T`. * Last time I checked. I could be wrong now.
See my example here: https://codesandbox.io/s/clever-neumann-89tnx?file=/src/App....
Re: Comparing Svelte and React
#205Earlier quoted context omitted.
Please don't. It looks awful. And I think it's not necessary. Typescript should inherit it's type depending on what you are passing into "users".
There are valid reason to do that. Like a component that takes render function and item that is passed into it that can be anything.
See my example here at line 26: https://codesandbox.io/s/clever-neumann-89tnx?file=/src/App....
Typescript will inherit the type automatically.
Re: Comparing Svelte and React
#206I'm a big fan of Svelte. I've raved about their documentation before, but it bears repeating: this should be the gold standard. You can read it all in a day. There are examples to follow right next to the documentation. Svelte is both succinct and powerful. I find this in contrast to React which is often baffling and incoherent. I say this as someone that has used React professionally for 6 years. They've changed the…
Re: Comparing Svelte and React
#207How's unit testing in Svelte today? That's the main worry I have with template-based systems (well, that and TypeScript support, but I hear that that's quite OK now).
There’s svelte-testing-library [0] which follows the same approach as the React flavor. It emphasizes testing the app “as the user would use it”, which boils down to rendering components and inspecting the DOM. They intentionally don’t give you visibility into the internal state of the component, which can be weird to get used to if you’re used to doing things like “click the button; assert that state isClicked becam…
Re: Comparing Svelte and React
#208How's unit testing in Svelte today? That's the main worry I have with template-based systems (well, that and TypeScript support, but I hear that that's quite OK now).
It's not great as other people have mentioned. But I think storybook is a good middle ground for testing (it might be a stretch for others to see it that way) and Svelte has awesome support for storybook.
Re: Comparing Svelte and React
#209Earlier quoted context omitted.
When it comes to primitives you can only pass by value, but with objects and arrays you can only pass by reference . And this applies to comparisons too: when comparing objects or arrays you are comparing by reference , not deeply by their inner values. If you want to compare them deeply you have to take some additional steps to make that possible, and all of the different strategies for doing so have different trade…
You don't pass by reference in JS. You pass references by value. Passing by reference has a well defined meaning in computer language terminology. It means passing something that references the variable outside the function. Something you can't do in JavaScript void someFunc(ref int v) { v = 456; } var foo = 123; someFunc(foo); write(foo); // output 456 Above we are not passing 123 (the value of foo) into someFumc, w…
Having spent my career in languages with pass by reference it feels unnatural not to have it. I suspect if I started with JS this wouldn't be such a problem.
Re: Comparing Svelte and React
#210Earlier quoted context omitted.
How is Svelte "just JavaScript" when it uses custom templates and file types?
I feel like this "just javascript" trope really needs to die. JSX is not "Just Javascript", and magically reactive `foo = bar` assigments are not "Just Javascript". But frankly, that doesn't really matter one bit anyways; it's fairly nitpicky to object to different control flow syntaxes, when at the end of the day you're just rendering data from a request to screen. I'm sure not many people would be willing to argue…
It's very thin syntactic sugar over a function call. It has a very simple 1:1 mapping to the output code, as opposed to "magically reactive `foo = bar`.
> I'm sure not many people would be willing to argue that throwing promises (as react suspense supposedly does) is a holy grail of frontend development, even though it is "just javascript".
I'll give you that hooks and suspense are straying further from normal js because they don't behave like normal functions do and have special rules for being called; hooks are a DSL for encoding incremental computations into js, and suspense is just the react team fawning over algebraic effects/delimited continuations and trying to reproduce them in js.
But then again, all of these can be defined in normal JS code as opposed to a DSL which compiles to who knows what, so all the rules applying to normal JS and its tooling apply to them.