Live data from Hacker News

Thoughts on Svelte

tyhopp.com

131–140 of 194 posts

Re: Thoughts on Svelte

#131
post #27

Earlier quoted context omitted.

I guess my main gripes are not with the libraries for state management themselves, but how managing rendering after state mutations occur. Pinia and Vue/Nuxt just do this effortlessly. Having to deal with hooks and useEffect in React is just a pain... in my opinion.

You shouldn't use useEffect just to bring state mutations from the store into the component or to calculate "view model" from your state. Have a look at the new react docs. https://react.dev/learn/you-might-not-need-an-effect

Not OP but I think this is exactly the point. With Vue/Pinia it just works as expected without having to think about these things.

Re: Thoughts on Svelte

#132
post #58

Earlier quoted context omitted.

Is xstate something like redux or mobx?

it's like a much more structured, and observable version of redux. observable in the sense that not only can you tell what has happened, you can also tell (and visualise) what can happen next

Yeah, the first time you realise you can set the disabled state of a button using `state.can('submit')` it feels like magic!

Re: Thoughts on Svelte

#133

I used Vue in the past and decided to use Svelte early this year, I do not need SEO or anything SSR, just the original SPA with CSR. then I found out Sveltekit is really a SSR-first design, and Svelte itself has no client side routing etc. While Vercel sells Sveltekit(and Next.js) to be CSR ready, I don't buy it, I don't need the complexity of SSR in the code when I just need a clean CSR, however you paint the SSR-is…

This is a pretty bizarre comment, given svelte isn’t intended to be a web framework and sveltekit makes it extremely simple to do client side rendering.

"extremely simple"? I disagree. I had to read its document and most of them are unrelated to CSR, why do I need to do that? the kit by design is absolutely SSR-first, it does let you tweak for CSR, but I don't need that complexity, not at all.

If Svelte provides a built-in client side router, and do not try to point everyone who wants to use Svelte to Sveltekit, I may reconsider, for now, Svelte is no longer in my projects.

Re: Thoughts on Svelte

#134

Earlier quoted context omitted.

> what if you only want to perform a side effect when a particular value changes? https://react.dev/reference/react/useEffect That is literally what useEffect is for! Describe your side effect, provide a list of values that you want the hook to watch for when they change. `useEffect(someEffect, [value1, value2, value3])` > the very natural, and often inevitable, concept of side effects React uses a functional program…

> That is literally what useEffect is for! No, sorry; for useEffect to fire, a prop or a state needs to change; which means that the component is going to re-render. My point is that sometimes we want to observe properties passed to the component for side-effect purposes without re-rendering the component. > Functional programmers believe in minimizing side effects. In order to do something — anything — in the real w…

Sounds like the prop shouldn't be getting passed to the component then if the component isn't using it to render itself? Maybe it should be getting sent straight to your "store" perhaps? Let the components take care of the rendering, let your "store"/"state machine"/whatever take care of the side effects.

Re: Thoughts on Svelte

#135
post #26

I switched my game's UI from Vue2 to Svelte maybe a year ago, and I agree with almost all of the article. One thing I think the author overlooks: the appeal of Svelte's built-in animations and transitions is that they work correctly when the element's lifecycle is being managed by Svelte. E.g. with code like this: {#if showFoo} Foo! {/if} When `showFoo` changes to false, Svelte will first play a flyout transition and…

Did you _need_ to switch your games UI to Svelte because Vue2 really wasn't good enough for you needs, or did you just want to learn Svelte?

Re: Thoughts on Svelte

#136
post #27

Earlier quoted context omitted.

You shouldn't use useEffect just to bring state mutations from the store into the component or to calculate "view model" from your state. Have a look at the new react docs. https://react.dev/learn/you-might-not-need-an-effect

But then again, you might need an effect. The behind the scenes (or behind the hooks) complexity that react adds in order to the make DOM thing work then makes it difficult when you do need an effect. Things like WebRTC or sockets or some such. useRef? useState? I have found this to be extremely difficult. If someone knows a good resource for doing things like this in React (and not a one page file, but with multiple…

I'd say pull that logic out of your components and put it in some central place like an XState machine exposed to your components through Context.

Re: Thoughts on Svelte

#137
post #15

> I'd use it again for personal projects, maybe not for large company projects if I was the architect. Questions about large projects always arise when talking about Svelte. Did you / would you use it and why not? I would certainly NOT suggest using Svelte on enterprise projects. Why not? Because other people don’t do it, and that means that it is very likely that there are no (not many anyway ) experienced Svelte de…

With all due respect, the majority of large React projects I've encountered devolved into non-uniform big balls of mud that only the original authors can (sometimes) understand. React's "non-opinionated" stance constantly leads to a non-opinionated code base without a strong technical lead with a very firm hand.

When talking about other frameworks (sorry, "libraries"), React folks should really avoid throwing stones from their glass house.

I'm not fan of Angular by any means, but I totally respect how opinionated it is and how that translates out to development teams in the wild.

Re: Thoughts on Svelte

#138
Last year I wrote a comparison between Sveltekit and React with focus on Typescript and Graphql. What I didn't like particularly was that for-loops had no type inference [1]. Until this changes there is no reason for me to use Sveltekit in big projects. Typesafety is very important and nothing beats react on that.

[1]: https://www.nvegater.info/blog/SvelteKit#bad

Re: Thoughts on Svelte

#139
post #92
post #15

> I'd use it again for personal projects, maybe not for large company projects if I was the architect. Questions about large projects always arise when talking about Svelte. Did you / would you use it and why not? I would certainly NOT suggest using Svelte on enterprise projects. Why not? Because other people don’t do it, and that means that it is very likely that there are no (not many anyway ) experienced Svelte de…

> React and Angular are safe bets in THAT space. But they weren't always. And a lot of people that 'know' React don't feel entirety comfortable using React because of complexity - ever seen someone want to know how to store a variable and watched the life drain out their eyes as they read a Dan Abramov essay on what true reactivity means?

React never was truly reactive. Even according to its devs.

https://legacy.reactjs.org/docs/design-principles.html#sched...

Re: Thoughts on Svelte

#140

Earlier quoted context omitted.

We had the same problem. Svelte would have been perfect if it only had a true SPA router. SvelteKit is too complicated for a simple SPA.

I used https://github.com/EmilTholin/svelte-routing with great success, though it looks like the maintainer has recently stopped maintaining it, and recommending sveltekit. Still, I'd give try, it looks like people are still using it, and perhaps someone else will pick up the burden of maintenance, since there's clearly a ton of demand: https://github.com/EmilTholin/svelte-routing/issues/236

https://github.com/ItalyPaleAle/svelte-spa-router seems good too.

but it's not official, and Svelte project seems careless for client routing, instead it tries to convince everyone use its SSR-first kit, that "can do CSR too", which means you have to carry the whole SSR code base and its documentation into your CSR project totally unnecessarily.

I get it Vercel needs SSR for its business, I don't get it why it keeps selling everyone that "my SSR-first framework is great for CSR SPA too", it is NOT, not at all.

Post reply on HN