TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

Svelte5: A Less Favorable Vue3

64 pointsby rxliuli2 months ago

13 comments

gg22222 months ago
To the author: Yes, do consider SolidJS seriously. I find that its reactivity system is simple and the easiest to reason about, with none of the messiness and constant changes to &quot;the best practice way to do things&quot; like React has gone through the years.<p>SolidJS seems designed right so that it doesn&#x27;t need so many major revisions and it feels quite stable.<p>It feels like an evolved React that is simpler to use.<p>Also its signals and stores can be used in normal .ts files, so it is easier to create re-usable &quot;stores&quot;.<p>edit: BTW haven&#x27;t been following Svelte but it&#x27;s already version 5? I thought it was the newest framework.
评论 #43299874 未加载
评论 #43299243 未加载
评论 #43299395 未加载
评论 #43299890 未加载
评论 #43300278 未加载
评论 #43299663 未加载
评论 #43299814 未加载
seanwilson2 months ago
My current preference in Vue 3 (with the Composition API) but using JSX (which is generally only mentioned with React) instead of Vue HTML templates (e.g. <a href="https:&#x2F;&#x2F;vuejs.org&#x2F;guide&#x2F;extras&#x2F;render-function#v-for" rel="nofollow">https:&#x2F;&#x2F;vuejs.org&#x2F;guide&#x2F;extras&#x2F;render-function#v-for</a>, <a href="https:&#x2F;&#x2F;vuejs.org&#x2F;guide&#x2F;extras&#x2F;render-function.html#jsx-tsx" rel="nofollow">https:&#x2F;&#x2F;vuejs.org&#x2F;guide&#x2F;extras&#x2F;render-function.html#jsx-tsx</a>) with TypeScript. Correct me if I&#x27;m out-of-date, but my understanding is Vue is more batteries included, and state management is more concise. I strongly prefer JSX :<p>- I can write for-loops, conditions, etc. in the same language I write my logic in with the same TypeScript and (Vscode) IDE support (e.g. refactoring, formatting, error reporting) vs using a special template language + IDE plugin.<p>- I find HTML templates really ugly and harder to read in that your dynamic logic code gets lost inside the static markup and presentation code e.g. `&lt;li v-if=&quot;items.length &gt; 2&quot; v-for=&quot;{ id, text } in items&quot; :key=&quot;id&quot; class=&quot;card card-body fw-bold small&quot;&gt; {{ text }} &lt;&#x2F;li&gt;` vs `{items.length &gt; 2 &amp;&amp; items.map(({ id, text }) =&gt; (&lt;li key={id} class=&quot;card card-body fw-bold small&quot;&gt;{text}&lt;&#x2F;li&gt;))}` (still quite ugly but most of the logic is on the outside now).<p>- I can easily assign chunks of HTML to variables or generate HTML snippets via concise functions in regular TypeScript instead of being forced to create a new verbose component via HTML templates each time e.g. the arrow function above can be assigned to variable and reused. HTML templates feel very limiting in comparison.<p>It&#x27;s sometimes awkward finding the JSX syntax (like for using Vue slots), but this is more because it&#x27;s less common.<p>Would be curious of others who have tried this Vue 3 + JSX combination!
评论 #43299369 未加载
评论 #43299550 未加载
评论 #43299555 未加载
评论 #43299843 未加载
评论 #43299207 未加载
nasso_dev2 months ago
As a &quot;Svelte5 enthusiast&quot;, I didn&#x27;t stop reading and I wasn&#x27;t particularly surprised... All frameworks&#x2F;libraries&#x2F;languages have quirks. I was perfectly aware of every single point listed yet I still enjoy Svelte 5 a lot more than 4.<p>&gt; Form Components Are Uncontrolled by Default, Which Can Cause Issues &gt; [...] &gt; What happens if you remove the bind? One-way binding? No, it only sets the initial value, then the input&#x27;s internal state takes over, contrary to expectations.<p>I strongly disagree. This is literally how HTML works. This makes forms with default values MUCH less awkward to author.
vlod2 months ago
You know I&#x27;ve fallen in love with Svelte (specifically Sveltekit). I would strongly recommend giving it a shot.<p>I&#x27;m an experienced React dev and thought I&#x27;d try something new for a side project. I tried and liked SolidJS (and agree with a lot of the positive comments here) and Ryan seems super knowledgeably about everything front end. (It was a close second).<p>However I wanted to give Sveltekit a shot as it&#x27;s so different to React (and SolidJS is not).<p>For me it seems to put me back to those good olde days (insert rose tinted glasses and violin music), where web dev was just html, css and js&#x2F;jquery (yes, it was hard for it not to turn into spaghetti). However I coded like I was being chased by demons and loved every minute of it.<p>I don&#x27;t get that with React. Having to fix stupid race conditions and constant rendering glitches gets to become grating.<p>Sveltekit (with it&#x27;s signals approach, like SolidJS) sort of puts me back there. It&#x27;s all just html, css (or tailwind), simple js and event driven.<p>You set up some state at the top &lt;script&gt; block and have loaders&#x2F;actions (superforms is great) in external files. To me it all seems super intuitive.
authorfly2 months ago
Thank you to author for pointing out some negatives here.<p>The 5th version made two &quot;non-error&quot;, but ergonomic changes, for the sake of larger code bases and standard formats over quick, yet reliable, reactive and testable code (which first attracted me to svelte): - the need for getters and setters when using $runes in functions; this is a waste of time and almost always unnecessary in the contexts in which one uses small store classes. Not that Svelte 4 was better, it was different.. in a pinch, I&#x27;d take 4 though. - using folders for routing and using standard page.svelte.js and server.svelte.js naming for everything; it clutters your IDE file list. You could say it&#x27;s good practise, but limiting to one component per file also causes more files in some cases than multiple components per file (as is possible in React)<p>Despite all this, Svelte 5 introduces $writable, which is kind of for the use case of one-off simple state - which doesn&#x27;t need getters&#x2F;setters - so the whole thing doesn&#x27;t feel that consistent.<p>I don&#x27;t mind using consistent runes - that is a bit of boilerplate, but makes it easier to reason about. I still love the reactivity of using bind (like Vue) and using $effect with it automatically figuring out what to do without the footguns of Reacts useEffect. I love that I can just start writing files and routing will work, css can just go there without a node module to process it.<p>Increasingly, I&#x27;ve realised React is probably going to remain my number 1: - Recent changes are mostly just shorthands to reduce boilerplate - Mobx has got state down - Hooks have footguns, but I know them - The eco-system is still unmatched - `use` and other statements allowing async loading (like other recent shorthands) is helpful, a lot of my components used to have boilerplate to do async stuff, and it took effort to make failure cases&#x2F;loading work well. This pairs very well with server functions too.
评论 #43299580 未加载
pablopang2 months ago
All the points in the gist are basically wrong...I will comment after point to point as soon as I&#x27;m back at the desk
评论 #43299286 未加载
Taterr2 months ago
As a new comer to JS frameworks Svelte 5 convinced me to use Vue instead.<p>I think Svelte has a nicer template syntax and the reactivity is cleaner is some cases, but it feels like there&#x27;s no &quot;best practice&quot; or &quot;recommended&quot; patterns in a lot of common cases and I don&#x27;t have the confidence to make something that won&#x27;t suck later.<p>Vue has been more stable for longer so it&#x27;s easier to find dozens of examples of the thing you&#x27;re trying to do with less argument over how to do it, and LLMs seem to produce much better Vue code.
评论 #43310778 未加载
pjmlp2 months ago
As old timer I have framework fatigue.<p>It is either plain ASP.NET MVC, Spring or Next.js, depending on the programming language, and that is it.
评论 #43299913 未加载
评论 #43299502 未加载
tglide2 months ago
&gt; Runes Only Work in Svelte Components or .svelte.ts Files<p>This is like complaining that types only work in .ts files<p>&gt; Hooks Using Runes Must Wrap State in Functions<p>This is on purpose, as you know. They want reactivity to be explicit. The benefit of runes is, that if you like Vue and Solid so much, you can literally create their reactive primitives in Runes, and it works.<p>&gt; Classes as First-Class Citizens for Runes... or Not?<p>This entire section is weird. The title complains about classes, but then the second code snippet is a function back again. And the third is also equally weird, why would you ever need that.<p>&gt; Svelte Templates Include Features That Cannot Be Implemented in JavaScript<p>This one I don&#x27;t know sufficiently about. I&#x27;ll let others argue about it. But I do think this was already present before<p>&gt; Form Components Are Uncontrolled by Default, Which Can Cause Issues<p>Same here, Svelte always had this behavior. As you also state, this is present in other frameworks, such as Vue itself, which you&#x27;re promoting as better than Svelte<p>&gt; Ecosystem<p>If you want someone to point out the issues people had when migrating to Vue3, and still have to this day, sure. Every framework really, when they go through such a big change.<p>&gt; Community Response<p>Criticism is fine. But a lot of the things have been discussed over and over tbh, and a lot of it is poorly structured, e.g. saying &quot;svelte is react now&quot;, which just brings noise to the table. I&#x27;ve personally seen a lot of other criticism which has led to action being taken.<p>As a proof of that, recently here in hacker news there was a post criticizing Svelte 5. It is now mentioned on this PR as a change for it <a href="https:&#x2F;&#x2F;github.com&#x2F;sveltejs&#x2F;svelte&#x2F;pull&#x2F;15469">https:&#x2F;&#x2F;github.com&#x2F;sveltejs&#x2F;svelte&#x2F;pull&#x2F;15469</a><p>I do criticize things in Svelte as well, e.g. I do like the patterns for passing reactivity through boundaries, but I do think it needs to be well documented on how to, as people can get a bit lost. Or maybe some utilities shipped to it. But I don&#x27;t personally like `ref` and `createSignal`. They come with their own issues.
评论 #43300423 未加载
teekoiv2 months ago
I very much agree with the overall thesis of the post. Runes are just irksome in subtle ways.<p>One big point that the post misses, is that the Class escape hatch for runes is incompatible with constructor-set parameters.<p>Say you have a class that wraps a HTMLElement which you set in the constructor. This doesn&#x27;t work:<p><pre><code> class Wrapper { dom: HTMLElement = $state() constructor(el: HTMLElement) { this.dom = el } } </code></pre> as TypeScript throws an error about `Type &#x27;undefined&#x27; is not assignable to type &#x27;HTMLElement&#x27; for the $state()`. You could fix it by eg. `$state(undefined as unknown as HTMLElement)` but that&#x27;s dumb. Interesting enough you could do something like:<p><pre><code> class Wrapper { dom: HTMLElement constructor(el: HTMLElement) { let d = $state(el) this.dom = d } } </code></pre> Moreover, Vite&#x2F;esbuild mangles class-field parameters with esnext into constructor-set parameters as they are just more versatile. So the original code becomes something like:<p><pre><code> class Wrapper { constructor(el: HTMLElement) { this.dom = $state(el) } } </code></pre> Which is incompatible with rules of runes. I did whine about this already <a href="https:&#x2F;&#x2F;github.com&#x2F;sveltejs&#x2F;svelte&#x2F;issues&#x2F;14600">https:&#x2F;&#x2F;github.com&#x2F;sveltejs&#x2F;svelte&#x2F;issues&#x2F;14600</a> but so far no clear answer
评论 #43306818 未加载
评论 #43299755 未加载
评论 #43299428 未加载
KolmogorovComp2 months ago
All these irks to avoid redraw()ing when needed
bhaney2 months ago
I didn&#x27;t even know there was a Svelte 2
评论 #43306781 未加载
评论 #43299144 未加载
DannyBee2 months ago
I use svelte a lot, because react&#x27;s rules and such tend to drive me nuts.<p>It&#x27;s not that i can&#x27;t get used to them, it&#x27;s that i just don&#x27;t want to have to deal with them when they exist mainly because it made it easier to implement, not easier to use. It just gets the balance wrong for me. To each their own. I&#x27;ve met people who love them.<p>Some of these arguments resonate, some don&#x27;t.<p>In the case of Svelte 5, it is (unfortunately) easier to understand if you look at the post-compiled code. Which often makes it totally obvious what is going on and what works or doesn&#x27;t. Which is not great. It also often issues error messages that remind me of C++ 20 years ago in their unhelpfulness, before a <i>lot of time</i> was spent making the error message better. For example, I walked the tanstack folks through an example of generated code, because totally reasonable and smart people have trouble wrapping their head around what happens under the covers and what the error messages mean: <a href="https:&#x2F;&#x2F;github.com&#x2F;TanStack&#x2F;table&#x2F;pull&#x2F;5943">https:&#x2F;&#x2F;github.com&#x2F;TanStack&#x2F;table&#x2F;pull&#x2F;5943</a><p>IMHO, trying to teach people this level of idiosyncrasy is a bit silly, and regardless of theoretical benefit, seems unlikely to work long term. It feels like there is not enough compiler help here to make it feel really magical, though at a glance it looks like their good be. I hope they adjust this.<p>I also agree the community is frustrating to deal with a not insignificant amount of time. There are lots of good people, mind you, but also lots of &quot;you are holding it wrong&quot;, etc. I reported what is a blazingly clear bug (once you know it exists):<p>Svelte5 ships two incompatible Snippet types because of the use of unique symbols for SnippetReturn. Different unique symbols are never compatible in TS.<p>So these two SnippetReturn types (which are then used in the Snippet type in each file):<p><pre><code> rg &quot;SnippetReturn.*unique symbol&quot; types&#x2F;index.d.ts 268: const SnippetReturn: unique symbol; src&#x2F;index.d.ts 271:declare const SnippetReturn: unique symbol </code></pre> are incompatible.<p>The error message you get if you trigger this is .. hilarious and hurts your brain (the two syntax highlighted types in this picture that look 100% identical are not compatible, one is from types&#x2F;index.d.ts, one is from src&#x2F;index.d.ts) - <a href="http:&#x2F;&#x2F;tiny.cc&#x2F;wnkc001" rel="nofollow">http:&#x2F;&#x2F;tiny.cc&#x2F;wnkc001</a><p>I also reported a bug to the typescript folks about the error message.<p>The difference in how the triagers handled it were night and day. Amusingly, the svelte side has a bog simple and obvious fix - share the (typeof&#x27;d) unique symbol type between the two files so there are not two unique symbols. 5-10 line fix, at most. You just have to decide how much to share (IE just SnippetReturn or the whole Snippet type, or what). In the vast majority of projects i work on, someone would look at this, go &quot;oh shit yeah we fucked that up whoops&quot;, fix it with the 10 line fix, and move on. There is absolutely zero reason or advantage to have the code like this. It is an obvious bug, it should be fixed, it&#x27;s not worth a lot of time. But after many messages, I actually gave up on the svelte bug. To be fair i clearly got frustrated but man not a great experience ....<p>Compare to typescript - the typescript side requires work to issue a good error message here, and more thought.<p>Yet I&#x27;m in the midst of finishing a changelist on the typescript side to improve the compiler error message, because the experience dealing with the community was so much better.<p>Plenty of people I talk with have some story like this with Svelte :(<p>I will say, some of the other complaints here seem weird. SVAR grid works fine for tables. It supports variable heights and widths for columns. Maybe they specifically want unstyled tables? I dunno.<p>The usual ui complaint for svelte is not grid, but good tree components. They also pick a few things they admit are not unique to svelte, and exist in other popular frameworks. Seems like a weird shot<p>Also, complaining about file naming and &quot;unpleasant code infection&quot; is also weird.<p>The other arguments seem much stronger - the lawyer in me wants to yell &quot;put your arguments in order of strength, and remove the weakest ones. Quality wins over volume, and most people are not going to read the whole thing&quot;. If i&#x27;m really trying to make an effective argument, i make short ones, not long ones. On HN i&#x27;ll do longform because i don&#x27;t care enough most of the time to spend the time editing to make it effective. But if i was really trying to be convincing i would make much shorter ones.<p>In any case, i think some of this is reasonable. But having spent lots of time with frameworks, i&#x27;ll keep using Svelte5, but I do hope things improve. I feel like i&#x27;d spend the same amount of time with other idiosyncrasies if i moved to Solid.
评论 #43300453 未加载