【翻譯】ExtJSvsAngularJS

原文:ExtJS vs AngularJS

創(chuàng)新互聯(lián)堅(jiān)持“要么做到,要么別承諾”的工作理念,服務(wù)領(lǐng)域包括:網(wǎng)站設(shè)計制作、成都網(wǎng)站制作、企業(yè)官網(wǎng)、英文網(wǎng)站、手機(jī)端網(wǎng)站、網(wǎng)站推廣等服務(wù),滿足客戶于互聯(lián)網(wǎng)時代的豐澤網(wǎng)站設(shè)計、移動媒體設(shè)計的需求,幫助企業(yè)找到有效的互聯(lián)網(wǎng)解決方案。努力成為您成熟可靠的網(wǎng)絡(luò)建設(shè)合作伙伴!

ExtJS和AngularJS是兩個行業(yè)內(nèi)領(lǐng)先的富界面開發(fā)框架。TechFerry有機(jī)會使用Ext JS和Angular JS來開發(fā)多個富界面的單頁面應(yīng)用程序。本文講述的就是使用這兩種技術(shù)來開發(fā)多個應(yīng)用程序后的開發(fā)體驗(yàn)。本文圍繞利弊、架構(gòu)、測試、移動能力、性能、生成和部署等方面對Ext JS和Angular JS進(jìn)行了超過30個以上的要點(diǎn)進(jìn)行了比較。

我們將通過使用Ext JS和Angular JS開發(fā)一個測試應(yīng)用程序來了解架構(gòu)細(xì)節(jié),以便進(jìn)行詳細(xì)的性能比較測試。對于性能報告,我們使用了類似的組件集,采用了固定的生成過程,以確保比較是同類比較。


Sencha Ext JS

  • 業(yè)界最強(qiáng)大的富界面應(yīng)用程序開發(fā)框架

  • 無與倫比的跨瀏覽器兼容性

  • 先進(jìn)的MVC架構(gòu)

  • 無插件的圖表

  • 現(xiàn)代UI部件

AngularJS
  • HTML增強(qiáng)的Web應(yīng)用程序

  • 與其他庫的完整擴(kuò)展能力和好的協(xié)同表現(xiàn)

  • 開源的Javascript框架,由谷歌維護(hù)

  • 聲明式編程



Sencha ExtJS 和AngularJS 的比較

Sno功能ExtJSAngularJS
1.一站式富界面應(yīng)用程序
2.具有豐富的主題套件能力的UI組件
幸運(yùn)的是,有大量的開源的商業(yè)組件,為Angular JS提供了集成組件,包括AngularUI、AngularUI Bootstrap、Kendo(或Angular-Kend)、Wijmo或其他。
3.打頁面應(yīng)用程序的設(shè)計
4.跨瀏覽器兼容性
Angular JS依賴于jqLite/JQuery來提供跨瀏覽器的兼容能力。但與其他第三方庫集成可能需要跨瀏覽器兼容能力。
注意:Angular JS(1.3及以上)已經(jīng)不支持IE8了,而Sencha Ext JS 5還會繼續(xù)支持IE8。如果你的企業(yè)用戶需要支持IE8,應(yīng)考慮Ext JS。
5.圖表
Ext JS獨(dú)立圖表是業(yè)內(nèi)最強(qiáng)大和最先進(jìn)的,對于大多數(shù)商業(yè)應(yīng)用程序來說,它的插件是免費(fèi)和足夠應(yīng)付的。AngularJS D3圖表基本上就是集成的D3圖表,這讓它擁有了令人驚異的圖表和圖形繪制功能。使用D3.js,你會愛上D3圖表的。
6.學(xué)習(xí)曲線
中等
架構(gòu)
7.應(yīng)用程序設(shè)計框架
MVC

