Android 我如何告诉我的老板使用 Xamarin 不会让它更快
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/23613764/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How do I tell my boss working with Xamarin will not make it faster
提问by Christopher Francisco
I am the only mobile developer in my job. Before I was hired, my currently boss was thinking on using Xamarin as their marketing says the words Shared codeand native.
I consider myself an advanced Android developer since I've build large information systems. Right now I'm working on simple apps I could finish in a week, but Xamarin is giving me headache since its too buggy, and the reusable code is about 10% that could easily be copy/pasted into iOS
, and despite the fact that you can share that 10% code, sometimes you still have to use compilation directives #if / #endif
.
我是我工作中唯一的移动开发人员。在我被聘用之前,我现在的老板正在考虑使用 Xamarin,因为他们的营销中说的是Shared code和native。我认为自己是一名高级 Android 开发人员,因为我已经构建了大型信息系统。现在我正在开发我可以在一周内完成的简单应用程序,但 Xamarin 使我头疼,因为它太有问题了,可重用的代码大约有 10% 可以轻松复制/粘贴到 中iOS
,尽管事实上你可以共享那 10% 的代码,有时您仍然必须使用编译指令#if / #endif
。
I mean, there is no really any advantage for me, since I already know both Java
and Objective-C
languages. I already have vast knowledge of SQLite
and data storage with Core Data
on both iOS and Android SDK so that learning Xamarin will make it slower.
我的意思是,对我来说真的没有任何优势,因为我已经知道语言Java
和Objective-C
语言。我已经在 iOS 和 Android SDK 上拥有丰富的SQLite
数据存储知识,Core Data
因此学习 Xamarin 会使它变慢。
I have already tried to talk them into not going for Xamarin since its only a little code you can share, but they don't seem either to understand.
我已经尝试说服他们不要使用 Xamarin,因为它只有一些您可以共享的代码,但他们似乎也不理解。
I need some good argument to convince them not to buy it, so I can do my job in a more productive and faster way. Thank you in advance.
我需要一些好的论据来说服他们不要购买它,这样我才能以更高效、更快捷的方式完成我的工作。先感谢您。
回答by Pancho
Some good points from Lee Whitney's Blog: Why I Don't Recommend Xamarin for Mobile Development:
Lee Whitney 的博客中的一些优点:为什么我不推荐 Xamarin 进行移动开发:
App Overhead
Xamarin based apps have a built in overhead that makes them larger on average. This affects download time and storage used on a device. The minimum additional size is usually a few megabytes and can grow proportionately as the code uses more of the APIs. This is due to the way code from .NET assemblies is statically linked (as native code) into apps as the assemblies are referenced. On Android there is also an extra startup delay for apps for OS specific reasons. To Xamarin's credit this overhead used to be much greater and the company has made great strides in reducing it. However, the impact on app users is still measureable.
Limited Sharing of UI Code Across iOS and Android
User Interface development is not portable between iOS and Android.
This means APIs, event logic, widgets, and designers must be used and coded differently for each platform. There are a few exceptions to this for common, low level operations.Xamarin would argue that trying to abstract UI APIs across very different platforms can create unnecessary complexity or lead to a poor user experience with an LCD (lowest common denominator) design. They have a point here. Titanium tries to do this partially, and the result has made many developers unhappy with the inconsistent or unpredictable results. HTML5 apps are more successful at pulling off this UI abstraction without forcing an LCD design, but they do not have the native performance of Xamarin.
UI problems can be some of the most time consuming aspects of developing mobile apps. Despite having a good justification, the important takeaway is that for many mobile UI problems, Xamarin will not save developers or designers time.
Limited Sharing of Code Outside of Xamarin
Xamarin does not allow creation of reusable components or modules outside of it's own environment. For example, code written in Xamarin cannot be used in native or HTML5 apps. This means any code developed by a team using Xamarin cannot be shared or reused with teams using any other tooling for iOS and Android. How much this matters depends on the situation, but the problem with development is we can't predict all of our situations. So it's an uncomfortable limitation to have right out of the gate.
Ecosystem and Community
This is something that is not really Xamarin's fault. What company has a mobile ecosystem that matches Apple, Google, or HTML5? However, it matters. When developers are 10 times more likely to find results when searching the web about an issue, it directly impacts productivity. The ecosystem of available support, services, and 3rd party components, and related tooling is, and will continue to be, significantly smaller than for native or HTML5 based apps.
The Third Learning Curve
Some concepts and techniques require special knowledge specific to the Xamarin environment. This effectively adds a third learning curve for developers beyond programming language and native APIs. For example, developers having to understand iOS reference counting to avoid problems with Xamarin's garbage collection (Is this a bug in MonoTouch GC?). Another example is data structures and generics working in subtly different ways (http://docs.xamarin.com/guides/ios/advanced_topics/limitations). These are the types of issues that are hard to see before you actually adopt a new platform, so they merit special consideration.
More Moving Parts
Xamarin introduces it's own set of bugs that affect product quality and developer productivity. The problem is not that Xamarin has a bad product, but that adding any large or complex system to the app toolchain comes with problems and bugs that do not exist in native apps.
The historical record of these bugs can be reviewed using Xamarin's bug tracker (https://bugzilla.xamarin.com).
Yes, all software has bugs. The point is when you measure the advantage of adding new tools; the disadvantage of new problems must be factored in.
Summary
In the end we have to try and quantify the benefits of a development abstraction like Xamarin over other abstractions, or over native development. Is C# better than Objective-C? Yes, by far in my opinion, but that's only one factor. When you add everything up it tips the scales away from Xamarin in favor of other approaches to mobile development. As of 2013 (this stuff can change quickly) I tend to choose a native code solution or an HTML5/Cordova solution. I like both for different reasons and will try to explain some of the decision factors in another article.
应用程序开销
基于 Xamarin 的应用程序有一个内置的开销,使它们平均更大。这会影响设备上使用的下载时间和存储空间。最小的附加大小通常是几兆字节,并且可以随着代码使用更多 API 成比例地增长。这是由于 .NET 程序集的代码在引用程序集时静态链接(作为本机代码)到应用程序的方式。在 Android 上,由于操作系统特定原因,应用程序还会有额外的启动延迟。对于 Xamarin 而言,这种开销曾经要大得多,并且该公司在减少它方面取得了很大进展。但是,对应用程序用户的影响仍然是可衡量的。
跨 iOS 和 Android 的 UI 代码共享有限
用户界面开发在 iOS 和 Android 之间是不可移植的。
这意味着必须针对每个平台以不同方式使用和编码 API、事件逻辑、小部件和设计器。对于常见的低级操作,有一些例外。Xamarin 会争辩说,尝试在非常不同的平台上抽象 UI API 会产生不必要的复杂性或导致 LCD(最低公分母)设计的用户体验不佳。他们在这里有一个观点。Titanium 尝试部分地做到这一点,结果让许多开发人员对不一致或不可预测的结果感到不满。HTML5 应用程序在不强制 LCD 设计的情况下更成功地实现了这种 UI 抽象,但它们没有 Xamarin 的本机性能。
UI 问题可能是开发移动应用程序中最耗时的一些方面。尽管有很好的理由,但重要的一点是,对于许多移动 UI 问题,Xamarin 不会为开发人员或设计人员节省时间。
在 Xamarin 之外有限共享代码
Xamarin 不允许在它自己的环境之外创建可重用的组件或模块。例如,不能在本机或 HTML5 应用程序中使用用 Xamarin 编写的代码。这意味着团队使用 Xamarin 开发的任何代码都不能与使用任何其他 iOS 和 Android 工具的团队共享或重复使用。这有多重要取决于情况,但发展的问题是我们无法预测我们所有的情况。因此,直接走出大门是一个令人不舒服的限制。
生态系统和社区
这并不是 Xamarin 的错。哪家公司拥有与 Apple、Google 或 HTML5 相匹配的移动生态系统?但是,这很重要。当开发人员在网上搜索某个问题时找到结果的可能性增加 10 倍时,它会直接影响生产力。可用支持、服务和第 3 方组件以及相关工具的生态系统现在并将继续比原生或基于 HTML5 的应用程序小得多。
第三条学习曲线
某些概念和技术需要特定于 Xamarin 环境的特殊知识。这有效地为开发人员增加了除编程语言和本机 API 之外的第三条学习曲线。例如,开发人员必须了解 iOS 引用计数以避免 Xamarin 垃圾收集问题(这是 MonoTouch GC 中的错误吗?)。另一个例子是以微妙不同的方式工作的数据结构和泛型 ( http://docs.xamarin.com/guides/ios/advanced_topics/limitations)。这些是在您实际采用新平台之前很难看到的问题类型,因此值得特别考虑。
更多活动部件
Xamarin 引入了它自己的一组影响产品质量和开发人员生产力的错误。问题不在于 Xamarin 的产品不好,而是将任何大型或复杂系统添加到应用程序工具链都会带来本机应用程序中不存在的问题和错误。
可以使用 Xamarin 的错误跟踪器 ( https://bugzilla.xamarin.com)查看这些错误的历史记录。
是的,所有软件都有错误。关键是当您衡量添加新工具的优势时;必须考虑新问题的缺点。
概括
最后,我们必须尝试量化像 Xamarin 这样的开发抽象相对于其他抽象或原生开发的好处。C# 比 Objective-C 更好吗?是的,到目前为止,我认为,但这只是一个因素。当你把所有的东西加起来时,它就会使 Xamarin 的规模远离 Xamarin,转而支持其他移动开发方法。从 2013 年开始(这东西会很快改变),我倾向于选择原生代码解决方案或 HTML5/Cordova 解决方案。我喜欢两者的原因各不相同,并将尝试在另一篇文章中解释一些决定因素。