Live data from Hacker News

Svelte 4

svelte.dev

161–170 of 227 posts

Re: Svelte 4

#161

Curious as to people’s experience with Svelte (or SvelteKit) for making so-called “native” apps via Electron/Taurus/etc? (I believe the new 1Password app is powered by Svelte.)

We did a pretty big one, integrated with a python/gtk app [yikes]. Anyways, svelte is a joy to work with, also on the note of libraries, svelte's community is smaller but I found by far my favourite component system I've ever used - https://carbon-components-svelte.onrender.com/.. surprising coming from IBM, but hey, I'll take it.

But in general electron was a pain, slow builds - had an adhoc solution for the svelte dev server, but its not great.

Re: Svelte 4

#162
post #158

Earlier quoted context omitted.

As I said most of this is subjective so I won’t disagree but: > copying similar code over and over This isn’t true. Svelte is more than capable of reusing code internally.

What code does Svelte use internally vs what code winds up compiled into your components? Last I checked, MOST of the code wound up in your components. In fact, this was their entire argument for why people should use Svelte when it launched. Just look at their "Hello World" application on the Svelte website. 5 lines of code transform into 45 lines of code.

If two components use the same code it’s hoisted and both components use the same function declaration.

Re: Svelte 4

#163
post #48
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 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…

I'm somewhat in the same boat, so used to react that it makes it harder to learn a simpler paradigm.

Re: Svelte 4

#164

hope it adds a client side router, and provides a true SPA mode(not the sveltekit stuff), before then, no plan to use svelte again as my use cases is 100% SPA with 0% SSR, absolutely nothing with SSR.

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, React will be my choice.

Re: Svelte 4

#165
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 audibly laughed at your second paragraph. Yes you understand this perfectly :).

Re: Svelte 4

#166
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 import from `svelte` and its subpackages (instead of taking you to an unhelpful type declaration, it will take you to the actual source, which you'll be able to edit right inside `node_modules` to see changes happen).

Re: Svelte 4

#167

Time for a very naive question. As somebody looking for a more effcient (less re-rendering) and nicer DX (template based, stuff like exit animations) alternative to React, what actually makes Svelte measurably better than Vue? On first (and very naive) look the two seem pretty similar, with the biggest difference being that Vue seems to have the much bigger ecosystem and more mature tooling (I keep hearing about Svel…

I haven't worked with Svelte (but with Vue, so def biased) but my feeling is that where Vue really shines (and always have, compared to other frameworks) is it's data reactivity system, making data (including but not limited to) stores very nice to author. The composability of Vue 3 data stores makes it imo really nice to work with for anything a little bit more complex, and I've yet to see anything as good.

I've used both for years. Reactivity and stores in Svelte are much simpler and elegant IMO.

Re: Svelte 4

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

You will write a fraction of the code and your apps will be considerably lighter.

Re: Svelte 4

#170
I've heard of Svelte but am not sure exactly what it does. So this time I went to their homepage and it doesn't provide any concise summary of what it is.

If I had to guess, I'd say it packages Javascript up into an application that runs locally, but... ¯\_(ツ)_/¯

Post reply on HN