Fork us on GitHub

Comparing QT and Codename One

A biased view of other mobile solutions
Post Image

Comparing QT and Codename One

We get a lot of requests to compare Codename One to other technologies and while we do have a comparison page it is somewhat static. Doing a comparison within a blog post does have the advantage of focusing on one technology and allowing comments. In this segment we’ll compare the venerable QT to Codename One.

When developers started asking for this comparison I was of the opinion that it made no sense. The technologies are so far apart from one another that they defy any sensible comparison. I still think the conceptual difference is a bit too great but I’ll try to bridge some of the gap.

We updated this comparison after the initial publication to include the additional Property Cross section

Background

QT went thru a lot over it’s many years. It’s the basis of the excellent KDE Linux desktop environment which in my humble opinion was always superior to gnome. It’s a C++ library & toolchain developed by a company called Trolltech that was purchased by Nokia.

Nokia purchased Trolltech with the goal of taking QT into mobile, this went thru many iterations over the years but the product that’s available today is radically different to everything available since.

At a Glance

Table 1. QT vs. Codename One
Category QT Codename One

Language

C++/QML-JavaScript

Java

Cloud Build

No (requires Mac & Windows for full OS support)

Yes (can work on Linux for iOS development)

IDE

QT Creator or Visual Studio

NetBeans, Eclipse or IntelliJ IDEA

Web Deployment

No

Yes

Widgets

Lightweight

Lightweight

Pricing (Monthly no discounts)

350 USD

19 USD - 399 USD

In Detail

Language

While QT supports QML (an XML flavor) with JavaScript bindings QT at it’s base is C based. If you need to integrate a native widget like Googles native maps or similar capabilities you need to do this via C.

This might be challenging as most of the integration documentation for various libraries is in Java, Objective-C. Binding an iOS/Android SDK to QT might not be trivial. C++ isn’t garbage collected or "safe" and is a challenging language for novices.

Codename One uses Java for everything with all of the typical Java advantages (GC, safe memory etc.). When integrating with native code Codename One generates "stubs" for the various platforms allowing developers to write native Objective-C, Java (Android flavor), C# etc. code.

This makes integrating with native OS capabilities far simpler as developers can literally copy and paste sample code from the SDK vendor.

Cloud Build

Codename One’s cloud build capability is unique. It allows developers to build a native application using the Codename One cloud servers (Macs for iOS, Windows machines for Windows etc.) This removes the need to own dedicated hardware and allows you to build native iOS apps from Windows and native Windows apps from your Mac or Linux machine.

This makes the installation of Codename One trivial, a single plugin to install. This isn’t true for development environments that don’t use that approach.

IDE

QT has its own custom IDE with GUI builder. It also has a plugin to support Visual Studio which is quite popular in the C++ developer community.

Codename One integrates with all major Java IDE’s thru a standard plugin. The plugin delivers the simulators and visual tools for Codename One as well as the device building capabilities.

Web Deployment

QT is very portable and so is Codename One. Both support many platforms but there is one that Codename One can support that QT might find unreachable: JavaScript.

Codename One supports the process of compiling an application (threads and all) into a JavaScript application that can be hosted on the web. This is done by statically translating the Java bytecode to JavaScript obfuscated code.

Widgets

The one point of similarity between QT and Codename One is that both frameworks take the lighweight widget approach for greater flexibility and portability.

Property Cross Comparison

The PropertyCross demo was built as a tool that allows us to compare two cross platform frameworks, as such there are versions of the demo for many such platforms. You can check out details of the Codename One implementation here. The github repository for this demo is here.

The QT version of property cross includes 3 projects: - The main application QML UI - this includes code that is mostly declarative but quite a lot of it. It defines the UI of the application and not much more - The lib directory includes the CPP files and header files for the project - A special test project that we’ll ignore for now as this isn’t covered in other discussions

It’s pretty great that QT doesn’t require separate projects for every OS. It does have some theme directories but most of the code including the UI is common. This is because QT and Codename One share a lightweight architecture that increases portability.

The code isn’t as verbose as some other implementations it is roughly 2x-3x larger than the Codename One project in lines of code. The project seems to be missing the application launcher screenshots and the icon files for the various supported DPI’s. While most of the resources would probably be adaptable in a portable way icons and splash screens probably won’t be.

This is something that Codename One can handle seamlessly thanks to the build servers but QT might have an issue with.

Final Word

Our opinions are obviously biased but I think we did a reasonably fair comparison. I actually like and respect QT which makes it a great candidate for comparison.

If you think we misrepresented Codename One or QT in any way let us know in the comments.

Please use the comments section for suggestions of future comparison segments.

Share this Post:

Posted by Shai Almog

Shai is the co-founder of Codename One. He's been a professional programmer for over 25 years. During that time he has worked with dozens of companies including Sun Microsystems.
For more follow Shai on Twitter & github.