Google, Android and Java
Java as an application language
Java is a great language. When it was introduced it brought to the masses new
concepts such as safety (all operations are defined - they'll throw
exceptions), garbage collection, a large API and multi-platform support. For
this it traded off both run time and memory performance. However for many areas
of software development, like the common database driven business application,
it was perfect.
Java as a platform language
For all these reasons Android Inc (and then Google) decided to use Java
as the main (and only) platform language for Android. What this means
is that if you want to access all the OS functions, your application needs
to either be written in Java, or go through Java via the Java Native
Interface (JNI). This has many problems:
- Performance: Java is slow, has always been slow and will always be slow.
There has been almost 20 years of research being throw at this problem
and it's still slow. Not only is is slow, it also uses lots of memory,
has goofy start up times (thanks to virtual machines) and causes
animation frames to drop due to garbage collection.
These problems are amplified on mobile phones with limitied batteries.
- It's not a good bridge language. It's difficult to put other languages
(C++, C#, Python, etc) on top of it. If your application isn't written in
Java, it'll still run a Java VM and you'll need to interface with it to do
basic OS functions. People do it, I've done it, and it ain't pretty.
- It can have legal issues. The Oracle v Google API copyright lawsuit shows
just how problemic using a single-vendor controlled language is as the
platform of an OS.
A growing platform
As Android grew is attracted lots of applications, developers and development
environments. For many, Java was not desired or acceptable. Some of
- Unity games written in Unity script or C#
- C# developers and Mono
- Games and other performance applications written in C or C++
- Applications ported from other platforms
Alternatives to Java
There has been speculation that perhaps Google might be considering
additional platform languages, given the legal and performance issues with
Java. Weather this is true or not, I don't know. Here are some of the
alternatives (and draw backs) thrown around on the Internet:
- C#. Controlled by Microsoft (a competitor, convicted monopolist and
litigator) and was never designed for multi-platform use (in fact,
it was designed for Windows lock-in). C# has absolutely no advantages over Java
in this context.
- Swift. Controlled by Apple, a large and direct competitor.
Benefits: It's native compiled and doesn't have a garbage collector.
- Rust. Near-zero market share and created by a semi-competitor, Mozilla.
- Go. It is was not designed for UI applications, has a tiny market share
and has a garbage collector. Benefits: controller by Google.
In my not-so-humble opinion though, I think Google would be nuts in choosing
any of the previous options. I really think the only practical option
here would be C++:
- C++ is an ISO standard with no single controlling party.
- It has multiple implementations (both open and closed source) from many
companies, leading to a rich, diverse and competitive landscape.
- It's popular, battle tested and very established.
- It is very fast, supports multiple software paradigms and doesn't have
a slow garbage collector.
- There are already multiple UI libraries in C++ for Android.
- It links seamlessly with the Linux kernel's C API and other C libraries.
- The NDK in Android already supports it.
- C++ is already heavily used at Google.
- Google already backs development of one of the leading.
C++ compilers (clang).
To me it seems like an obvious solution. They can either make their
own nice to use Android C++ UI library or just buys Digia's Qt library
and hit the ground running.
Some of the lowest APIs could be done in C, like the Linux kernel API.
Although I'm not a fan of C in general, it's still much easier to link
with than a Java VM.