Codename One如何工作? [英] How does Codename One work?

查看:99
本文介绍了Codename One如何工作?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在寻找可用于多个移动平台的替代方案,并且发现了代号One ,该代号使用Java为 lingua franca ,而不是HTML/CSS/JS或脚本语言.

I'm prospecting alternatives to develop for multiple mobile platforms, and have found Codename One, that uses Java as lingua franca, instead of HTML/CSS/JS or scripting languages.

我找不到的是它是如何工作的.它是否将JVM与iOS和Win7的应用程序捆绑在一起,并在Android中使用Dalvik?它将源代码转换为本地代码吗,我们可以访问此源代码吗?考虑到他们承诺不妥协",还有其他魔术吗?在编写不可知论的Java时应该注意哪些限制?

What I couldn't find is how does it work. Does it bundle a JVM with the application for iOS and Win7, and uses Dalvik in Android? Does it translates source code to native, and do we have access to this source code? Is there other magic, considering they promise "no compromise"? What limitations should I be aware while coding agnostic Java?

先发制人的罢工:这是一个关于代号One的问题,而不是关于我应该选择哪个跨平台或者我应该本地化还是应该上网的一个问题.

Preemptive strike: this is a question about Codename One, not about which cross-platform should I choose or if I should go native or if I should go web.

推荐答案

代号One 使用基于SaaS的方法因此在将来可能会改变(可能还会改变)以适应改进的体系结构.请注意,Codename One还提供了离线构建的选项,这意味着拥有政策的公司禁止此类云架构仍可以使用Codename One,但会带来一些额外的开销/复杂性.

Codename One uses a SaaS based approach so this might (and probably will) change in the future to accommodate improved architectures. Notice that Codename One also provides an option to build offline which means corporations that have policies forbidding such cloud architectures can still use Codename One with some additional overhead/complexity.

当前在Android上,标准Java代码按原样执行.使用Java 8语法时,将在所有平台上使用retrolambda对其进行翻译.这样一来,它就可以与所有Android版本以及其他端口兼容.

Currently on Android the standard Java code is executed as is. Java 8 syntax is translated using retrolambda for all platforms when its used. This allows it to be compatible to all Android versions as well as other ports.

在iOS代号上,一个内置的&开源 ParparVM ,这是一个非常保守的VM. ParparVM 具有并发(非阻塞)GC的功能,并且完全用Java编写/C.这实际上意味着将在构建服务器上生成并编译一个xcode项目,从而使其像您对本地应用程序进行手工编码一样有效,从而为Apple所做的更改提供了未来证明".例如.在iOS版本中对64位和位代码进行了最新更改之后,ParparVM无需进行任何修改即可符合这些更改.

On iOS Codename One built & open sourced ParparVM which is a very conservative VM. ParparVM features a concurrent (non-blocking) GC and it is written entirely in Java/C. This effectively means that an xcode project is generated and compiled on the build servers so its effectively as if you handcoded a native app and thus "future proof" for changes made by Apple. E.g. with recent 64bit and bitcode changes to iOS builds ParparVM needed no modifications to comply with those changes.

过去,代号使用 XMLVM 来以非常相似的方式生成本机代码,但是XMLVM解决方案过于通用满足代号一"的需求.

In the past Codename One used XMLVM to generate native code in a very similar way but the XMLVM solution was too generic for the needs of Codename One.

iOS构建使用xcode(Apple的官方构建工具)在云中的Mac上进行编译和签名.这使它们与Apple的当前/未来更改兼容,并允许开发人员在定位iOS时使用Windows/Linux.您可以在此处了解更多有关ParparVM与iOS的兼容性的信息.

iOS builds are compiled and signed on Macs in the cloud using xcode (the official Apple build tool). This makes them compatible with current/future changes from Apple and allows developers to use Windows/Linux while targeting iOS. You can read more about the compatibility of ParparVM to iOS here.

