Ex Sun Developers Bring WORA Java Support to Android, iOS, and Other Mobile Platforms
Founded in 2012 Israeli start-up Codename One is producing a new Java SDK that allows Java developers to write native applications that support a number of mobile device platforms including iOS, Android, BlackBerry, and Windows Phone from a single code-base. For iOS, Codename One translates Java to C/Objective-C on its cloud servers and compiles the resulting source code to native applications. This results in iTunes compliant applications written in Java.
The two founders of Codename One are Chen Fishbein and Shai Almog. Fishbein was the lead architect and founder of the Lightweight User Interface Toolkit (LWUIT), the standard UI toolkit for Java ME, and also developed the Sprint Wireless Toolkit, which is one of the most successful J2ME development tools.
The platform is currently in beta but InfoQ downloaded it and took it for a test drive. It seems pretty far along. To build your code, you point their cloud-based website to your codebase. The code is uploaded and compiled, producing a QR code that you can use to download and install the finished product on your device. Intrigued we interviewed Shai Almog, cofounder and CEO, about their recently announced Windows Phone support and to find out more about the company.
InfoQ: Hello Shai. This idea is long overdue. Is it a true Java environment for all of these platforms?
Almog: Java isn't so much about the virtual machine, as it is about the unified stack, the tools, in fact the whole Java ecosphere. Java means you just press play and it works. Even Android requires an unfamiliar process a distinct set of tools, and an emulator for each configuration, so you lose the "Write Once Run Anywhere" (WORA.)
InfoQ: Are any changes required for each environment?
Almog: Not really. Codename One provides a singular API that works across every platform, integrated directly into the Java environment, solving all different fragmentation issues to create a singular environment.
InfoQ: Do you actually distribute a JVM on each platform?
Almog: No, it depends on the platform. On Android, we largely use the existing Dalvik virtual machine. But on iOS there is no Java so we translate the classes to C with an Objective C layer, and we use a Boehm Garbage Collector. It runs the Java code, but not in a true Java virtual machine. On RIM and other platforms, we compile things down to the limited subset of Java features available to it. So you can still get the same WORA experience associated with Java.
InfoQ: Do you try to support all features across all devices in every release?
Almog: We try but it is not always possible due to the underlying device variations. SQL is a great example; developers want it but some low-end devices just don't support it. Developers can query to see what is supported in any particular environment. Our strategy has been to provide a highest common denominator and rise up where possible.
InfoQ: Do I need to actually have the devices I am developing for?
Almog: Theoretically, but you can't feel the application from the mouse; you need to hold the phone and feel it to get an accurate sense of performance and behavior. Here we keep several iPad versions because there are slight variations.
InfoQ: Android must be very difficult because of the variety of versions?
Almog: Actually iPhone is much harder. Apple changes things so where 4.2 did it one way 4.3 was completely different. You suddenly find nothing builds. Android has more versions, but they are less destructive so in fact there are fewer variations.
InfoQ: Is there any installation required from the app user?
Almog: No it is all self-contained. That lets us maintain stability because we are not supporting some moving target VM. Devices can change so much from version to version, but we take care of maintaining the version compatibility, so the application developer does not have to.
InfoQ: How is the learning curve if you know Java?
Almog: It's pretty simple really. It feels like Swing so most Swing developers will find it much more familiar than XML-based Android. You can use the built in debuggers, there's no APK, no waiting for the emulator to start; our simulator launches immediately on each run.
InfoQ: Some folks say Swing is a bit draggy, doesn't have the feel of say a native Windows app. What does your platform do to make it more snappy?
Almog: The Swing UI was hard to customize and its native look and feel couldn't keep track of the OS since it was tied to JDK releases. Codename One allows theming and styles deep in the component model and since we are SaaS/OpenSource, we constantly update the feel of applications without the slow Sun/Oracle process. That ensures a snappy application experience.
InfoQ: What about 3D graphics?
Almog: No, at this point we are trying to avoid gaming use cases. That may change in the future.
InfoQ: What about device specific features like I/O, GPS, camera, audio, etc.?
Almog: We support all of those basic API's. Gestures are under development and some are currently supported. But if you need something we don't support, we provide native integration. You can define an interface and our plugin will generate native code for your device, and then you can call the native functionality.
InfoQ: How do you price this?
Almog: Basic is free, and we will keep it that way. It is important to give back to the community. Every month you can deploy 100 builds across all platforms except iOS. When you build locally you can do anything, but our build server limits you to 100. iOS is limited to five per month because it is so much more expensive for us to build. You can also buy unlimited builds for $9 per month. There are also more elaborate pricing schemes and you can pay extra for features such as crash protection.
InfoQ: How are the documentation and support?
Almog: The developer guide is a Google doc of around 100 pages, which we invite the community to help write. We maintain a detailed JavaDoc and spend a lot of time supporting the Google group mailing list.
InfoQ: It sounds like you are doing some great things. What's on the horizon?
Almog: There's a lot coming. Starting in late September support for Windows devices will be available. Then we will add in-app payments, more advanced APIs for the client and simulator, and more templates for developers to draw from. And we have just announced a partnership with Vserv, which allows developers to add advertising without changing a line of code.
With a growing number of enterprises supporting multiple mobile platforms Codename One has the potential to improve the rate and cost at which companies can develop new applications. The SDK can be downloaded free from the company website.
Craig Motlin Sep 01, 2014