Corona,Phonegap,Titanium的比較

本文翻譯自:Comparison between Corona, Phonegap, Titanium

I am a web developer and I want to move my web products to iPhone. 我是一名網絡開發人員,我想將我的網絡產品移至iPhone。 One of the products is like Google Maps: show map on the phone screen, you can drag or resize the map and view some information that we add to the map. 其中一個產品就像Google地圖:在手機屏幕上顯示地圖,您可以拖動或調整地圖大小並查看我們添加到地圖中的一些信息。

I know there are some technologies that enables you to use HTML, CSS and Javascript to develop native iPhone apps. 我知道有一些技術可以讓您使用HTML,CSS和Javascript來開發本機iPhone應用程序。 I've identified a few: 我發現了一些:

Are there other, similar products? 還有其他同類產品嗎? What are the differences between them? 它們之間有什麼區別? Which should I choose? 我該選哪個?


#1樓

參考:https://stackoom.com/question/6Dgg/Corona-Phonegap-Titanium的比較


#2樓

Of the solutions you mentioned, none of them appear to give you direct access to the MapKit framework introduced in OS 3.0. 在您提到的解決方案中,沒有一個可以讓您直接訪問OS 3.0中引入的MapKit框架。

As the Google Maps HTML widgets aren't nearly as good as MapKit (see Google Latitude for an example), you are probably best off developing a native Cocoa touch application, or choosing a solution you can extend to add MapKit integration. 由於Google Maps HTML小部件不如MapKit(例如,請參閱谷歌縱橫),您可能最好開發本機Cocoa touch應用程序,或者選擇可以擴展以添加MapKit集成的解決方案。 PhoneGap is extensible in this manner (it's open-source so it is by default), and some of the other solutions might be as well. PhoneGap可以這種方式擴展(默認情況下它是開源的),其他一些解決方案也可能。

edit: Titanium now has support for MapKit 編輯:Titanium現在支持MapKit


#3樓

From what I've gathered, here are some differences between the two: 從我收集的內容來看,這兩者之間存在一些差異:

  • PhoneGap basically generates native wrappers for what are still web apps . PhoneGap基本上爲仍然是Web應用程序生成本機包裝器。 It spits out a WhateverYourPlatformIs project, you build it, and deploy. 它會吐出一個WhateverYourPlatformIs項目,你可以構建它並進行部署。 If we're talking about the iPhone (which is where I spend my time), it doesn't seem much different from creating a web app launcher (a shortcut that gets its own Springboard icon, so you can launch it like ( like ) a native app). 如果我們談論iPhone(這是我花費時間的地方),它與創建一個Web應用程序啓動器(一個獲得自己的Springboard圖標的快捷方式)似乎沒什麼不同,所以你可以像( )那樣啓動它本機應用程序)。 The "app" itself is still html/js/etc., and runs inside a hosted browser control. “app”本身仍然是html / js / etc.,並在託管瀏覽器控件中運行。 What PhoneGap provides beyond that is a bridge between JavaScript and native device APIs. 除此之外,PhoneGap提供的是JavaScript和本機設備API之間的橋樑。 So, you write JavaScript against PhoneGap APIs, and PhoneGap then makes the appropriate corresponding native call. 因此,您針對PhoneGap API編寫JavaScript,然後PhoneGap進行相應的本地調用。 In that respect, it is different from deploying a plain old web app. 在這方面,它部署一個普通的舊的Web應用程序不同。

  • Titanium source gets compiled down to native bits. Titanium源被編譯爲本機位。 That is, your html/js/etc. 也就是你的html / js / etc. aren't simply attached to a project and then hosted inside a web browser control - they're turned into native apps. 不是簡單地附加到項目然後託管在Web瀏覽器控件中 - 它們變成了本機應用程序。 That means, for example, that your app's interface will be composed of native UI components. 這意味着,例如,您的應用程序界面將由本機 UI組件組成。 There are ways of getting native look-and-feel without having a native app, but... well... what a nightmare that usually turns out to be. 有一些方法可以在沒有本機應用程序的情況下獲得原生外觀,但是......嗯......這通常是一場噩夢。

