Live data from Hacker News

Comparing Svelte and React

jackfranklin.co.uk

231–240 of 338 posts

Re: Comparing Svelte and React

#231
I have been maintaining some Svelte components. But as many of them here, my profession is in React as of now.

One of things Author didn't directly point out is about JSX. I mean you can build JSX of a component incrementally in your component code. But that's something I am missing in Svelte.

Re: Comparing Svelte and React

#232
post #2

Half-OT: Svelte seems to be the pinnacle of the "bundling era" of frontend frameworks. What do you think comes next? XYZ-to-WASM? Back the roots with (non-)bundlers like Skypack? Anyone heard of next-gen experiments in that directions?

> XYZ-to-WASM

There is yew (https://github.com/yewstack/yew) which is a React inspired Rust framework that compiles to WASM.

Re: Comparing Svelte and React

#233

No mention of Typescript. You'd be mad to consider writing a significant app without it, and React has really great Typescript support - even templates are type checked properly thanks to JSX/TSX, and basically all tools support JSX these days. Vue doesn't come close to that, but it does look like Svelte is at least a bit better: https://svelte.dev/blog/svelte-and-typescript I'd still be wary that there are big cavea…

> Vue doesn't come close to that

> thanks to JSX/TSX, and basically all tools support JSX these days

I haven't used TS and Vue together, but Vue 3 seems to have been written with TS, as well as having supported JSX for quite a while. What are the limitations?

Re: Comparing Svelte and React

#234
post #41

Is it necessary to use a worker for the timer? If you just record the start time, then inconsistent setTimeout calls aren't a problem because each call calculates the duration from start time to current time. Or am I missing something?

HTTP 203 has a great video about counters (https://www.youtube.com/watch?v=MCi6AZMkxcU)which goes into more details about why counters/timers are a bit more complex.

Re: Comparing Svelte and React

#235

I'm a big fan of Svelte. I've raved about their documentation before, but it bears repeating: this should be the gold standard. You can read it all in a day. There are examples to follow right next to the documentation. Svelte is both succinct and powerful. I find this in contrast to React which is often baffling and incoherent. I say this as someone that has used React professionally for 6 years. They've changed the…

React, Redux, Jest, and it’s ilk always came off to me as a way for Facebook to remain relevant through tech-debt and lock-in.

Doesn't make sense, there is nothing that benefits facebook by "dominating" a tech niche. They dont profit off of development platforms (android and .NET) like google and microsoft

Re: Comparing Svelte and React

#236
post #216

I never got the appeal of state management in React. People now seem to rave about Svelte, because you can just do 'count += 1'. But you could do exactly this already in Angularjs (which, just like Svelte, had a template language). Ok, Angularjs worked different under-the-hood than Svelte. It was a dirty checking loop instead of compiler-generated change indicators, which didn't scale as well. But other than this sca…

It's because react works with immutable state. Svelte instead opts for compile-time magicks to handle state. Angular uses decorators to manage state. This has turned out to be an unwise descision because javascript decorators have changed in spec since then.

Angular does not use decorators to manage state. It uses decorators to create compile-time instructions for the dependency injection system to wire components, services, and directives together (I'm simplifying a bit here). Should TypeScript ever drop their decorator implementation, this could all be fairly easily changed to do it with functions instead:

  export class AppComponent { }
  
  export const appComponent = Component(AppComponent, {
    template: 'Hello World!>/h1>
    // other compile-time instructions
  });
How you want to approach runtime state has nothing to do with decorators.

Re: Comparing Svelte and React

#237

Earlier quoted context omitted.

It's so boringly cynical to suggest that people use something because they're lemmings rather than any of the great reasons to use something. Go watch the original React debut talk and ask yourself if React had/has anything going for it beyond Facebook's backing. I know I, and most developers I know, dropped Backbone/Knockout/whatever instantly to use React because it was so obviously better. Now that unidirectional…

> I know I, and most developers I know, dropped Backbone/Knockout/whatever instantly to use React because it was so obviously better. You skipped a huge step. There was angular before react. Which was horribly bloated and over complicated. People wanted something simpler. React, with it's facebook clout won in the end.

Something simpler: Vue

Something more simpler: Svelte

Just try it and give it a chance.

Re: Comparing Svelte and React

#238

Earlier quoted context omitted.

I think many people adopted React because Facebook was behind it, and using it in production, the ecosystem is huge, there is a react- package for everything you can image, there is also react-native, I don't like it, but there it is, you can reuse the knowledge to build native mobile apps. Now Svelte, I haven't been following, but I think the creators are working in what's going to be next and even better framework[…

It's so boringly cynical to suggest that people use something because they're lemmings rather than any of the great reasons to use something. Go watch the original React debut talk and ask yourself if React had/has anything going for it beyond Facebook's backing. I know I, and most developers I know, dropped Backbone/Knockout/whatever instantly to use React because it was so obviously better. Now that unidirectional…

Both the uni-directional data flow and virtual dom were not exactly new ideas when React/Flow came out. There were other libraries/frameworks playing with similar concepts at the time. Half a dozen new ones appeared in 2014. React won the lion's share of developer adoption.

I personally heard that 'objectively better' line incessantly from 2015 onwards, with 'it has the largest community' always being a top highlight. Facebook's backing and the celebrities that developed in the JS community around the time certainly played a part in it.

Re: Comparing Svelte and React

#239
post #118
post #115

Earlier quoted context omitted.

biggest issue of Svelte (and vue and others) is that mutable state is marketed as a feature. If you don't like mutable state anyway then it just seems like an inferior way of writing code.

Yes. To be fair, after looking how the whole Redux story went, I think the mainstream simply wasn't ready for immutable state.

When people not use something, they are not ready for it?

I think they simply don't need it.

Re: Comparing Svelte and React

#240
post #132

Earlier quoted context omitted.

Not necessarily. Discoverability is a function of colocation, not of immutability. One can write convoluted Redux monstrosities spanning a multitude of files where it's difficult to mentally follow how a dispatched action translates into state deltas (potentially because of too much higher-order abstractions, but also because one action may affect multiple reducers, and that in turn may affect a multitude of React tr…

These giant monstrosities are really easy to avoid. Redux Actions make locating a state change a breeze. I have worked on giant applications that did not use a redux-like approach to state and it was a horrendous mess.

I think it's easy to get into a mess as an applications complexity increases regardless of which state management approach one chooses. Every paradigm has a trade off.
Post reply on HN