還可看看 ExtJS 5 Beta
MVW (Model-View-Whatever).
它可支持流行的模式,如模型-視圖-控制器或模型-視圖-視圖模型
8.依賴注入對于依賴注入,Ext JS可以通過擴(kuò)充Deft JS來添加Ioc(Inversion of Control,控制反轉(zhuǎn))容器。
9.雙向數(shù)據(jù)綁定
10.直接的DOM操作
11.模塊化
測試
12.自動化測試支持可通過外部工具實(shí)現(xiàn)
13.測試框架或測試運(yùn)行器一些流行的第三放javascript測試框架,如Siesta(專門為Ext JS進(jìn)行了優(yōu)化)、Jasmine和Mocha,都可用于測試。AngularJS依靠它自己的端到端測試運(yùn)行器(Karma)來實(shí)現(xiàn)集成測試。Protractor就是針對Angular應(yīng)用程序的端到端測試框架。
性能
14.Dom 算法
深度優(yōu)先、自底往上的算法對于DOM樹,指令是深度優(yōu)先、自底往上的算法。而對于控制器則是自上往下的方式。
15.性能較高的覆蓋面/重量,因此Ext JS相對比較慢。在性能測試中,Angular比Ext JS輕3倍。請參閱性能比較統(tǒng)計。
16.輕量級-較小的下載覆蓋面
移動能力
17.Web應(yīng)用程序的移動支持Sencha建議使用Sencha Touch來開發(fā)應(yīng)用程序的移動版本。在移動設(shè)備上,像嵌套列表這樣的組件比網(wǎng)格更實(shí)用。不過,這意味著需要為應(yīng)用程序開發(fā)移動版本。使用ng-touch庫實(shí)現(xiàn)響應(yīng)式Web應(yīng)用程序,angular-gestures(手勢)和AngularJS響應(yīng)式模塊。
18.跨平臺本地移動應(yīng)用程序/混合應(yīng)用程序通過Sencha Touch集成Apache Cordova/Phonegap實(shí)現(xiàn)。通過Trigger.io、Cordova/Phonegap集成基于AngularJS優(yōu)化過Ionic框架實(shí)現(xiàn),可用來開發(fā)富界面和可靠的移動應(yīng)用程序。
19.移動網(wǎng)站
Sencha touch可用來開發(fā)移動網(wǎng)站。AngularJS響應(yīng)模塊(angular-responsive, angular-deckgrid等)、UI Boostrap、AngularJS responsive directives, angular-gestures 和ngTouch庫。
路由
20.內(nèi)置路由

參閱 ExtJS 5 Beta
21.深度鏈接

參閱 ExtJS 5 Beta
22.瀏覽器歷史、向前、向后按鈕支持t通過Ext.util.History實(shí)現(xiàn)
23.瀏覽器書簽支持

參閱ExtJS 5 Beta
24.SEO支持
大多數(shù)單頁面應(yīng)用程序需要通過身份驗(yàn)證后才能使用,因而一般不需要SEO索引。對于公共頁面,可使用靜態(tài)HTML/CSS來實(shí)現(xiàn),如果需要實(shí)現(xiàn)的動態(tài)內(nèi)容,可考慮AjaxBased SEO。可考慮使用Prerender.io或在Web服務(wù)器中實(shí)現(xiàn)無頭的瀏覽器支持來實(shí)現(xiàn)基于Ajax的SEO。
部署
25.生成工具針對Ext JS 4.x+的Sencha cmd 工具或針對Ext JS 3.x的Sencha sdk工具第三放的 Grunt 工具
26.包管理工具Sencha cmd
Yeoman, Grunt 或 Bower
協(xié)議和支持
27.協(xié)議:開源或商業(yè)Per-seat / per-server的商業(yè)協(xié)議或GPL許可下的開源協(xié)議MT許可下的開源javascript框架
28.完整的文檔套件、教程、視頻示例、培訓(xùn)
29.支持:一般性討論、Bug報告和定制功能需求基于Web的公共或白金(僅付費(fèi)的訂閱用戶)支持
公共支持
30.完全的樂趣和滿足:在整個應(yīng)用程序開發(fā)生命周期內(nèi),不需要考慮所選擇的第三庫新版本發(fā)布或bug修復(fù)
其他
31.內(nèi)置動畫支持
32.Deferred 和Promises.DeftJS提供了一些Ext JS擴(kuò)展,包含了Deferred和Promises.
33.Dirty Checking(臟檢查)
34.Deferred BootstrapUntil now, ExtJS applications' testing has never required delay in the Bootstrap as third-party JavaScript testing frameworks which are used for ExtJS application testing do not require deferring the bootstrap.Angular Scenario Runner and Batrang require Deferred Bootstrap and hence Deferred Bootstrap concept is introduced to allow end to end tests.

