原生编程对移动开发有什么好处? [英] Any advantage of programming natively for mobile development?

查看:18
本文介绍了原生编程对移动开发有什么好处?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要在一些主要的移动操作系统上为公司开发应用程序,特别是 iOS、Android 和 WP7.

I need to develop applications for a company on some major mobile OSes, specifically, iOS, Android and WP7.

我最初计划为三个不同的操作系统编写三个独立的应用程序 - 每个应用程序都使用本机 SDK.

I was initially planning to code three separate applications for the three different OSes - each using the native SDK.

但是,这样做有什么好处吗?有许多跨平台工具可用 - Sencha、Phonegap、Rhodes 等.它们创建的应用程序跨设备的感觉如何?他们有什么样的硬件集成(相机、GPS、本地存储等)?

However, is there any advantage to doing so? There are a number of cross-platform tools available - Sencha, Phonegap, Rhodes etc. How 'native' do the apps created by them feel across devices? What kind of hardware integration do they have (camera, GPS, local storage etc.) ?

如果这样做有任何好处,我没有时间限制,也绝对不会遇到开发三个本机应用程序的问题.

I have no time restriction and have absolutely no issues developing three native applications if there is any advantage to doing so.

如果重要,应用程序将同时具有在线和离线功能.

In case it matters, the apps will have both, online and offline, functionalities.

推荐答案

免责声明:我一直在跟踪您提到的跨平台工具,但从未使用它们构建任何东西.如果您通读这篇文章,您可能会猜到我目前主要是一名 Android 开发人员.

答案是:视情况而定.原生应用程序当然有优势,但问题是你是否关心(或足够关心)这些优势会导致为多个平台开发的开销.由于您没有详细说明您计划构建的应用程序类型,因此我将简要介绍一下我所知道的情况.

The answer is: it depends. There certainly are advantages to native apps, but the question is whether you care (or care enough) about those advantages to incur the overhead of developing for multiple platforms. Since you haven't given much detail around what kind of apps you are planning to build, I'll give you a rundown of what I know.

我假设您在谈论基于 HTML 的跨平台解决方案(例如 PhoneGapSenchaRhodes) 而不是像 Corona SDKMoai 也并非总是很有趣Mono 通过 MonoTouchMono for Android.我还排除了不支持 Windows Phone 的 Titanium.

I'm going to assume that you are talking about HTML-based cross-platform solutions (like PhoneGap, Sencha, and Rhodes) and not cross-platform gaming-oriented platforms like Corona SDK or Moai and also not the always interesting Mono via MonoTouch and Mono for Android. I'm also excluding Titanium which doesn't support Windows Phone.

我看到的原生和 HTML 跨平台解决方案之间的一些差距如下:

Some of the gaps I see between native and those HTML cross-platform solutions are as follows:

  • 熟悉用户界面
  • 性能(尤其是用户界面)
  • 兼容性
  • 调试
  • 平台 API

每个平台的用户对事物的运作方式都有一定的期望.iOS 中的应用程序通常具有某些 UI 范式(顶部带有左侧后退按钮的栏,圆桌/列表 UI 等),Android 中的应用程序可能具有另一种范式(例如 ActionBar,类似但不完全相同)与 iOS 栏或上下文菜单的长按项目相同),Windows Phone 用户又是另一个(图块和全景视图).如果您生成相同的 HTML UI,您可能无法利用它.对于通常不会花时间学习多个平台的用户来说,这些熟悉的 UI 模式使应用更加直观和舒适.

Users of each platform build up certain expectations about how things work. Apps in iOS often have certain UI paradigms (that bar thing up top with the back button on the left, those rounded table/list UIs, etc.), apps in Android may have another (ActionBar for example which is similar, but not quite the same as the iOS bar, or long-pressing items for context menus), Windows Phone users yet another (tiles and panorama views). If you generate the same HTML UI, you probably won't be able to take advantage of that. Those familiar UI patterns make the app more intuitive and comfortable for the user who usually doesn't spend their time learning multiple platforms.