The two are similar in that you write all your stuff using typical web technologies (html/js/css/blah blah blah), and that you get access to native functionality through custom JavaScript APIs. 兩者的相似之處在於您使用典型的Web技術編寫所有內容(html / js / css / blah blah blah),並且您可以通過自定義JavaScript API訪問本機功能。

But, again, PhoneGap apps (PhonGapps? I don't know... is that a stupid name? It's easier to say - I know that much) start their lives as web apps and end their lives as web apps. 但是,再次,PhoneGap應用程序(PhonGapps?我不知道......這是一個愚蠢的名字?它更容易說 - 我知道那麼多)作爲網絡應用程序開始他們的生活,並結束他們作爲網絡應用程序的生活。 On the iPhone, your html/js/etc. 在iPhone上,你的html / js /等。 is just executed inside a UIWebView control, and the PhoneGap JavaScript APIs your js calls are routed to native APIs. 只是在UIWebView控件內執行,而您的js調用的PhoneGap JavaScript API被路由到本機API。

Titanium apps become native apps - they're just developed using web dev tech. Titanium應用程序成爲原生應用程序 - 它們只是使用Web開發技術開發的。

What does this actually mean ? 這究竟意味着什麼?

  1. A Titanium app will look like a "real" app because, ultimately, it is a "real" app. Titanium應用程序看起來像一個“真正的”應用程序,因爲它最終一個“真正的”應用程序。

  2. A PhoneGap app will look like a web app being hosted in a browser control because, ultimately, it is a web app being hosted in a browser control. PhoneGap應用程序看起來像是一個託管在瀏覽器控件的Web應用程序,因爲它最終一個託管在瀏覽器控件中的Web應用程序。

Which is right for you? 哪個適合你?

  • If you want to write native apps using web dev skills, Titanium is your best bet. 如果您想使用Web開發技能編寫本機應用程序,Titanium是您最好的選擇。

  • If you want to write an app using web dev skills that you could realistically deploy to multiple platforms (iPhone, Android, Blackberry, and whatever else they decide to include), and if you want access to a subset of native platform features (GPS, accelerometer, etc.) through a unified JavaScript API, PhoneGap is probably what you want. 如果你想使用web開發技能編寫一個應用程序,你可以實際部署到多個平臺(iPhone,Android,Blackberry,以及他們決定包含的任何其他平臺),如果你想訪問本機平臺功能的一個子集(GPS,加速度計等)通過統一的JavaScript API,PhoneGap可能就是你想要的。