过去,Codename One使用依赖XMLVM的C#转换器支持Windows Phone,但这不是理想的方法.请注意,转换为C#的XMLVM后端与以前用于转换为iOS的XMLVM后端非常不同.代号选择选择停用该旧后端,因为它不像新的UWP后端那样强大,并且不符合Microsoft向前发展并专注于

In the past Codename One supported Windows Phone using a C# translator that relied on XMLVM but it was not an ideal approach. Notice that the XMLVM backend that translates to C# is very different from the one that was formerly used to translates to iOS. Codename One chose to discontinue that old backend as it wasn't as powerful as the new UWP backend and doesn't match Microsofts goals moving forward and focusing on UWP (Universal Windows Platform).

对于Windows 10桌面和移动设备支持,代号One使用iKVM来目标UWP(通用Windows平台) ),并在代号一个github存储库中开放了对原始iKVM代码的更改. .

For Windows 10 desktop and Mobile support Codename One uses iKVM to target UWP (Universal Windows Platform) and has open sourced the changes to the original iKVM code in the Codename One github repository.

请注意,UWP构建是在云中的Windows 10计算机上完成的,因此允许开发人员在构建本机Windows应用程序时使用Mac/Linux或更旧版本的Windows ...

Notice that UWP builds are done on a Windows 10 machines in the cloud thus allowing developers to use Mac/Linux or older versions of Windows when building native windows apps...

JavaScript构建目标使用 TeaVM 静态地进行转换. TeaVM通过相当精细的方式将应用程序分解来提供对使用JavaScript进行线程化的支持.为了支持复杂的UI代号,One使用HTML5 Canvas API,该API为构建应用程序提供了绝对的灵活性.

JavaScript build targets which are available on the enterprise level subscribers use TeaVM to do the translation statically. TeaVM provides support for threading using JavaScript by breaking the app down in a rather elaborate way. To support the complex UI Codename One uses the HTML5 Canvas API which allows absolute flexibility for building applications.

对于台式机版本,代号One使用javafxpackager,因为Mac和Windows机器都可以在云中使用,因此javafxpackager的平台特定性质不是问题.

For desktop builds Codename One uses javafxpackager, since both Macs and Windows machines are available in the cloud the platform specific nature of javafxpackager is not a problem.

使Codename脱颖而出的是它对UI采取的方法,该方法使用轻量级体系结构"来允许UI在所有平台上无缝工作,并且几乎完全用Java开发.将重量级"小部件嵌入轻量级"中的位置的能力得到了增强.您可以在博客帖子.请注意,此时对等正在进行一些改进,现在支持更精细的用法,例如分层.

What makes Codename One stand out is the approach it takes to UI where it uses a "lightweight architecture" to allow the UI to work seamlessly across all platforms and be developed almost entirely in Java. It is augmented by the ability to embed "heavyweight" widgets into place among the "lightweights". You can learn more about this in this blog post. Notice that at this time peering is undergoing some improvements and now supports more elaborate usages such as layering.

轻量级组件完全用Java编写,这使开发人员可以在模拟器中准确预览应用程序. GUI构建器.

A lightweight component is written entirely in Java, this allows developers to preview the application accurately in the simulators & GUI builder.

代号One通过使用大多数平台的本机游戏API进行绘制来实现快速性能. iOS上的OpenGL ES.

Codename One achieves fast performance by drawing using the native gaming API's of most platforms e.g. OpenGL ES on iOS.

Codename One背后的核心技术都是开源的,包括Codename One本身开发的大多数内容,例如 ParparVM 以及设备皮肤等.您可以了解有关使用Codename One来源的更多信息此处.

The core technologies behind Codename One are all open source including most of the stuff developed by Codename One itself e.g. ParparVM but also the full library, platform ports, designer tool, device skins etc. You can learn more about using the Codename One sources here.

此答案的作者FYI Shai Almog是代号One的首席执行官.

这篇关于Codename One如何工作?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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