5 ms·
https://svelte.dev/ https://svelte.dev/ > Svelte is a radical new approach to building user interfaces. Whereas traditional frameworks like React and Vue do th
by paulddraper 7y ago
https://svelte.dev/ https://svelte.dev/
> Svelte is a radical new approach to building user interfaces. Whereas traditional frameworks like React and Vue do the bulk of their work in the browser, Svelte shifts that work into a compile step that happens when you build your app.
> Instead of using techniques like virtual DOM diffing, Svelte writes code that surgically updates the DOM when the state of your app changes.
That sounds like a perfect pitch for Angular. What's the difference between Svelte and Angular?
- Wolfr_ 7y agoThe difference is that Svelte is pre-compiled while Angular will put templates through the renderer while building up the page.
- The_rationalist 7y agoWhy does it matter?
- badfrog 7y agoMuch faster initial load.
- The_rationalist 7y agoBenchs?
- paulddraper 7y agoAngular v1 interpreted templates at runtime. Starting in 2015, Angular v2+ uses an optimizing AOT compiler. [1] [1] https://angular.io/guide/aot-compiler https://angular.io/guide/aot-compiler
- IggleSniggle 7y agoAngular has been pre-compiled for years. The AOT compiler has been available since Angular 2, released in 2015. It has also been able to produce stand-alone native web-components since 2018, btw. It's only recently that it started producing multiple packages simultaneously, however (to serve up a package optimized for the client's web platform).
- ricardobeat 7y agoMost modern frameworks can be AOT compiled in that sense - React, Vue, Riot - they load JS code only at runtime, but still use templates (VDOM, strings or another representation) as blueprints to update/manipulate the DOM. AFAIK Angular still uses dirty checking; Angular Ivy, yet to be released, will move to something a little closer (incremental-dom), but still not the same. What Svelte does is precompile the UI update code[1], changing text nodes, attributes, children, targeting DOM nodes directly. Think Prepack[2] vs DOM diffing. [1] https://svelte.dev/repl/hello-world?version=3.16.7 https://svelte.dev/repl/hello-world?version=3.16.7 [2] https://prepack.io/ https://prepack.io/
- paulddraper 7y ago> Think Prepack Angular compiler is certainly an optimizing compiler. > Angular Ivy, yet to be released Ivy became an opt-in feature of the Angular CLI earlier this year with Angular v8. > AFAIK Angular still uses dirty checking Ivy uses "dirty checking" too [1]. AFAIK Ivy and pre-Ivy operate on similar fundamental principals, which is why Ivy is a drop-in replacement. [1] https://indepth.dev/what-every-front-end-developer-should-know-about-change-detection-in-angular-and-react/ https://indepth.dev/what-every-front-end-developer-should-kn...
- erokar 7y agoSimplicity. You can achieve the same in Svelte using fewer concepts and a smaller API. Angular is over-engineered, Svelte is not.
- sansnomme 7y agoSpecifically Svelte is a lot shorter and concise without the Spring-style infamous enterprise software boilerplate that plagues angular. https://dev.to/maurogarcia_19/angular-vs-svelte-card-component-14nk https://dev.to/maurogarcia_19/angular-vs-svelte-card-compone... In addition, its reactive variables is a lot easier to use.
- vikingcaffiene 7y ago> Angular is over-engineered. I take issue with opinions like this that are espoused as fact. I've built large apps in both Angular and React. The React code base needed everything that I got out of the box from Angular. The difference is that React had no one true way to do things which I suppose some people would consider a good thing. I don't. Angular is a framework. Its not over engineered, its complete. You might not like its chosen abstraction but for people like me who just want to get shit done without needing to worry about plumbing and boiler plate, its really nice. All that said, Svelte looks cool. I'll check it out. I think its a fair criticism to say that Angular has a steeper learning curve and if I can reap all the benefits with a shorter ramp up time, its worth adding to the tool belt.
- ng12 7y agoTo understand why people say Angular is over-engineered Google something simple like "Angular http request". You'll end up at this page: https://angular.io/guide/http https://angular.io/guide/http It's almost comical. I can't believe how long that guide is and how many concepts Angular invented just to fetch some JSON from an http service.
- rileymat2 7y agoInterestingly, they explain some of the reasoning behind the extra info in the docs. WHY WRITE A SERVICE? This example is so simple that it is tempting to write the Http.get() inside the component itself and skip the service. In practice, however, data access rarely stays this simple. You typically need to post-process the data, add error handling, and maybe some retry logic to cope with intermittent connectivity. The component quickly becomes cluttered with data access minutia. The component becomes harder to understand, harder to test, and the data access logic can't be re-used or standardized. That's why it's a best practice to separate presentation of data from data access by encapsulating data access in a separate service and delegating to that service in the component, even in simple cases like this one.
- JMTQp8lwXL 7y agoAngular is (loosely) a superset of what Svelte provides: it's a templating engine, it has a built-in forms library, built-in routing, dependency injection, baked in i18n support, and better XSS sanitization than other frameworks. Angular's templating engine is fairly complex too; it, for example, has a concept of "pipes", so you can write something like this: "<div>{{data | json}}</div>" which will take a JS object, data, and pipe it through a function that returns a stringified version of it, which is what is used in your template. (Compared to other frameworks, this might seem obsolete since JSX is syntactic sugar for JS: in React, you'd just write: "<div>{{JSON.stringify(data)}}</div>"). It's commonly used with Angular CLI to have simple commands like "ng serve" and "ng build" to bundle your application. It also heavy handedly imposes constraints on the architecture of your application-- to some, that's a benefit. All Angular apps kind of look the same.