Live data from Hacker News

Introducing Svelte, and Comparing Svelte with React and Vue (2021)

joshcollinsworth.com

31–40 of 213 posts

Re: Introducing Svelte, and Comparing Svelte with React and Vue (2021)

#31
I'm afraid of switching to Svelte because of what happened to Angular. I switched to Vue because of Angular's 1.x to 2+ upgrade. Then I was faced with the Vue 2 to Vue 3 upgrade, which now has a lot of my code in a state of mess.

Svelte has always looked so promising, just what I wanted. But my fear is that if I ditch Vue and jump to Svelte, it will do the same thing as any other framework did: become a monster and cause problems with all my dependencies.

So I'm staying with Vue.

Re: Introducing Svelte, and Comparing Svelte with React and Vue (2021)

#32
post #23
post #15

Earlier quoted context omitted.

You don’t need to write .value’s everywhere, that’s about all. And Vue is a lot more convenient in other ways.

Do you mean .value when writing a component that's some sort of form field? How do you refer to that value in Svelte components? edit: oh nvm, we haven't upgraded our codebase to Vue 3 yet, there are a lot more ".value"'s if you click through to the Vue 3 examples in the original post.

I'm talking about reactive references in the composition API; the options API is too different from Svelte to make a direct comparison. You can use reactive() to hide some .value's but they are more limited and I personally avoid them. There have been proposals to add more transformations to @vue/compiler-sfc to make refs more "magical" like Svelte.

Re: Introducing Svelte, and Comparing Svelte with React and Vue (2021)

#33
post #16

My 2c: I think svelte is overhyped and a poor solution to the problem it's trying to solve. First of all, I am tired of ridiculous metrics like how small svelte is when it's a really small example, and it's one or two lines of initial boilerplate. The thing that really set svelte apart was it's better syntax and experience when it first came out. I think that was when react class components, and vue 2 was still promi…

Just throwing this out there, but have you considered that React and Vue in fact also have custom non-JS syntax? JSX is not valid JS, parsers had to be written to work with it. And Vue uses templating syntax in HTML, just like Svelte. Svelte doesn't have any non-native syntax in the JS parts, just the templating.

Re: Introducing Svelte, and Comparing Svelte with React and Vue (2021)

#34
post #26
post #23

Earlier quoted context omitted.

Do you mean .value when writing a component that's some sort of form field? How do you refer to that value in Svelte components? edit: oh nvm, we haven't upgraded our codebase to Vue 3 yet, there are a lot more ".value"'s if you click through to the Vue 3 examples in the original post.

Vue has `refs`, which are reactive proxy objects that are used for tracking things like re-rendering. Since vue does not hide the fact that something is a ref, you need to call `myRef.value` to get to the underlying value of `const myRef = ref(10)`. In a new and currently experimental syntax, you can use `const myRef = $ref(10)`, at which point you can just use `myRef` directly. This will then be converted by the Vue…

> In a new and currently experimental syntax, you can use `const myRef = $ref(10)`,

Oh sweet didn't know that. I keep forgetting to type `.value` and debugging it wastes a couple of seconds here and there.

https://vuejs.org/guide/extras/reactivity-transform.html#ref...

Re: Introducing Svelte, and Comparing Svelte with React and Vue (2021)

#35
post #13
post #5

The only thing I don't like about Svelte is the reactive blocks, prefixed with $:. There are a number of gotchas, like updating complex objects, which make things a bit...implicit rather than explicit.

Rule of thumb is: it's fired after assignment of a named variable from the root scope which was mentioned in this reactive block. You can even add a line that just says `myVar;` and the reactive block containing it will be executed on every `myVar = ...`.

Yeah I understand why people find them confusing. They trip me up too, and I write a lot of Svelte. I think it would have been better if Rich had added something like the computed/useEffect style of this concept, but it would have looked very out of place in the rest of Svelte which is probably why he didn't do it.

Re: Introducing Svelte, and Comparing Svelte with React and Vue (2021)

#36
Just one note. The article spends a lot of time talking about how all react returns must be wrapped.....

Dude, just use fragments it's just an empty tag in the jsx compiler and adds like zero effort.

Other than that, seems interesting. Didn't actually function in the embedded browser used in my hn client so that's bad... But overall seems like it's worth a try.

Re: Introducing Svelte, and Comparing Svelte with React and Vue (2021)

#38
post #16

My 2c: I think svelte is overhyped and a poor solution to the problem it's trying to solve. First of all, I am tired of ridiculous metrics like how small svelte is when it's a really small example, and it's one or two lines of initial boilerplate. The thing that really set svelte apart was it's better syntax and experience when it first came out. I think that was when react class components, and vue 2 was still promi…

Just throwing this out there, but have you considered that React and Vue in fact also have custom non-JS syntax? JSX is not valid JS, parsers had to be written to work with it. And Vue uses templating syntax in HTML, just like Svelte. Svelte doesn't have any non-native syntax in the JS parts, just the templating.

Worse than that, Vue has something like three different DSLs under the hood. Some of it JS-like but not fully JS, some of it is custom attributes, some of it is "oh, it's JS, but you have to make very specific objects"

Re: Introducing Svelte, and Comparing Svelte with React and Vue (2021)

#39
post #26

Earlier quoted context omitted.

Vue has `refs`, which are reactive proxy objects that are used for tracking things like re-rendering. Since vue does not hide the fact that something is a ref, you need to call `myRef.value` to get to the underlying value of `const myRef = ref(10)`. In a new and currently experimental syntax, you can use `const myRef = $ref(10)`, at which point you can just use `myRef` directly. This will then be converted by the Vue…

> In a new and currently experimental syntax, you can use `const myRef = $ref(10)`, Oh sweet didn't know that. I keep forgetting to type `.value` and debugging it wastes a couple of seconds here and there. https://vuejs.org/guide/extras/reactivity-transform.html#ref...

Huh, I forgot reactivity transform is already out! Meant to try it but didn't get the chance. Good thing I happen to be starting a new project today.

Re: Introducing Svelte, and Comparing Svelte with React and Vue (2021)

#40
We use Knockout JS extensively in an old codebase and its two way data bindings and computed values depending on those bindings are a mine field. The uni direcional data flow of React in my opinion has been a breakthrough. How have folks found using two way bindings in Svelte (and other frameworks?)
Post reply on HN