TE
科技回声
首页24小时热榜最新最佳问答展示工作
GitHubTwitter
首页

科技回声

基于 Next.js 构建的科技新闻平台,提供全球科技新闻和讨论内容。

GitHubTwitter

首页

首页最新最佳问答展示工作

资源链接

HackerNews API原版 HackerNewsNext.js

© 2025 科技回声. 版权所有。

Ask HN: What are the benefits of choosing Svelte over React?

4 点作者 RapperWhoMadeIt超过 2 年前

3 条评论

montroser超过 2 年前
The two frameworks take completely different approaches to solving similar problems, so each comes with huge trade-offs compared with the other.<p>In a sense, the Svelte framework runs at compile-time -- it takes your application source code, and uses its framework to produce a minimal JavaScript bundle that you ship to your end users.<p>In contrast, the React framework runs at run-time -- you ship React along with your application to the end user, and they boot it all up and run it there.<p>So, in terms of benefits, Svelte will be smaller and will likely run faster. As a bonus, it&#x27;s much easier to learn.<p>For downsides, Svelte can be harder to debug, and the community is smaller. But that said, React is a hot mess with so many ways to do all the things because all the existing ways are terrible and so then people make even more new ways again...
评论 #32967504 未加载
maiertech超过 2 年前
Developing with Svelte and SvelteKit feels like I am closer to standard Web APIs. Meaning I can learn lots of evergreen stuff that will not get outdated any time soon.
评论 #32967518 未加载
Glench超过 2 年前
Svelte has been a dream for me:<p>* Styles are included so you don&#x27;t need a whole other library for doing styling. Automatic component-scoped CSS is great. You can also include whatever your favorite compile-to-css language is.<p>* It&#x27;s faster than React because there&#x27;s no virtual dom. I&#x27;ve run into performance issues a lot with React and not much with Svelte. Never used Solid though.<p>* Less boilerplate. According to this talk, React components translated into Svelte components have around 40% fewer characters: <a href="https:&#x2F;&#x2F;www.youtube.com&#x2F;watch?v=BzX4aTRPzno" rel="nofollow">https:&#x2F;&#x2F;www.youtube.com&#x2F;watch?v=BzX4aTRPzno</a> I&#x27;ve definitely noticed writing less code.<p>* Less JS bloat!* The actual Svelte library gets compiled away so you don&#x27;t need to include e.g. the entire React runtime. *(There _is_ a crossover point when you have many many Svelte components where the bundle size will be more because each components has self-contained duplicated code, but my understanding is that it&#x27;s pretty high).<p>* Use the HTML&#x2F;CSS&#x2F;JS&#x2F;TS I already know. There&#x27;s a little &quot;magic&quot; in the compiled reactivity system, but I&#x27;ve found it to be very minimal and easily understandable. I don&#x27;t have to learn much to be very productive in Svelte.<p>* The interactive documentation. It&#x27;s stellar. VERY clear and I can change all the examples they give and play around with things to test my understanding. The REPL is also super useful when asking questions to other devs about Svelte: <a href="https:&#x2F;&#x2F;svelte.dev&#x2F;repl&#x2F;" rel="nofollow">https:&#x2F;&#x2F;svelte.dev&#x2F;repl&#x2F;</a><p>* Batteries included — Styles, animations, transitions, stores... all of these work really well together and I rarely have to go outside of Svelte itself.<p>And SvelteKit is taking all this to the next level with making Svelte available throughout the full stack. Heck, I&#x27;m making a SaaS boilerplate built on top of SvelteKit because I love it so much: <a href="https:&#x2F;&#x2F;sveltesaas.com&#x2F;" rel="nofollow">https:&#x2F;&#x2F;sveltesaas.com&#x2F;</a><p>Some drawbacks to Svelte:<p>* It&#x27;s not as popular as React so you&#x27;re not as well supported when developing. Think Stack Overflow or other developers in your organization.<p>* The reactivity system can be a little magic (for example you can&#x27;t do array.push() to trigger a reactive update).<p>* You have to learn the templating system instead of just using the JS you already know. A little unfortunate, but I honestly kind of like using templates better — I don&#x27;t enjoy JSX at all. I found it only takes like a half hour to learn Svelte&#x27;s templating anyway.
评论 #32970119 未加载