性能比較統(tǒng)計

為了評估這兩個框架的性能,我們開發(fā)了一個包含網(wǎng)格、樹和圖表組件的小型的應(yīng)用程序。這兩種技術(shù)都是按照規(guī)定的生成過程來進(jìn)行的,因此,我們可以使用最小化的生成來進(jìn)行量級比較。YSlow用來收集性能數(shù)據(jù)。其他的細(xì)節(jié):

  • Ext JS:使用網(wǎng)格、樹和圖表組件

  • Angular JS:使用angular-charts.min.js、angular.min.js、jquery.min.js、angular- route.min.js、ng-grid-2.0.7.min.js、angular.treeview.min.js、angular- animate.js模塊

  • 對于這些組件的數(shù)據(jù)部分,使用的是同意的http請求,同樣的Web服務(wù)器。

  • 結(jié)論:Ext JS比AngularJS重3倍

Ext JS


【翻譯】ExtJS vs AngularJS

AngularJS:

【翻譯】ExtJS vs AngularJS

如果使用ext-all,那么統(tǒng)計結(jié)果是:

【翻譯】ExtJS vs AngularJS

框架的選擇:

使用Ext JS:

  • 使用Sencha Ext JS提供的方便的組件,可節(jié)省大量時間。

  • 如果擔(dān)心編程和開發(fā)時的兼容性問題,它是一大亮點(diǎn)。

  • 你或你的客戶需要專門的許可或?qū)I(yè)支持。

  • 如果富桌面應(yīng)用程序(使用Ext JS)和移動Web應(yīng)用程序(使用Sencha Touch)是獨(dú)立,這相當(dāng)實(shí)用。

  • 可承擔(dān)支持合約或per-seat / per-server 的商業(yè)許可。

使用AngularJS:

  • 要求較小的足跡。更多詳細(xì)信息,請參閱性能比較統(tǒng)計。

  • 應(yīng)用程序要求響應(yīng)式設(shè)計。

  • 你的組織需要尋求自動化測試的價值,以及自動化測試是你們開發(fā)文化的一部分。

  • 要整合的第三放組件是免費(fèi)的,因而成本比較低。

  • 團(tuán)隊(duì)更關(guān)注CSS和跨瀏覽器的兼容性問題。

  • 在整個應(yīng)用程序開發(fā)生命周期內(nèi),團(tuán)隊(duì)能夠很好的管理所集成的第三方庫的新版本或bug修復(fù)。

架構(gòu)差異:

我們嘗試從以下10個方面來比較Ext JS和AngularJS之間的架構(gòu)差異:

  • 應(yīng)用程序設(shè)計框架

  • 組件

  • 路由的好處

  • 可測試性

  • 數(shù)據(jù)綁定

  • SEO的友好性

  • 移動解決方案

  • DOM算法

  • Deferred和Promises

  • 臟檢查

  • Deferred bootstrap

摘要:

Ext JS是基于組件(網(wǎng)格、樹、表單和圖表)的,代碼開始于擴(kuò)展的API類和配置模塊,如果需要,可自定義延時文稿或行為/事件,將這些組件添加到容器/布局。它遵循面向?qū)ο笤瓌t和MVC模式,很少需要與DOM直接交互。

AngularJS,剛好相反,它是聲明式編程,開始時,需要在純HTML中添加AngularJS指令、配置模塊、使用模板或路由來配置視圖,而且框架還有關(guān)注DOM的創(chuàng)建。由于要處理HTML,因而需要直接與HTML結(jié)構(gòu)或DOM元素交互。

應(yīng)用程序設(shè)計框架

