Live data from Hacker News

Svelte 4

svelte.dev

171–180 of 227 posts

Re: Svelte 4

#171
post #90
post #12

The release was livestreamed on the Svelte youtube: https://www.youtube.com/watch?v=72TIVhRtyWE also > Svelte 4 reduces the Svelte package size by nearly 75% (10.6 MB down to 2.8 MB), which means less waiting on npm install. This improvement will be especially noticeable for users who are loading our interactive learning experience on learn.svelte.dev for the first time, users of the Svelte REPL, and users with limit…

fun/weird fact - the major release seems to have caused ~9m downloads happening on npm, catapulting Svelte to technically the top of the charts https://twitter.com/SvelteSociety/status/1671923994671603713...

that's just every developer switching every single one of their side projects to svelte in excitement

Re: Svelte 4

#172
post #28

Earlier quoted context omitted.

> 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.

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

Prop drilling in Svelte is exactly the same complexity.

useState() wouldn’t exist because Svelte doesn’t need a virtual DOM and the compiler takes care of reactivity (per the famous React vs Svelte meme).

Stores are way, way simpler than redux reflux whatever else.

Re: Svelte 4

#173
post #4

> Svelte 4 reduces the Svelte package size by nearly 75% (10.6 MB down to 2.8 MB), which means less waiting on npm install. This improvement will be especially noticeable for users who are loading our interactive learning experience on learn.svelte.dev for the first time, users of the Svelte REPL, and users with limited connectivity. The majority of the remaining package size is eslint support, which necessitates dis…

I wonder how much of that came from this TS to JSDoc change Rich Harris talked about here: https://news.ycombinator.com/item?id=35892250 > I _would_ say that this will result in no changes that are observable to users of the framework, but that's not quite true — it will result in smaller packages (no need to ship giant sourcemaps etc), and you'll be able to e.g. debug the framework by cmd-clicking on functions you i…

A lot! Sourcemaps are often twice the size of the code itself.

Re: Svelte 4

#174
post #40

Earlier quoted context omitted.

> I keep hearing about Svelte's flavor of JS basically being its own language now and it not playing all that well with Typescript it's a weird habit on HN to refer to random rumours that have discouraged you from trying something, and then explicitly not link to even the source of the random thing you're thinking of. I would guess you're misremembering something about the *developers of Svelte* saying they didn't th…

But Svelte obviously doesn't play well with TypeScript, and is kind of its own language - you don't need a source for that. Good luck e.g. getting reactive declarations to play well with TS's type narrowing or null analysis.

I literally hack on TS 5 on Svelte all day and have for a year now (was 4.x originally). Never had a problem with reactive declarations.

Re: Svelte 4

#175
post #172

Earlier quoted context omitted.

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.

> It's really quite simple and elegant. Svelte's model would likely be more complex tbh. Prop drilling in Svelte is exactly the same complexity. useState() wouldn’t exist because Svelte doesn’t need a virtual DOM and the compiler takes care of reactivity (per the famous React vs Svelte meme). Stores are way, way simpler than redux reflux whatever else.

I prefer an explicit function call over compiler voodoo magic, especially when it comes to reactivity (of which can have performance implications). Any solution where a compiler is changing the semantics of my code on the fly is just a hard pass.

Re: Svelte 4

#177
post #172

Earlier quoted context omitted.

> It's really quite simple and elegant. Svelte's model would likely be more complex tbh. Prop drilling in Svelte is exactly the same complexity. useState() wouldn’t exist because Svelte doesn’t need a virtual DOM and the compiler takes care of reactivity (per the famous React vs Svelte meme). Stores are way, way simpler than redux reflux whatever else.

I prefer an explicit function call over compiler voodoo magic, especially when it comes to reactivity (of which can have performance implications). Any solution where a compiler is changing the semantics of my code on the fly is just a hard pass.

Shrug. You’re comparing compiler voodoo with vdom voodoo.

Re: Svelte 4

#178
post #140
post #26

Earlier quoted context omitted.

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 reactive systems to be at least as complicated as React's declarative model. I was glad to move on from Knockout more than a decade ago and Svelte is conceptually the same thing in how they work, but with a different proprietary syntax and a faster renderer. I also don't understand the styling complaint. React devs used "just CSS" for years before some of them started pushing for CSS-in-JS. In fact, SCSS/CSS i…

That N is very large. E.g. here's a page that talks about it: https://github.com/halfnelson/svelte-it-will-scale. I'll note that was done with Svelte 3 and that with Svelte 4 components are at least 10% smaller, so it's actually even better than that. SvelteKit is also very efficient at JS splitting per-route thanks to Vite. It ensures only the JS that is necessary for a page is loaded and you're extremely unlikely to be using anywhere near that many components. Based on the article above, you'd have to have three entire sites worth of components on a single page.

Re: Svelte 4

#179

Earlier quoted context omitted.

It sounds like you have a misunderstanding about SvelteKit. It does have a client side router and you can use SvelteKit as a pure SPA today very easily, all you need is to set `export const ssr = false;` and `export const prerender = false;` in `src/routes/+layout.ts`. Then export with `adapter-static` and you're done. Swing by the official Svelte Discord, we're happy to discuss your questions! https://discord.com/in…

I'm aware of that in fact, it's still far from the "pure" SPA as what React or Vue provides. SSR-first sveltekit is not the same as "pure" CSR SPA, and I do not need read all the SSR oriented doc to figure out how to do a CSR SPA. I spent a few months with Svelte(kit) and eventually returned to React. If ever Svelte does CSR-first SPA with client side builtin router, I will definitely give a second try, until then, R…

You would be hard pressed to find a functional difference between a SvelteKit project compiled with adapter-static and a "Create React App" app. If you have any concrete differences, do share them. They're functionally equivalent (except a SvelteKit project is a lot lighter in JS due to the compiler architecture).

There are unfortunately a lot of misunderstandings around SvelteKit because it is SSR-centric. SvelteKit has probably the best interactive docs of any framework at https://learn.svelte.dev/ and I do encourage everyone to go through them to get the full picture!

Post reply on HN