关于网络语言的互操作性的跨平板项目问题 [英] Questions about web-languages interoperability in a cross-plateform project
问题描述
我计划建立在iOS,Android的应用程序,并与AngularJS一个网站。
I plan to create an application on iOS, Android and a website with AngularJS.
但不必重新编写每个应用程序的业务code,我想重复使用尽可能多的code越好。
But for not having to rewrite the business code on each app, I would like to reuse as much code as possible.
要能够执行该项目的核心在任何平台上,我必须使用网络语言。
To be able to execute the core of the project on any platform, I have to use a web language.
通过不同的文章中,我打算一个通用架构,分离项目的业务逻辑 - 核心 - (UIKit的为iOS,AngularJS和聚合物的Web应用程序等)与UI将重新实现各个系统。
Through different articles, I plan a common architecture to separate the business logic of the project - core - with the UI which will reimplemented for each system (UIKit for iOS, AngularJS and Polymer for the webapp, etc.)
该架构的目标是要尊重的重要的软件工程原则,如 信息隐藏通过分解要求在模块 , 干 和 固体
The goal of this architecture is to respect important software engineering principles such as information hiding by decomposing requirements in modules, DRY and SOLID
- 在每个功能将在模块分解。
- 核心:业务逻辑code - 可重复使用的每一个平台上 - psented以库的形式将重新$ P $
- 查看:视图类将在每个不同的平台上开发使用每个平台上提出了不同的UI元素。例如:在Objective-C /斯威夫特一个的ViewController的iOS或一个简单的类的子类来处理HTML Web的应用程序。 目前在这个类中没有逻辑这是只负责:
- 在处理用户交互的业务逻辑。
- 从业务逻辑显示内容
- Each feature will be decomposed in module.
- Core: Business logic code - reusable on every platform - will be represented in form of a library.
- View: The view class will be developed on each different platform to use the different UI elements proposed on each platform. E.g.: subclass of a ViewController in Objective-C / Swift for iOS or a simple class to manipulate HTML for the web-app. There is no logic in this class. It is only responsible to:
- Handle user interactions to the business logic.
- Display contents from the business logic
这里的iOS(几乎是一样的Android版):
芯将通过一个虚拟机作为这篇文章被执行的code向我们展示:的http://www.skyscanner.net/blogs/developing-mobile-cross-platform-library-part-3-javascript
The code of "core" will be executed through a virtual machine as this article shows us: http://www.skyscanner.net/blogs/developing-mobile-cross-platform-library-part-3-javascript
这里是AngularJS:
现在,你知道的一切建筑,这里是我的问题。
Now that you know everything about the architecture, here are my questions.
我没有足够的经验和反馈的网络语言研究,以便能够做出明智的选择。一些研究之后,我发现有多种选择:
I don't have enough experiences and feedback on the web-langages to be able to make a smart choice. After few researches, I found that there are various options:
-
飞镖
- 问题1:是否有机制允许的Objective-C /雨燕和Java之间的互操作性,通过虚拟机?我知道,这两个平台有虚拟机执行JavaScript code和谷歌提供dart2js编译达特为Javascript code。但它不是普通的JavaScript:看到一个例子这里。所以,我不知道还有一个正确的互操作性。
- Question 1: Are there mechanisms to allow interoperability between Objective-C/Swift and Java through VM? I know that both platforms have VM to execute Javascript code and Google provides dart2js to compile Dart to Javascript code. But it's not plain Javascript: See an example here. So I don't know if there is still a proper interoperability.
的Javascript ES6:事件,如果它不是完全在浏览器中实现的是,它有可能开始使用ES6用的 Traceur 编译器。
Javascript ES6: Event if it's not fully implemented in browsers yet, it's possible to start using ES6 with Traceur compiler.
- 问题2:有由Traceur和虚拟机中的iOS / Android的编译的JavaScript的互操作性
- 问题3:它是安全的使用ES6通过Traceur开发一个大型项目,并有生产code
- Question 2: Is there interoperability of Javascript compiled by Traceur and the VM in iOS/Android?
- Question 3: Is it "safe" to use ES6 through Traceur to develop a large-scale project and have production code?
感谢您的阅读。
推荐答案
我知道这是不是你列出的选项之一,但是不要自动排除C ++。这是Dropbox的使用,例如,他们甚至开源的工具,用于这一目的:
I know this wasn't one of the options you listed but don't automatically rule out C++. This is what Dropbox uses for example, they even open sourced their tools for this purpose:
C ++到Java / Objective-C的API生成器:
C++ to Java/Objective-C API generator:
https://github.com/dropbox/djinni
样本原生的应用程序为Android / iOS的:
Sample "native" app for Android/iOS:
有趣的文章,关于这个问题有更多的链接:
Interesting article on the subject with more links:
的http://oleb.net/blog/2014/05/how-dropbox-uses-cplusplus-cross-platform-development/
更新答:
如果你真的不想使用C ++和都还好与膨胀,你会得到去非本地,那么你可以尝试以下方法:
If you really don't want to use C++ and are okay with the bloat you'll get from going non-native then you can try the following:
https://github.com/MobileChromeApps/mobile-chrome-apps
该项目是科尔多瓦谷歌的叉子,并增加了许多新功能和优势。
That project is Google's fork of Cordova and adds a bunch of new features and benefits.
有一个飞镖包装上镀铬的API的位置:
There is a Dart wrapper over Chrome APIs here:
https://github.com/dart-gde/chrome.dart
基本上,你会使用纯HTML5技术,那么你会使用Chrome API的某些东西(设备状态等)写出飞镖您的应用程序。然后,您可以部署:
Basically, you would write your app in Dart using plain HTML5 technologies, then for certain things you'd use the Chrome APIs (device state, etc). Then you can deploy:
- 网页:编译成JavaScript无铬API特性
- 在Chrome操作系统:编译成JavaScript与Chrome浏览器的API功能 。
- 安卓:编译成JavaScript,然后用MobileChromeApps创建Android应用程序
- 的iOS:编译成JavaScript,然后用MobileChromeApps创建iOS应用程序
这篇关于关于网络语言的互操作性的跨平板项目问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!