Ext JS:
  • 遵循 MVC框架.

  • 隨著Ext JS應(yīng)用程序的大小和復(fù)雜性的增加,Sencha Touch和Ext JS可以通過加入Deft JS來添加Ioc容器、針對依賴注入和動態(tài)應(yīng)用程序的程序集。

  • 基于組件和hence模塊

AngularJS:
  • AngularJS是增強(qiáng)的HTML Web一個月程序

  • 它被描述為“Model-View-Whatever”框架,它沒有規(guī)定是哪一種特定的應(yīng)用程序架構(gòu)或哪一套模式。然而,它足夠靈活去支撐流行的模式,如模型-視圖-控制器或模型-視圖-視圖模型。

  • 基于模塊。依賴于模塊內(nèi)的html元素。


組件:

Ext JS:

Ext JS區(qū)別于其他框架的一個主要特性就是包含一套有豐富的主題能力的UI組件。
 Pros:
使用Ext JS提供的方便的組件可以節(jié)省大量時間。
Cons:

Sencha組件往往會產(chǎn)生冗長的DOM輸出,其結(jié)果就是需要更多標(biāo)簽。

AngularJS:
  • AngularJS不能解決的問題是沒有豐富用戶接口組件。

  • 不過,有大量的開源或商業(yè)組件可以集成到AngularJS,包括AngularUI、AngularUI Bootstrap、Kendo (或 Angular-Kendo)、 Wijmo以及其他。


路由的好處

ExtJS:

Ext JS沒有路由。不過,許多單頁面應(yīng)用程序可能不需要路由,除非你希望通過內(nèi)部/深度鏈接來實(shí)現(xiàn)SEO友好性或支持書簽。
AngularJS:
  • AngularJS路由連接著瀏覽器中的控制器、視圖模板和當(dāng)前URL定位。使用該特性就可實(shí)現(xiàn)深度鏈接。

  • 深度鏈接是由網(wǎng)站中指定的、可搜索的或可索引的內(nèi)容塊的連接所組出的超鏈接。它可以讓我們利用瀏覽器的歷史記錄(后退或前進(jìn)導(dǎo)航)已經(jīng)瀏覽器的書簽功能。


可測試性:

ExtJS:
  • 使用Sencha框架生成的應(yīng)用程序可使用幾個流行的第三方j(luò)avascript測試框架來測試,如Siesta(基于Ext JS進(jìn)行了優(yōu)化)、Jasmine和Mocha。

  • Sencha產(chǎn)品套件沒有包含測試框架或測試運(yùn)行器。

AngularJS:
  • AngularJS從創(chuàng)建之初開始就被設(shè)計為可測試的應(yīng)用程序。

  • 它支持三方面的自動化測試:單一、集成和功能測試。

  • AngularJS團(tuán)隊(duì)還開發(fā)了它自己的Karma測試運(yùn)行器。另外,第三方工具Protractor是針對Angular應(yīng)用程序的端到端測試框架。


雙向數(shù)據(jù)綁定:
雙向數(shù)據(jù)綁定是應(yīng)用程序UI和模型對象之間的粘合劑,這樣,對象屬性的改變就會反映到UI,反之亦然。

ExtJS:

通過使用存儲對象,Ext JS有著優(yōu)秀的數(shù)據(jù)綁定功能。為了執(zhí)行雙向數(shù)據(jù)綁定,還需要執(zhí)行一些工作,如重新加載存儲等等。
AngularJS:
AngularJS的雙向數(shù)據(jù)綁定基本上是通過嵌套在原型繼承樹上的模型來實(shí)現(xiàn)的。

Cons:
如果模板綁定的數(shù)據(jù)有2000到3000,應(yīng)用程序會變得遲鈍。

Bindonce is a great way to minimize the number of watches when most of the data presented in your page, once rendered, are immutable and you need not keep watching them for changes.

SEO Friendliness:
Most of the single page apps which work behind authentication need not be indexed for SEO. If you have some pages in your app which are public and which needs to be indexed, you can createthem separately, either with static HTML/CSS or if you do need to use dynamic content, consider Ajaxbased SEO as described below.

