08.02.2017 Views

vuejs

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

About Vue.js<br />

iv<br />

Comparison with Other Frameworks<br />

Angular<br />

There are a few reasons to use Vue over Angular, although they might not apply for everyone:<br />

• Vue.js is much simpler than Angular, both in terms of API and design. You can learn almost<br />

everything about it really fast and get productive.<br />

• Vue.js is a more flexible, less opinionated solution. That allows you to structure your app the<br />

way you want it to be, instead of being forced to do everything the Angular way. It’s only<br />

an interface layer so you can use it as a light feature in pages instead of a full blown SPA. It<br />

gives you bigger room to mix and match with other libraries, but you are also responsible for<br />

making more architectural decisions. For example, Vue.js’ core doesn’t come with routing or<br />

ajax functionalities by default, and usually assumes you are building the application using an<br />

external module bundler. This is probably the most important distinction.<br />

• Angular uses two-way binding between scopes. While Vue also supports explicit two-way<br />

bindings, it defaults to a one-way, parent-to-child data flow between components. Using oneway<br />

binding makes the flow of data easier to reason about in large apps.<br />

• Vue.js has a clearer separation between directives and components. Directives are meant to<br />

encapsulate DOM manipulations only, while Components stand for a self-contained unit that<br />

has its own view and data logic. In Angular there’s a lot of confusion between the two.<br />

• Vue.js has better performance and is much, much easier to optimize, because it doesn’t use<br />

dirty checking. Angular gets slow when there are a lot of watchers, because every time<br />

anything in the scope changes, all these watchers need to be re-evaluated again. Also, the<br />

digest cycle may have to run multiple times to “stabilize” if some watcher triggers another<br />

update. Angular users often have to resort to esoteric techniques to get around the digest<br />

cycle, and in some situations there’s simply no way to optimize a scope with a large amount<br />

of watchers. Vue.js doesn’t suffer from this at all because it uses a transparent dependencytracking<br />

observing system with async queueing - all changes trigger independently unless<br />

they have explicit dependency relationships. The only optimization hint you’ll ever need is<br />

the track-by param on v-for lists.<br />

Interestingly, there are quite some similarities in how Angular 2 and Vue are addressing these<br />

Angular 1 issues.

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!