We all like our coffee different, just as we all have favourite features and designs of frameworks. There is no correct, or best, framework, only personal preference and what's good enough for the job in hand.
Svelte is a Flat White with locally roasted coffee beans from an independent coffee shop.
React is a Starbucks Vanilla Late.
Vue is a Starbucks Caramel Machiato.
Angular is the Vanilla Late from your staff canteen, it used to be a bit rough, but seems to be better in recent years.
Not using a framework, is carefully weighing out the "correct amount" of beans, grinding them by hand, tampering it with the "correct force", and then making the "perfect" espresso.
Disclaimer: I <3 alpine.js
- 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 without you having to think about it (though IMO there’s work to do there with CSS variables and the like)
- The end-user bundle is so much smaller. This doesn't matter so much if you're creating a giant web app (e.g. Gmail) but I often work on smaller sites and it's very gratifying for users to only have to download ~20KB of JS rather than the hundreds (if not megabytes) you'd get with React. Has a positive impact on page performance scores, SEO etc too.
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 small project to try it out, so I'm going to give it another shot.
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 is the default for the still nearly ubiquitous create react app system.
End-user bundle argument is a red herring. What is true for "hello world" isn't true for large applications. The overhead of React is a one-time payment while each new Svelte component drags along all the code needed to support it (copying similar code over and over).
React's F + N * C (where F is framework size, N is component count, and C is average component size) is smaller for large values of N than Svelte's N * (F + C) approach.
Caveat: since I went react -> svelte it's possible I was just warmed up to JS by that point
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 component tree?" and the answer was "Make a new context with createContext and wrap the context provider in a component which provides the state and write a hook to easily consume the context within a child component" and, yeah, that's not exactly a frictionless dev experience.
FWIW for simple state management in React I've heard lots of good things about zustand: https://github.com/pmndrs/zustand
I haven't dug too deeply into Svelte because last I checked it didn't play particularly nicely with TypeScript but this release may prompt me to give it another look.
I'm not sure how long ago you tried or what issues you ran into, but hopefully this will help with getting started with Svelte and TypeScript much more easily.
Svelte state management, for example, is just the `subscribe(callback: () => void) => Unsubscriber` interface. A couple of utility store functions are provided like `writable` and `derived` but state management libraries don't need to know anything about Svelte, just provide that single life cycle method. The context API looks almost exactly like React's.
There's also stuff like generally fewer LoC, more incentive to use native APIs and rebuild times measured in hundreds of milliseconds, but that first thing is what got me sold on Svelte.
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 Svelte's flavor of JS basically being its own language now and it not playing all that well with Typescript). From what I remember they even once had a virtual DOM-replacing Ahead of Time compiler, so that might not be the biggest moat either.
Both can be fiddled around with to support rendering using JSX, but it seems to easier and better supported for Vue.
Edit: The AOT compilation was called "Reactivity Transform" and dropped due to the aforementioned shift away from "real" JavaScript: https://vuejs.org/guide/extras/reactivity-in-depth.html#runt...
Now I wonder whether the performance benefit is big enough to justify using Svelte, especially since Vue already uses a "compiler informed virtual DOM".
Anecodally all Vue apps I have used felt fast while the React experience was more mixed, but the sample on the Vue side is also just really small.
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 think Typescript was worth it for *developing libraries*, and so they were switching to using JSDoc annotations for developing Svelte, which has no impact at all on Typescript or Svelte or Svelte users using Typescript?
e.g. https://devclass.com/2023/05/11/typescript-is-not-worth-it-f...
anyway, Svelte is fairly similar to Vue, just a subjectively slightly nicer style. do both tutorials and see which you like I guess?
I don't know about you, but I don't keep a map of "random thought" to "url" anywhere. It seems totally fine/normal in a discussion forum to say "Hey i heard this thing, any substantiation to it?" without needing a source.
The biggest advantage of Vue is the ecosystem. However, Svelte is catching up. Some interesting UI component libs have recently arisen, e.g. https://skeleton.dev.
Performance wise, both are super fast.
Make sure to check out Sveltekit, even for building pure SPAs. The routing and data loading are worth it alone.
The only optimization I had to implement was virtualization when showing hundreds of off screen images (an optimization I would have had to implement regardless of framework).
nope, its still there, just is less complicated than you make it sound with those adjectives in front of "compiler"
in the days of svelte 3 vs vue 2, i'd say the authoring experience was a lot more straightforward as vue had constraints around being a drop in framework. but then vue 3 came with "script setup" and other svelte inspired improvements that brought it a lot closer to svelte. am a bit uncomfortable with the 2->3 churn in the vue ecosystem (https://twitter.com/swyx/status/1482778158537801728) but havent actually tested it out since
What sold me on svelte is the fact that I learned like all of it in maybe 3 hours. I have tried to pick up React here and there and I get the fundamentals but I hate that you need an architecture framework, a router framework etc. Svelte has a standard way of doing that.
Writing Svelte, I actually had "fun" building stuff, I can't say the same thing about my React attempts.
> Vapor Mode will only support a subset of Vue features. In particular, Vapor Mode components will only support Composition API and <script setup>. However, this supported subset will work exactly the same between Vapor and non-Vapor components.
> Building an app with only Vapor components allows you to drop the Virtual DOM runtime from the bundle, significantly reducing the baseline runtime size.
This seems like a clear push in the direction of Solid and Svelte in this area.
Not diffing at all against a virtual DOM and instead executing the pre-compiled DOM manipulations is an order of magnitude better in terms of processing. It also avoids diffing entirely. At a casual glance, the compiler hints and other VDOM optimisations in Vue reduce but do not obviate this burden (e.g., don't re-render static nodes, flatten the DOM tree to avoid traversing) But as ever, it's best to measure these things and I can't seem to find any recent benchmarks between the two platforms, and any benchmark would vary wildly depending on use-case, and with the exigencies of real-world development.
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 suspect author (Evan) lost interest, given the Vue 2/3 situation (similar to Python 2/3) and the lost battle against React.
Wow, that’s a pretty big reduction.
Eh, that's not a fair comparison, Windows bundles the .NET standard libraries and runtime.
Another manager said to me (fairly with hindsight) "If you get something down from two hours to one hour, that's an opimisation. Going from 6 hours to 5 minutes means it just wasn't finished."
Sorry, HR rep, I thought we were just slinging pithy aphorisms!
> 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).
> The number of dependencies in Svelte has been greatly reduced from 61 down to 16. This means faster downloads for our users as well as less susceptibility to supply chain attacks
Its not zero but quite a big dependency reduction
create-nextjs-app is installing React, React Router, Webpack, Tailwind, ESLint, Jest, etc.
create-nextjs-app is by design an "everything and the kitchen sink" approach.
Something about svelte being a superset of standard html/js/css that gets compiled bothers me. I realize that the same can be said about typescript/tsx but I feel like in can trust it more... Maybe it's a maturity thing? Or that it's just one language getting compiled to its subset (with syntactic sugar for dom elements)
I tried SvelteKit 2 weeks ago after working through learn.svelte.dev and it immediately appealed to me.
Starting with one file in a route that holds JS, HTML and CSS was great. Breaking it up into components as I went along was natural. I think TailwindCSS helped here too, because I barely had to do any CSS work and could focus on JS and HTML.
It took me a while to understand the value of stores and where to use them, but then I hit upon a use case (big complicated multiple nested tree of mutable data).
After a few refactorings I had a very nice compact and easy to understand solution - nothing like what I experienced with RR and Angular.
Svelte clicked after like 3 hours.
Also it's more "fun" than React ever was.
there are better libraries out there like zustand or react-query which helps on most of these stuff.
At least for small projects like this, it's perfect. For something larger/complex I'd be a bit more weary.
* Main search (bottom center, not top right) taking over the screen when you click on desktop is terrible ux
* Should support some fuzzy search or misspelling tolerance, e.g. Cuzco for Cusco
* Valencia, Spain gives a 500 error
* No keyboard bindings when searching to navigate up/down between the matching results (e.g. type in 'Valencia' and I expect I can use the down key to choose which of the three results)
In my opinion I feel like React.js was ahead of its time, but now we're seeing some competitors achieve the same (or better results in terms of benchmarks) with simpler approaches.
Keep in mind these are just opinions, and I'm only about a month into React in a massive web application. That said, it took me like a literal day to learn Vue 2 because it was mostly just like native web development anyways.
But I really hate how react does not have a "blessed"/"official" router or state management, and a lot of "innovation" in this space simply looks like fashion waves nowadays, often reinventing the wheel, and are getting unpopular again over time.
I personally do use Meteor again these days to have real fullstack stuff easily, which has built-in state management (client-only collections work extremely well for state) when things become more complex than a few useState things. Also SSR "just works" with this, since a useTracker (from meteor) is executed during SSR cycle (as opposed to useEffect API calls), including rehydration with a fast-render package.
This absolutely is crucial for my projects, or else stuff like proper SEO is simply a pain in the ass. I would even pay money for react to have kind of renderToString on the server that simply BLOCKS (or awaits) during SSR so that the initial HTML contains fetched data. The discussion about react server components at this point is just comically absurd for me, as if they really want to make the simple SSR requirement as complex as possible for no reason, other than maybe force users into Nextjs so they can make more business from magically working hosting.
From an ecosystem view point I think that's really cool! It means that they're not tied to anything and you can pick what works for you. The community, of course, has found its go-to solution anyway, fittingly named "React Router".
The state management situation is more complicated and I think that's even more beautiful, because someone liking Redux can just use it for themselves instead of it being forced on everyone.
That's really the big thing. I know everyone loves to believe they're masterclass programmers and falling for such traps is beneath them, but after seeing some of these masterclass programmer's react repos... it's very clear why the react docs is filled with many disclaimers and notes (which kudos to the react team for phenomenal docs).
I don't think the same thing apply for any other popular frontend frameworks.
I love Svelte because prototyping a new feature in it is really really trivial, even with keyboard interactions and animation effects.
Svelte isn't a subset of js/html/css, it just uses them. Svelte does support typescript as well.
SolidJS is the one I am really excited about moreso though, since it uses JSX and works even moreso with the DOM.
> "Svelte 3 was released more than four years ago! In JavaScript-framework-time, that's eons. Svelte’s freshness has persisted throughout, but Node.js and browser APIs have evolved during that time and today we’re updating Svelte to take advantage of some of these improvements. Svelte 4 is mainly a maintenance release, bumping minimum version requirements and tightening up the design in specific areas."
This seems eminently reasonable to me.
> "Svelte 3 was released more than four years ago... Svelte 4 is mainly a maintenance release, bumping minimum version requirements and tightening up the design in specific areas."
Major Changes breaking: Minimum supported Node version is now Node 16 (#8566)
breaking: Minimum supported webpack version is now webpack 5 (#8515)
breaking: Bundlers must specify the browser condition when building a frontend bundle for the browser (#8516)
breaking: Minimum supported vite-plugin-svelte version is now 2.4.1. SvelteKit users can upgrade to 1.20.0 or newer to ensure a compatible version ([#8516] (#8516))
breaking: Minimum supported rollup-plugin-svelte version is now 7.1.5 (198dbcf)
breaking: Minimum supported svelte-loader is now 3.1.8 (198dbcf)
breaking: Minimum supported TypeScript version is now TypeScript 5 (it will likely work with lower versions, but we make no guarantees about that) ([#8488] (#8488))
breaking: Remove svelte/register hook, CJS runtime version and CJS compiler output (#8613)
breaking: Stricter types for createEventDispatcher (see PR for migration instructions) (#7224)
breaking: Stricter types for Action and ActionReturn (see PR for migration instructions) (#7442)
breaking: Stricter types for onMount - now throws a type error when returning a function asynchronously to catch potential mistakes around callback functions (see PR for migration instructions) (#8136)
breaking: Overhaul and drastically improve creating custom elements with Svelte (see PR for list of changes and migration instructions) ([#8457](https://github. com//pull/8457))
breaking: Deprecate SvelteComponentTyped in favor of SvelteComponent (#8512)
breaking: Make transitions local by default to prevent confusion around page navigations (#6686)
breaking: Error on falsy values instead of stores passed to derived (#7947)
breaking: Custom store implementers now need to pass an update function additionally to the set function ([#6750](https://github.com/sveltejs/svelte/pull/ 6750))
breaking: Do not expose default slot bindings to named slots and vice versa (#6049)
breaking: Change order in which preprocessors are applied (#8618)
breaking: The runtime now makes use of classList.toggle(name, boolean) which does not work in very old browsers ([#8629](https://github.com/sveltejs/svelte/ pull/8629))
breaking: apply inert to outroing elements (#8627)
breaking: use CustomEvent constructor instead of deprecated createEvent method (#8775)
These are just catch up releases, nothing seriously breaking.
to give you perspective, Nodejs went from v10 to v20 in the same time frame.
Adore this. Would love to see more JS frameworks reduce their dependency trees.
https://frontendmasters.com/courses/svelte-v2/
From the migration there does appear to be some breaking changes, don't know how that aligns with the course which I planned to take.
His old course was good as well, but that relied on Sapper.
I don't think you learn anything that wouldn't apply to Svelte 4. It's intended as a smaller update to prep them for bigger changes coming in Svelte 5.
Swing by the official Svelte Discord, we're happy to discuss your questions! https://discord.com/invite/svelte
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.
StencilJS
SolidJS
Svelte
React
Vue
Angular
The virtual DOM was created to solve browser performance issues with the actual DOM. This may not be relevant anymore, but that's why it was made.
The VDOM was invited to prevent bugs by removing the difficult of managing fine grade DOM mutations. Technically you are doing more work with a VDOM and diffing, than carefully mutating the DOM, it's slower.
Of course if you just threw away the whole DOM and re built it, then he's the VDOM was quicker, but that's not how anyone was building stuff.
I tested the beta version of Svelte 4 on my app and it worked without requiring any changes other than running the migration script. Excellent work from the team!
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 limited connectivity. The majority of the remaining package size is eslint support, which necessitates distributing a CJS build, and once the eslint rewrite is completed the Svelte package size can drop by over another 50%.
All sounds great anyway, congrats to the team!
(I believe the new 1Password app is powered by Svelte.)
But in general electron was a pain, slow builds - had an adhoc solution for the svelte dev server, but its not great.
Spent an hour or so after reading this and found conflicting information/out of date documentation. The tutorial[1] on the website is not helpful for actual deployment/development.
I found Svelte for New Developers[2] which is slightly better, however, when building according to the instructions what I expect to happen is not happening. i.e, a static index.html is rendered vs. the src/App.svelte getting rendered.
Wrangling all of this is the worst part of modern day Javascript.
1: https://learn.svelte.dev/tutorial/welcome-to-svelte 2: https://svelte.dev/blog/svelte-for-new-developers
You'll be up and running in seconds. This is all you need to know:
# npm 6.x
npm create vite@latest my-svelte-app --template svelte
# npm 7+, extra double-dash is needed:
npm create vite@latest my-svelte-app -- --template svelte
(if you're looking for sveltekit it's the same command, you'll just select sveltekit in the prompt)If I had to guess, I'd say it packages Javascript up into an application that runs locally, but... ¯\_(ツ)_/¯
If you're interested in seeing what all the fuss is about and have 5-10 minutes to spare, you could start https://svelte.dev/tutorial/basics and get a pretty good sense of it in less than 10 minutes
like git clone repo and then npm run dev ?
To be more exact on what I want to do: is a dynamic dashboard, where users can add widgets or/and resize them per needed.
Basically I'd need the ability to drag and drop, move the tree around like a Map, detect clicks to add new nodes and new branches, stuff like that. I'm thinking an HTML5 canvas would be best but idk.
[1] https://devblogs.microsoft.com/typescript/announcing-typescr...
As well as Bloomberg and the NYT sites, and Brave search.
I'm sure there are more, but for some reason people aren't talking about it a ton yet, and it's definitely not as ubiquitous as React
I love Vue but I really wanted to work on an actual project with Svelte because the developer experience was fantastic. Guess I'll have to wait a few more years.
Almost every job is react, react, react. It's exhausting dealing with the cultists
I'd recommend it to anyone who is focused on actually just shipping UI and making progress (not bike shedding or wasting time, you know who I'm talking about lol).
It is a nice paradigm that lets devs focus on just writing HTML, CSS, and JS with a little bit of teeny tiny magic (it is actually easy to understand). That's it.