Ajax based SEO: For the indexing of dynamic / ajax-based single page web apps, all you have to do is to generate the additional static content so that when the crawlers access your page, they get easy access to that static content and when the users access your page, they see the app. To achieve this functionality you could either use some tools like Prerender.io: fully open-source  or you have to set up the headless browser support in your web-server which is an additional effort.
ExtJS:

  Ajax based seo is possible in ExtJS with hashbang urls' support in your web-server.
AngularJS:

 
  • AngularJS seo with Prerender.io: When a crawler visits your page at hashbang url,   the Prerender service will check and see if it has a snapshot or already rendered page    for that URL, if yes, it will send it to the crawler, if not, it will render    a snapshot on the fly and send the rendered HTML to the crawler for correct indexing.

  • Alternatively, you can also build support for hashbang URLswhich may require you to set-up your web-server to summon-up the    headless html browser.


Mobile Solutions:

ExtJS:

  • Sencha Touch - the industry-leading and high-performance mobile HTML5 framework,  is used to develop powerful, universal mobile web apps / mobile website.

  • Sencha touch integration with Cordova/Phonegap  is used to develop the cross platform hybrid applications.

AngularJS:

  • AngularJS can be used to develop responsive web apps / websites although all the angular modules are not responsive.

  • To develop the cross platform hybrid applications, integrate AngularJS with

    • Trigger.io

    • Ionic Framework - Advanced Html5 hybrid mobile framework and optimized for AngularJS

    • Cordova/Phonegap


Dom Approach:

ExtJS:

It follows the Depth First, Bottom-Up approach.
AngularJS:

Directives are linked in a Depth-First, Bottom-Up approach to the DOM tree.Controllers are linked in a top-down manner.

Deferred and Promises:
Deferred and Promises break the complexities of asynchronous programming, separate out the synchronous and asynchronous world, remove the tight coupling between the twoThey are for asynchronous programming what try, catch and throw keywords are for synchronous programming.

ExtJS:

ExtJS augmented with DeftJS may provide Deferred and Promises.
AngularJS:

AngularJS offers an implementation of the Q API for Deferred and Promises.

Dirty Checking
Dirty checking in nutshell: The framework compares the old value and new value and if they are different, fires the change event.

ExtJS:

  • ExtJS 4.x uses the store's binding feature to execute the dirty checking.

  • ExtJS store allows you to delay the process of dirty checking via its autoSync config which when set to false, the user changes are marked with dirty flags in UI and are updated in batch when the user saves the store.

  • To reflect the changes in the real data in UI, a little work is to be done like reloading the store etc

AngularJS:

  • Angular uses the Digest Cycle to execute the dirty checking.

  • With Angular api, you do not need to manaually call the digest cycle, angular internally fires digest cycle followed by updation of the dom but  from third party api, you need to call $apply method to enter the digest cycle.

  • Changes are reflected in the real data in UI as soon as the digest cycle is finished.

  • The dirty checking is done asynchronously.

Cons:
  • Application becomes laggy if there are 2000-3000 watches in a template... more

Bindonce is a great way to minimize the number of watches when most of the data presented in your page, once rendered, are immutable and you need not keep watching them for changes.

Deferred bootstrap:
Bootstrap means the initialization process. Deferred bootstrap is to make a delay in the bootstrap process to mock out the heavy dependencies or for the instrumentation purposes. Deferred bootstrap is primarily introduced to allow end to end tests.

Although deferred bootstrap has no value in the developement and testing of most single page applications, yet it serves its value in AngularJS applications' end to end testing. Some javascript test runners such as Batrang and  Angular Scenario Runner (which are developed by AngularJS team for the end to end testing of the angularJS applications) require deferred bootstrap.

ExtJS:

Several popular third-party JavaScript testing frameworks such as Siesta (optimized specifically for Ext JS), Jasmine and Mocha, are being used for ExtJS applications testing  which do not require deferring the ExtJS application's bootstrap.
AngularJS:

  • Batrang is a new Chrome extension, recommended by the angular team, provides the tools to address performance bottlenecks, visualize and debug applications.

  • AngularJS Batarang and Angular Scenario Runner require Deferred Bootstrap feature to hook into angular's bootstrap process and sneak in more modules into the DI registry which  can replace or augment DI services for the purpose of instrumentation or mocking out  heavy dependencies.




