Live data from Hacker News

Svelte 5: Runes

svelte.dev

371–380 of 404 posts

Re: Svelte 5: Runes

#371
post #200
post #191

Earlier quoted context omitted.

Let's be honest: the state (see what I did there?) of React state management is a dumpster fire. https://fe-tool.com/awesome-react-state-management That's an article listing the top 18 state management libraries for React. 18?!? React devs can't even agree on a common development model for state, but you think it's explicit and very easy to reason about? Folks don't adopt utility libraries for things that were alread…

React isn't a state manager and why should everyone be forced to use the one "blessed" manager? Despite there being so many, only a handful (redux toolkit, jotai, zustand recoil, and mobx) see much real-world use and they are basically just 3 approaches (reducers, signals, and directed graphs) with varying levels of complexity and features. > Yes, after it has DIFFED the whole tree to see where the changes occurred i…

I use vue, so I’m assuming that is the “signals approach”. I use pinia btw

Can you explain how all 3 state mechanisms you mentioned, and how they are different ?

Re: Svelte 5: Runes

#372

Earlier quoted context omitted.

Can you explain why that is? I find hooks are flexible enough that I tend to be able to implement more sane and manageable reactivity, not the opposite. Maybe I’m misunderstand your issue, though.

I’m referring to the dependency array you pass into hooks, and any hook being able to trigger updates. With classes there was no manual dependency tracking (except comparing old props?) and all re-renders were triggered by state, context or prop changes. Not making a judgement either way, just stating the trade-offs.

The dependency array strikes me as far safer and more reliable, but it has been a bit of a foot gun for a lot of people. I still encounter code where dependencies are missing, which virtually never makes sense or should be intentional. I suppose the compilation step that’s proposed would address that, but it’s yet to be seen.

There does seem to be an aspect to modern react where it’s great if you’re willing to put in the effort to figure out all the quirks, but for everyone else who just wants to get things done/has other priorities, it’s a bit of a minefield at times.

Re: Svelte 5: Runes

#373
post #187

Perhaps I'm just the grumpy old guy that's afraid of change. But I fell in love with Svelte because it was dead simple (according to me). It was a breeze of fresh air and I felt I just program again without wiring enchantments together. I do agree that its simplicity has downsides too, so perhaps it's just nothing to be afraid of? But I can't help seeing this as ominous: > This is just the beginning though. We have a…

Agree. Svelte is a blast to write as an old grumpy backend engineer. But yes, probably just scared for nothing. Turning onMount() into $effect() is a tiny change, but this self-aware smol brained grug likes onMount() as it means something! To enable logical grouping, Svelte 5 allows us to nest the $effect()s? What does that even mean? Where am I? Nurse!

maybe super specific to this comment but onMount isn't going away, it could be replaced with $effect from an implementation standpoint, but it would be wildly confusing if used for that purpose without the clearer name for the wrapper

Re: Svelte 5: Runes

#374

Earlier quoted context omitted.

I don’t know about you, but I have bills that need paid. I’ll clutch my pearls over something else

I have a friend who's a car guy. He bought some fancy Mazda that he just adores and he takes to the track sometimes. He's not pearl clutching. He's in love with that car. He keeps it immaculate and he has a sparkle in his eye when he talks about it. Some people are the same with furniture. They buy super expensive, custom stuff and look after it for decades. Not me! All through my 20s I didn't care at all and my vari…

My comment was meant to be a more humorous jab at my own efforts as a software engineer but in re reading I think it came across as rude and I apologize.

I think if you feel strongly about something you should defend it!

Re: Svelte 5: Runes

#376

This is (surprisingly) almost identical to the Reactivity Transform explorations we did in Vue: https://vuejs.org/guide/extras/reactivity-transform.html let count = $ref(0) const double = $computed(() => count * 2) watchEffect(() => { console.log(double) }) We started experimenting with this ling of thought almost 3 years ago: - First take (ref sugar), Nov 2020: https://github.com/vuejs/rfcs/pull/228 - Take 2, Aug 20…

Hi! First up — not that it matters, but since people will wonder — our design wasn't informed by the Reactivity Transform. We evaluated something close to 50 designs, some of them extremely wacky, before settling on runes, and it wasn't until after that time that the Reactivity Transform was brought to our attention. Nevertheless, it's interesting and validating that we landed on such similar approaches. While the Re…

