代号一号如何运作? [英] How does Codename One work?

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

问题描述

我正在寻找为多个移动平台开发的替代方案,并找到了使用 Java 的 Codename One作为 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?

先发制人:这是一个关于 Codename 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.

推荐答案

Codename One 有一个可选的 SaaS方法,因此这可能(并且可能会)在未来改变以适应改进的架构.请注意,Codename One 还提供了一个选项来离线构建,这意味着公司具有禁止此类云架构的政策仍然可以使用具有一些额外开销/复杂性的 Codename One.这也意味着您可以免费使用它,而无需使用构建服务器.

Codename One has an optional SaaS 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. It also means you can use it for free without ever working with the build servers.

目前在 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 Codename One 上构建 &开源 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.

过去 Codename One 使用 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 的后端非常不同.Codename One 选择停止使用旧后端 因为它没有新的 UWP 后端那么强大,也不符合微软向前推进并专注于 UWP(通用 Windows 平台).

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 桌面和移动支持 Codename One 使用 iKVM 来目标 UWP(通用 WindowsPlatform) 并在 Codename One 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 Codename One 使用了 HTML5 Canvas 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.

对于桌面构建 Codename 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 One 的突出之处在于它采用轻量级架构"的 UI 方法.允许 UI 在所有平台上无缝工作,并且几乎完全用 Java 开发.它通过嵌入重量级"文件的能力得到增强.小部件在轻量级"中占据一席之地.您可以在此 博文.请注意,此时 peering 正在进行一些改进,现在支持更精细的用法,例如分层.

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 编写,这使开发人员可以在模拟器中准确地预览应用程序 &图形用户界面构建器.

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

Codename 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.

仅供参考,此答案的作者 Shai Almog 是 Codename One 的首席执行官.

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

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