原生的另一个优势是性能,尤其是与 UI 相关的性能,即原始图形渲染能力或只是计算.如果您有简单的 UI,这可能无关紧要,但如果您有复杂的动画 UI,那么有些事情最终可能不会那么顺利.在 Android 中尤其如此,因为您拥有种类繁多的设备,其中包括一些功耗相当低的设备.

Another advantage of native is performance, especially UI-related performance be that raw graphical rendering power or just calculations. If you have simple UIs this might not matter, but if you have complex animated UIs then some things may end up not as smooth. This is particularly true in Android where you have a huge range of devices including some fairly low-powered ones.

使用 HTML 跨平台工具的另一个缺点是不同的手机处理 HTML/CSS/JavaScript 的方式不同.这很有趣,因为这是一把双刃剑.一方面,HTML 本质上是跨平台的,这很棒,另一方面,您仍然存在与设备相关的烦人的问题.在 Android 中尤其如此,在 Android 中您拥有如此多的不同设备,并且制造商出于某种原因喜欢修改 WebView 的实现.您最终会遇到一些小错误,某些设备会做一些奇怪的事情.如果你完全原生,你往往会有更好的兼容性(当然是以投入更多的工作为代价).也往往缺乏对旧版 Android 的支持.

Another downside to using an HTML cross-platform tool is that different phones deal with HTML/CSS/JavaScript differently. It's funny because this is a bit of a double-edged sword. On one hand it's great that HTML is inherently cross-platform, on the other, you still have nagging device-dependent issues. This is especially true once again in Android where you have so many varying devices and where manufacturers love to tinker with the implementation of WebViews for some reason. You end up with little bugs where certain devices do weird things. If you go full native, you tend to have better compatibility (at the price of putting in more work of course). Support for older versions of Android also tends to be lacking.

在移动平台上调试 JavaScript 并不是最美妙的体验.您最终会在控制台上进行大量日志记录.这是可行的,但肯定不如逐行进入您的代码那么好.在这方面似乎取得了一些进展(例如,参见 这个名为 weinre 的工具),但我无法发表评论关于它有多好,因为我还没有开始深入研究.

Debugging JavaScript is not the most wonderful experience on a mobile platform. You end up doing a lot of logging to the console. It's workable, but certainly not as nice as stepping into your code line-by-line. There seems to be some progress on this front (see this tool called weinre for example) but I can't comment on how good it is yet as I haven't gotten around to digging into it.

这种调试不仅更难,而且发现错误也更难.JavaScript 代码中的错误不会出现在日志中,除非您手动捕获并记录它们.你最终可能会默默地失败.

Not only is that kind of debugging harder, but noticing bugs is harder too. Errors in your JavaScript code won't end up in your logs unless you manually catch and log them. You can end up with things just silently failing.

总的来说,你提到的大玩家都有相当不错的硬件支持.您提到的相机、GPS 和本地存储等功能在对应用程序开发人员很重要的功能列表中非常重要,因此他们将它们包含在内.要获取完整的功能列表,您可能需要访问每个功能的网站(这里是 PhoneGap 按平台划分的高级功能支持图表)a> 例如),但通常你想到的大电话功能"都在那里.即便如此,还有很多更复杂的事情据我所知这些框架没有做或做的不好,尤其是与手机功能无关而与平台相关的事情.线程就是一个例子.

In general the big players that you've mentioned have pretty decent hardware support. Features that you mentioned like camera, GPS and local storage are pretty high on the list of features important to app developers so they include them. For a full list of features you'll probably want to go to the website of each one (here's PhoneGap's high-level feature support chart by platform for example), but generally the big "phone feature" things that you think of are there. Even so, there are a bunch of more complicated things that as far as I know these frameworks don't do or don't do as well, particularly things that are less to do with phone features and more platform-related. Threading is one example.

这篇关于原生编程对移动开发有什么好处?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