> $state and $ref are quite different.

I wouldn't say they are "different" - they are fundamentally the same thing: compiler-enabled reactive variables backed by runtime signals! But yes, Vue already exposes the underlying concept of refs, so for users it's two layers of abstractions. This is something that Svelte doesn't suffer from at this moment, but I suspect you will soon see users reinventing the same primitive in userland.

> There's strict read/write separation

I'd argue this is something made more important than it seems to be - we've hardly seen real issues caused by this in real world cases, and you can enforce separation if you want to.

> We're instead encouraging people to use familiar JavaScript concepts like functions and accessors

This is good (despite making exposing state much more verbose). In Vue, we had to introduce destructuring macros because we wanted the transform to be using the same return shape with all the existing composable functions like VueUse.

> There are already a lot of different ways to work with Vue

This is largely because Vue has a longer history, more legacy users that we have to cater to, so it's much harder to get rid of old cruft. We also support cases that Svelte doesn't account for, e.g. use without a compile step. That said, the default way with a compile step is now clearly Composition API + . Reactivity Transform also only really applied in this case so the point you raised is kinda moot.

Separate from the above points, the main reason Reactivity Transform wasn't accepted remains in Runes: the fact that compiler-magic now invades normal JS/TS files and alters vanilla semantics. Variable assignments can now potentially be reactive - but there is no obvious indication other than the declaration site. We had users trying Reactivity Transform on large production codebases, and they ended up finding their large composition functions harder to grasp due to exactly this (and not any of the points raised above).

Re: Svelte 5: Runes

#377

This is (surprisingly) almost identical to the Reactivity Transform explorations we did in Vue: https://vuejs.org/guide/extras/reactivity-transform.html let count = $ref(0) const double = $computed(() => count * 2) watchEffect(() => { console.log(double) }) We started experimenting with this ling of thought almost 3 years ago: - First take (ref sugar), Nov 2020: https://github.com/vuejs/rfcs/pull/228 - Take 2, Aug 20…

All of this looks like MobX

>All of this looks like MobX

Shhhh. Don't tell the Vue/Svelte community that they're just reinventing the React ecosystem on a 5 year delay. It will spoil all of their fun.

Re: Svelte 5: Runes

#378

Earlier quoted context omitted.

All of this looks like MobX

>All of this looks like MobX Shhhh. Don't tell the Vue/Svelte community that they're just reinventing the React ecosystem on a 5 year delay. It will spoil all of their fun.

MobX is not that known unfortunately. It kills me inside.

Re: Svelte 5: Runes

#379
post #355

Earlier quoted context omitted.

I have never heard of a case where I need to care about selector syntax errors. If it ever happened, I guess I'd just use a try? Much of the time "checking for null" consists of adding a single question mark. document.querySelector("div#options")?.setAttribute("hidden", "true");

> If it ever happened, I guess I'd just use a try? Exactly, you'd "just use a try". Instead of not using it. > Much of the time "checking for null" consists of adding a single question mark. Note: this API was introduced way before the `?` was even thought of. Which tells you a lot about the quality of the API. So. Just for the simple task of selecting elements: - you have to different APIs for "select 1 element"/"se…

> Exactly, you'd "just use a try". Instead of not using it.

This has happened zero times so far, to me.

You can use qsa all the time if you want a consistent interface. I consider throwing to be a good thing if the input was bad.

For me, none of these things represent a significant enough problem to take on another dependency.

I'm probably doing different things than you. If JQuery solves some of your problems, I'm not trying to convince you to stop using it.

I know you're asking/wishing it was the standard library. I don't even disagree, really.

Re: Svelte 5: Runes

#380

Earlier quoted context omitted.

All of this looks like MobX

>All of this looks like MobX Shhhh. Don't tell the Vue/Svelte community that they're just reinventing the React ecosystem on a 5 year delay. It will spoil all of their fun.

Michel and I have been internet acquaintances for years, and we've even talked about this stuff IRL. MobX certainly isn't something we just somehow never learned about!

But anyway: it's absurd to compare this with React+MobX. MobX replaces useState, sure, but you're still re-rendering entire components on each change (which is why MobX explicitly recommends that you break apart your app into many small components, regardless of whether that's a boon to readability and maintainability.

By contrast, Svelte (and Solid, and other frameworks) understand signals on a much deeper and more optimal level. They're really not the same thing at all.

Post reply on HN