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。

  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值