Digest Cycle in AngularJS:
  • The digest cycle is all about reacting to changes in data.

  • Generally what happens is, the browser's event-loop waits for an event to arrive, as long as it recives an event, it emits the event on the input controls which is then captured in the corresponding directive's event handler which calls apply function, to enter into Angular execution context, with function/expression (the work you wish to do in Angular execution context) as parameter.

  • Model mutation is then executed in apply function with all the error handling followed by the firing of the digest cycle in its finally phase.

  • In all the  Dirty Cycle mechanisms,  all the watchers in the watch list are iterated and in each iteration watch expression in current scope is evaluated, old and new value of scope is compared and if both values differ,then the corresponding listener of the watcher function is fired which upon execution calls digest cycle again with one of the two possilities:

    • If the listener function does not modify the scope then in the running digest turn, model is declared as stable and digest loop is finished followed by the browser re-painting of the DOM node which was dirty.

    • If scope is modified, then it will fire the other listeners, so the watchers keep re-running until until no more watchers are fired and a max limit of 10 iterations is reached when $digest will throw 'Maximum iteration limit exceeded' to prevent infinite loops.

  • This dirty checking is done asynchronously.

Three mechanisms of Dirty Checking:
  • Reference-Based Dirty-Checking: The old value is compared to the new with the strict equality operator===  which detect the new and old values are the same "physical" object.It is the most efficient both in terms of computation and memory, since it doesn't do copying or traversal. It merely keeps a reference to the value around for comparison.

  • Value-Based Dirty-Checking: It performs a deep-object-tree comparison.This means that within each $digest cycle, AngularJS will check to see if the new and old values have the same structure.

  • Collection-based dirty checking: It works by comparing physical object references. Collection watchers keep an internal copy of the array or object, and traverse the old and new values in each digest cycle, checking for  changes using the strict equality operator === i.e. unlike the reference based dirty checking, it  goes one-level deep and   performs an additional, shallow reference check of the top level items in the collection.

Cons of dirty checking:
Application becomes laggy if there are 2000-3000 watches in a template.
 Although anything faster than 50ms is imperceptible to humans and you can't really show more than about 2000 pieces of information to a human on a single page because anything more than that is really a bad UI and humans can't process this anyway, yet while building any sort of widget or  data grid with two-way binding you may easily hit 2000 bindings without the bad UI.

Watcher:

By default all the model data that is bound to UI are being watched upon i.e.  they all have a watcher registered in the watch list, a collection used by digest cycle for the dirty checking. You can also attach a watcher to the scope by using $watch function.  A watcher has two functions:  A watch function or a watch expression, which specifies the piece of data you are interested in. A listener function which will be called whenever that data changes.

 Asynchronous nature of dirty cycle:

 Assignment such as $scope.username="angular" will not immediately   cause a $watch to be notified, instead the $watch notification is delayed   until the $digest phase. This delay is desirable, since it coalesces multiple   model updates into one $watch notification as well as it guarantees that   during the $watch notification no other $watches are running.   If a $watch changes the value of the model, it will force additional $digest cycle.


ExtJS 5 Beta:

Recently launched ExtJS5 Beta version provides support for router and hence deep linking is now possible.ExtJS 5 also supports MVC and MVVM.

We will review and update the article as and when new and stable versions of ExtJS and AngularJS are released.

當(dāng)前名稱:【翻譯】ExtJSvsAngularJS
轉(zhuǎn)載來源:http://bm7419.com/article16/pcdjdg.html

成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供網(wǎng)站收錄、App設(shè)計、外貿(mào)建站外貿(mào)網(wǎng)站建設(shè)云服務(wù)器、網(wǎng)站營銷

廣告

聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請盡快告知,我們將會在第一時間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時需注明來源: 創(chuàng)新互聯(lián)

成都做網(wǎng)站