Live data from Hacker News

Svelte 4

svelte.dev

41–50 of 227 posts

Re: Svelte 4

#41
post #13

Could someone give a one or two sentence explanation of why I would want to use Svelte over something like React? I have heard it is "better", but have never understood why.

[deleted]

Re: Svelte 4

#42
post #15
post #13

Could someone give a one or two sentence explanation of why I would want to use Svelte over something like React? I have heard it is "better", but have never understood why.

Most folks would probably say "it's faster" but I think the real upside of using Svelte is the DX. It's just massively simpler and way easier to be productive.

[deleted]

Re: Svelte 4

#43
post #13

Could someone give a one or two sentence explanation of why I would want to use Svelte over something like React? I have heard it is "better", but have never understood why.

Massive reduction in boilerplate. As someone who attempted to onboard onto both react and svelte for a couple days each, react continued to feel hyper unintuitive with a bunch of magic constructs. Svelte felt like I could guess what would work and it just did. Caveat: since I went react -> svelte it's possible I was just warmed up to JS by that point

It's the opposite for me. React can be verbose but that's because a lot of it is explicit and has escape hatches. Svelte has magic that works until it doesn't and then you're stuck in Svelte land. It's not "just JS" despite people marketing it as such

Re: Svelte 4

#45
post #28
post #23

Earlier quoted context omitted.

Less code as everyone else mentioned, single file components (CSS is inside your .svelte files too, and isolated automatically), and a general feeling of on railsness that React for me lacked. State in Svelte goes in stores. State in react seems to go in one of eighteen different mechanisms, which all begin with a 45 minute video of the author’s opinions about the true nature of reactive programming, when all I want…

> State in Svelte goes in stores. State in react seems to go in one of eighteen different mechanisms, which all begin with a 45 minute video of the author’s opinions about the true nature of reactive programming, when all I want to do is store a string. So... useState? :) Of course then I got to thinking about how I'd answer the question "How can I put make that useState value accessible at different points in the co…

I work on several large react apps that are very data heavy and what I would consider complex. Honestly we just use useState and prop drilling. Most state is stored at optimal position within the hierarchy, so there really aren't that many props being passed down. The only place context is used is for session information.

It's really quite simple and elegant. Svelte's model would likely be more complex tbh.

Re: Svelte 4

#46
Anyone using Svelte with Deno? I see some stuff on github and google about it, but curious if any HN folks have any experience with this.

Re: Svelte 4

#47
Anyone using Svelte with Deno? I see some stuff on github and google about it, but curious if any HN folks have any experience with this.

Re: Svelte 4

#48
post #26
post #13

Could someone give a one or two sentence explanation of why I would want to use Svelte over something like React? I have heard it is "better", but have never understood why.

This is always a personal judgement, but here's my personal list: - I find it so much easier to understand. I don't have to useState/useEffect/whatever, I just assign variables and the component re-renders the relevant parts whenever I assign a new value. - Styling is "just" CSS. No messing around with CSS-in-JS libraries and their various ways of being invoked. The CSS is automatically scoped to your component witho…

> I find it so much easier to understand. I don't have to useState/useEffect/whatever, I just assign variables and the component re-renders the relevant parts whenever I assign a new value.

What's frustrating for me is that I'm so used to thinking in hooks that when I first gave Svelte a try, it didn't click. And I knew that was wrong, lol. The release of Svelte 4 is good timing, I might have a use-case at work for a small project to try it out, so I'm going to give it another shot.

Re: Svelte 4

#49
post #27
post #16

> The number of dependencies in Svelte has been greatly reduced from 61 down to 16 Adore this. Would love to see more JS frameworks reduce their dependency trees.

I understand this thought for external dependencies, but dependencies also includes internal ones, which I don't see a reason to reduce. Modularity and re-usability of individual pieces of code are a good sign for me.

I assume they mean external dependencies when they say that. I'm not sure what the point of the statement would be if it included internal ones.

Re: Svelte 4

#50
post #19

Earlier quoted context omitted.

Svelte tries to improve upon the relatively complex/heavyweight runtime of something like React by shifting as much of that complexity to the build step as possible. It also takes a more "batteries-included" approach compared to React by including some opinionated features like state management, animation, transitions and the like. I haven't dug too deeply into Svelte because last I checked it didn't play particularl…

One of the things released today was dedicated documentation for TypeScript: https://svelte.dev/docs/typescript . The site was also updated today to include a JS/TS toggle so that you can see all the examples written in TypeScript if you prefer it to JS. I'm not sure how long ago you tried or what issues you ran into, but hopefully this will help with getting started with Svelte and TypeScript much more easily.

> The site was also updated today to include a JS/TS toggle so that you can see all the examples written in TypeScript if you prefer it to JS.

Yeah that toggle has been on there for months now actually

Post reply on HN