You might be asking: Why would I want to write a PhoneGapp (I've decided to use the name) rather than a web app that's hosted on the web? 你可能會問:我爲什麼要寫一個PhoneGapp(我決定使用這個名字)而不是一個在網絡上託管的網絡應用程序? Can't I still access some native device features that way, but also have the convenience of true web deployment rather than forcing the user to download my "native" app and install it? 我仍然無法以這種方式訪問​​某些本機設備功能,但也具有真正的Web部署的便利,而不是強迫用戶下載我的“本機”應用程序並安裝它?

The answer is: Because you can submit your PhoneGapp to the App Store and charge for it. 答案是:因爲您可以將您的PhoneGapp提交到App Store併爲其收費。 You also get that launcher icon, which makes it harder for the user to forget about your app (I'm far more likely to forget about a bookmark than an app icon). 您還會獲得啓動器圖標,這會讓用戶更難忘記您的應用程序(我更可能忘記書籤而不是應用程序圖標)。

You could certainly charge for access to your web-hosted web app, but how many people are really going to go through the process to do that? 您當然可以收取訪問您的網絡託管的網絡應用程序的費用,但是有多少人真的要經歷這個過程呢? With the App Store, I pick an app, tap the "Buy" button, enter a password, and I'm done. 通過App Store,我選擇一個應用程序,點擊“購買”按鈕,輸入密碼,我就完成了。 It installs. 它安裝。 Seconds later, I'm using it. 幾秒鐘後,我正在使用它。 If I had to use someone else's one-off mobile web transaction interface, which likely means having to tap out my name, address, phone number, CC number, and other things I don't want to tap out, I almost certainly wouldn't go through with it. 如果我不得不使用其他人的一次性移動網絡交易界面,這可能意味着必須點擊我的名字,地址,電話號碼,CC號碼以及其他我不想挖掘的東西,我幾乎肯定不會經歷它。 Also, I trust Apple - I'm confident Steve Jobs isn't going to log my info and then charge a bunch of naughty magazine subscriptions to my CC for kicks. 此外,我相信蘋果 - 我相信史蒂夫喬布斯不會記錄我的信息,然後收取一堆頑皮的雜誌訂閱我的CC踢。

Anyway, except for the fact that web dev tech is involved, PhoneGap and Titanium are very different - to the point of being only superficially comparable. 無論如何,除了涉及web dev技術這一事實之外,PhoneGap和Titanium是非常不同的 - 只是表面上可比較。

I hate web apps, by the by, and if you read iTunes App Store reviews, users are pretty good at spotting them. 我討厭網絡應用程序,如果您閱讀iTunes App Store評論,用戶非常擅長髮現它們。 I won't name any names, but I have a couple "apps" on my phone that look and run like garbage, and it's because they're web apps that are hosted inside UIWebView instances. 我不會說出任何名字,但我的手機上有幾個“應用程序”看起來像垃圾一樣運行,這是因爲它們是在UIWebView實例中託管的網絡應用程序。 If I wanted to use a web app, I'd open Safari and, you know, navigate to one. 如果我想使用網絡應用程序,我會打開Safari,你知道,導航到一個。 I bought an iPhone because I want things that are iPhone-y. 我買了一部iPhone,因爲我想要的東西是iPhone-y。 I have no problem using, say, a snazzy Google web app inside Safari, but I'd feel cheated if Google just snuck a bookmark onto Springboard by presenting a web app as a native one. 我在Safari中使用一個時髦的谷歌網絡應用程序沒有問題,但如果谷歌只是通過將一個網絡應用程序作爲本地應用程序發佈到Springboard上,我會感到受騙。

Have to go now. 要離開了。 My girlfriend has that could-you-please-stop-using-that-computer-for-three-seconds look on her face. 我的女朋友可以讓你停止使用那臺計算機三秒鐘的表情。


#4樓

My understanding of PhoneGap is that they provide Javascript APIs to much of the iPhone APIs. 我對PhoneGap的理解是它們爲大多數iPhone API提供了Javascript API。

Titanium seems easier for a web developer background. 對於Web開發人員來說,Titanium似乎更容易。 It is a simple XML file to create a basic TabView application and then everything in the content area is controlled by HTML / JS. 它是一個簡單的XML文件,用於創建基本的TabView應用程序,然後內容區域中的所有內容都由HTML / JS控制。 I also know that Titanium does provide some javascript access to some of the frameworks (particularly access to location information, the phone ID, etc). 我也知道Titanium確實提供了對某些框架的一些javascript訪問(特別是訪問位置信息,電話ID等)。

UPDATE: Titanium added Maps API in version 0.8 of their framework. 更新:Titanium在其框架的0.8版本中添加了Maps API。


#5樓

You should learn objective c and program native apps. 您應該學習目標c並編寫本機應用程序。 Do not rely on these things you think will make life easier. 不要依賴這些你認爲會讓生活更輕鬆的事情。 Apple has made sure the easiest way is using their native tools and language. Apple確保最簡單的方法是使用他們的原生工具和語言。 For your 100 lines of javascript I can do the same in 3 lines of code or no code at all depending on the element. 對於你的100行javascript,我可以在3行代碼中完成相同的操作,或者完全沒有代碼,具體取決於元素。 Watch some tutorials - if you understand javascript then objective c is not hard. 觀看一些教程 - 如果你理解javascript那麼客觀c並不難。 Workarounds are miserable and apple can pull the plug on you anytime they want. 解決方法很糟糕,蘋果可以隨時隨地拔掉插頭。


#6樓

I registered with stackoverflow just for the purpose of commenting on the mostly voted answer on top. 我在stackoverflow上註冊只是爲了評論最多的投票答案。 The bad thing is stackoverflow does not allow new members to post comments. 糟糕的是stackoverflow不允許新成員發表評論。 So I have to make this comment more look like an answer. 所以我必須讓這個評論更像是一個答案。

Rory Blyth's answer contains some valid points about the two javascript mobile frameworks. Rory Blyth的答案包含了關於兩個javascript移動框架的一些有效點。 However, his key points are incorrect. 但是,他的關鍵點是不正確的。 The truth is that Titanium and PhoneGap are more similar than different. 事實是,Titanium和PhoneGap比不同更相似。 They both expose mobile phone functions through a set of javascript APIs, and the application's logic (html, css, javascript) runs inside a native WebView control. 它們都通過一組javascript API公開手機功能,應用程序的邏輯(html,css,javascript)在本機WebView控件中運行。

  1. PhoneGap is not just a native wrapper of a web app. PhoneGap不僅僅是Web應用程序的本機包裝器。 Through the PhoneGap javascript APIs, the "web app" has access to the mobile phone functions such as Geolocation, Accelerometer Camera, Contacts, Database, File system, etc. Basically any function that the mobile phone SDK provides can be "bridged" to the javascript world. 通過PhoneGap javascript API,“網絡應用程序”可以訪問手機功能,如地理位置,加速度計相機,聯繫人,數據庫,文件系統等。基本上,手機SDK提供的任何功能都可以“橋接”到javascript世界。 On the other hand, a normal web app that runs on the mobile web browser does not have access to most of these functions (security being the primary reason). 另一方面,在移動Web瀏覽器上運行的普通Web應用程序無法訪問大多數這些功能(安全性是主要原因)。 Therefore, a PhoneGap app is more of a mobile app than a web app. 因此,PhoneGap應用程序更像是一個移動應用程序而不是Web應用程序。 You can certainly use PhoneGap to wrap a web app that does not use any PhoneGap APIs at all, but that is not what PhoneGap was created for. 您當然可以使用PhoneGap來打包一個完全不使用任何PhoneGap API的Web應用程序,但這不是爲PhoneGap創建的。

  2. Titanium does NOT compile your html, css or javascript code into "native bits". Titanium不會將你的html,css或javascript代碼編譯成“native bits”。 They are packaged as resources to the executable bundle, much like an embedded image file. 它們作爲資源打包到可執行包中,就像嵌入的圖像文件一樣。 When the application runs, these resources are loaded into a UIWebView control and run there (as javascript, not native bits, of course). 當應用程序運行時,這些資源被加載到UIWebView控件並在那裏運行(當然是javascript,而不是本機位)。 There is no such thing as a javascript-to-native-code (or to-objective-c) compiler. 沒有javascript到本機代碼(或to-objective-c)編譯器這樣的東西。 This is done the same way in PhoneGap as well. 這在PhoneGap中也以相同的方式完成。 From architectural standpoint, these two frameworks are very similar. 從架構的角度來看,這兩個框架非常相似。

Now, are they any different? 現在,他們有什麼不同嗎? Yes. 是。 First, Titanium appears to be more feature rich than PhoneGap by bridging more mobile phone functions to javascript. 首先,通過將更多手機功能與javascript連接起來,Titanium似乎比PhoneGap功能更豐富。 Most noticeably, PhoneGap does not expose many (if any) native UI components to javascript. 最值得注意的是,PhoneGap不會將許多(如果有的話)本機UI組件暴露給javascript。 Titanium, on the other hand, has a comprehensive UI APIs that can be called in javascript to create and control all kinds of native UI controls. 另一方面,Titanium具有全面的UI API,可以在javascript中調用以創建和控制各種本機UI控件。 Utilizaing these UI APIs, a Titanium app can look more "native" than a PhoneGap app. 利用這些UI API,Titanium應用程序看起來比PhoneGap應用程序更“原生”。 Second, PhoneGap supports more mobile phone platforms than Titanium does. 其次,PhoneGap比Titanium支持更多的手機平臺。 PhoneGap APIs are more generic and can be used on different platforms such as iPhone, Android, Blackberry, Symbian, etc. Titanium is primarily targeting iPhone and Android at least for now. PhoneGap API更通用,可以在不同的平臺上使用,如iPhone,Android,Blackberry,Symbian等.Titanium主要針對iPhone和Android至少目前。 Some of its APIs are platform specific (like the iPhone UI APIs). 它的一些API是特定於平臺的(如iPhone UI API)。 The use of these APIs will reduce the cross-platform capability of your application. 使用這些API將降低應用程序的跨平臺功能。

So, if your concern for your app is to make it more "native" looking, Titanium is a better choice. 因此,如果您對應用程序的關注是使其更具“本機”外觀,那麼Titanium是更好的選擇。 If you want to be able to "port" your app to another platform more easily, PhoneGap will be better. 如果您希望能夠更輕鬆地將您的應用“移植”到另一個平臺,PhoneGap會更好。

Updated 8/13/2010: Link to a Titanium employee's answer to Mickey's question. 2010年8月13日更新: 鏈接到Titanium員工對Mickey問題的回答。

Updated 12/04/2010: I decided to give this post an annual review to keep its information current. 更新日期:12/04/2010:我決定對此帖進行年度審覈,以保持其最新信息。 Many things have changes in a year that made some of the information in the initial post outdated. 許多事情在一年內發生了變化,使得最初的帖子中的一些信息過時了。

The biggest change came from Titanium. 最大的變化來自Titanium。 Earlier this year, Appcelerator released Titanium 1.0, which departed drastically from its previous versions from the architectural standpoint. 今年早些時候,Appcelerator發佈了Titanium 1.0,從架構的角度來看,它大大偏離了以前的版本。 In 1.0, the UIWebView control is no longer in use. 在1.0中,UIWebView控件不再使用。 Instead, you call Titanium APIs for any UI functions. 相反,您可以爲任何UI功能調用Titanium API。 This change means a couple things: 這種變化意味着幾件事:

  1. Your app UI becomes completely native. 您的應用UI變得完全原生。 There is no more web UI in your app since the native Titanium APIs take over control of all your UI needs. 由於本機Titanium API可以控制您的所有UI需求,因此您的應用中不再有Web UI。 Titanium deserves a lot of credit by pioneering on the "Cross-Platform Native UI" frontier. 通過在“跨平臺原生UI”前沿上開拓,Titanium值得稱讚。 It gives programmers who prefer the look and feel of native UI but dislike the official programming language an alternative. 它爲程序員提供了更喜歡本機用戶界面的外觀和感覺,但卻不喜歡官方編程語言。

  2. You won't be able to use HTML or CSS in your app, as the web view is gone. 您將無法在應用中使用HTML或CSS,因爲Web視圖已消失。 (Note: you can still create web view in Titanium. But there are few Titanium features that you can take advantage of in the web view.) Titanium Q&A: What happened to HTML & CSS? (注意:您仍然可以在Titanium中創建Web視圖。但是,您可以在Web視圖中利用很少的Titanium功能。) Titanium問答:HTML和CSS發生了什麼?

  3. You won't be able to use popular JS libraries such as JQuery that assume the existence of an DOM object. 您將無法使用流行的JS庫,例如假定存在DOM對象的JQuery。 You continue to use JavaScript as your coding language. 您繼續使用JavaScript作爲編碼語言。 But that is pretty much the only web technology you can utilize if you come to Titanium 1.0 as a web programmer. 但是,如果您作爲Web程序員來到Titanium 1.0,那麼這幾乎是您可以利用的唯一Web技術。

Titanium video: What is new in Titanium 1.0. Titanium視頻:Titanium 1.0的新功能。

Now, does Titanium 1.0 compile your JavaScript into "native bits"? 現在,Titanium 1.0是否將您的JavaScript編譯爲“本機位”? No. Appcelerator finally came clean on this issue with this developer blog: Titanium Guides Project: JS Environment. 沒有。在這個開發者博客上,Appcelerator終於在這個問題上變得乾淨了: Titanium Guides Project:JS Environment。 We programmers are more genuine people than those in the Marketing department, aren't we? 我們的程序員比營銷部門的人更真誠,不是嗎? :-) :-)

Move on to PhoneGap. 轉到PhoneGap。 There are not many new things to say about PhoneGap. 關於PhoneGap的新內容並不多。 My perception is that PhoneGap development was not very active until IBM jumped on board later this year. 我的看法是,在IBM今年晚些時候加入之前,PhoneGap的開發並不是很活躍。 Some people even argued that IBM is contributing more code to PhoneGap than Nitobi is. 有些人甚至認爲IBM爲PhoneGap提供的代碼比Nitobi更多。 That being true or not, it is good to know that PhoneGap is being active developed. 這是真的與否,很高興知道PhoneGap正在積極開發。

PhoneGap continues to base itself on web technologies, namely HTML, CSS and JavaScript. PhoneGap繼續以Web技術爲基礎,即HTML,CSS和JavaScript。 It does not look like PhoneGap has any plan to bridge native UI features to JavaScript as Titanium is doing. 它看起來並不像PhoneGap有任何計劃將本機UI功能橋接到JavaScript,正如Titanium正在做的那樣。 While Web UI still lags behind native UI on performance and native look and feel, such gap is being rapidly closed. 雖然Web UI在性能和原生外觀方面仍落後於原生UI,但這種差距正在迅速縮小。 There are two trends in web technologies that ensure bright feature to mobile web UI in terms of performance: Web技術有兩種趨勢,可確保移動Web UI在性能方面具有明顯的特性:

  1. JavaScript engine moving from an interpreter to a virtual machine. JavaScript引擎從解釋器移動到虛擬機。 JavaScript is JIT compiled into native code for faster execution. JavaScript是JIT編譯成本機代碼以加快執行速度。 Safari JS engine: SquirrelFish Extreme Safari JS引擎:SquirrelFish Extreme

  2. Web page rendering moving from relying on CPU to using GPU acceleration. 網頁渲染從依賴CPU轉向使用GPU加速。 Graphic intensive tasks such as page transition and 3D animation become a lot smoother with the help of hardware acceleration. 藉助硬件加速,圖形密集型任務(如頁面過渡和3D動畫)變得更加順暢。 GPU Accelerated Compositing in Chrome GPU中的GPU加速合成

Such improvements that are originated from desktop browsers are being delivered to mobile browsers quickly. 源自桌面瀏覽器的此類改進正在快速傳遞到移動瀏覽器。 In fact, since iOS 3.2 and Android 2.0, the mobile web view control has become much more performing and HTML5 friendly. 事實上,自從iOS 3.2和Android 2.0以來,移動網絡視圖控件已經變得更加性能和HTML5友好。 The future of mobile web is so promising that it has attracted a big kid to town: JQuery has recently announced its mobile web framework. 移動網絡的未來是如此充滿希望,它吸引了一個大傢伙來到城鎮: JQuery最近宣佈了其移動網絡框架。 With JQuery Mobile providing UI gadgets, and PhoneGap providing phone features, they two combined creates a perfect mobile web platform in my opinion. 隨着JQuery Mobile提供UI小工具和PhoneGap提供手機功能,他們兩個組合在我看來創建了一個完美的移動網絡平臺。

I should also mention Sencha Touch as another mobile web UI gadget framework. 我還應該提到Sencha Touch作爲另一個移動Web UI小工具框架。 Sencha Touch version 1.0 was recently released under a dual licensing model that includes GPLv3. Sencha Touch 1.0版最近在包含GPLv3的雙重許可模式下發布。 Sencha Touch works well with PhoneGap just as JQuery Mobile does. 與JQuery Mobile一樣,Sencha Touch與PhoneGap配合得很好。

If you are a GWT programmer(like me), you may want to check out GWT Mobile , an open source project for creating mobile web apps with GWT. 如果您是GWT程序員(像我一樣),您可能需要查看GWT Mobile ,這是一個用GWT創建移動Web應用程序的開源項目。 It includes a PhoneGap GWT wrapper that enables the use of PhoneGap in GWT. 它包括一個PhoneGap GWT包裝器,可以在GWT中使用PhoneGap。

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章