On this blue moon night, I’ll talk about the Android OS, it’s ecosystem and anything that crosses my mind. Now, before I start, I would like to mention that I love android and have only ever owned Android phones. I also develop for Android and have been for the past couple of years. Anything and everything I’m about to write is my opinion based on my own experience as a user and a developer and you don’t need to agree or disagree with it.
Android is a marvel of engineering of the modern world. Almost everywhere you look, you can find an android powered device be it a smartphone or tablet or watch or TV. The android platform and technology is integrated into our lives. The immense success of android is attributed to it’s open source nature. The entire android OS is open source and runs on Linux, which is also open source. Any random guy can develop a phone and adapt android to run on it. It’s been a few years since it’s conception and has since captured the market and hearts of it’s users. Android has replaced most, if not all, of the legacy OS that were available in the past. Most notably, Symbian by Nokia and the BlackBerry OS. Android has gained it’s popularity by allowing a wide variety of phone manufacturers to modify the OS to their requirements.
In the present market, we can find android phones from dozens of manufactures, featuring a variety of features and specifications. Phones range from budget phones to high end devices with tons of memory and computing power. And, I expect android to only increase in popularity in the foreseeable future.
In the past, when android first started appearing in the market, devices were pretty simple. My very first phone had 512 MB of RAM and a single core processor from Qualcomm. Now, I own a phone with 2 GB of RAM and a quad core processor. Over the years, manufacturers have added tons of RAM and computing capacity to their devices to appeal to their customers. But, in my opinion, a phone does not need 8 GB of RAM and an octa core processor. My laptop has 16 GB of RAM and a quad core processor. The tools I need to get my job done requires tons of RAM and computing power to run. A phone simply does not need to, or rather, can not run anything that would be able to utilize the resources that manufacturers are putting in their phones these days.
Most phones only need to run a few applications and even those don’t need tons of resources to get the job done. Say for instance, on my laptop, I run high resource utilization tools like Eclipse, VirtualBox and other stuff. Other people at my office run photo and video editing suites on their laptop with barely 4 GB of RAM and a dual or quad core processor. And, here’s the thing, a phone cannot possibly run a virtualization stack or a photo editing suite like Photoshop; so, packing 8 GB of RAM and an octa core processor into a phone makes no sense whatsoever. A phone can barely use 2 GB of RAM during normal operations. Putting more resources than can be used is simply a waste of resources that could have been used elsewhere.
The android OS is open source and runs on the Linux kernel. The linux kernel made it possible to run android on a wide range of hardware. Most android phones run on some variant of the ARM processor. A small portion of android phones run on the x86 processor. Some phones even contain MIPS processor. Android is able to run on all these varying platform because linux is available for all of these platforms. Since android is designed to run on varying hardware, the creators of android needed a way to make sure that applications can run regardless of the processor. Thus, android programming is done using JAVA. A compiled android application contains JAVA Byte Code that is interpreted by the Dalvik VM or the ART when run.
Using Java to program android enabled developers to forget about the processor their application is going to run on and concentrate on actually developing the application. It’s also a necessity since android is designed to be run on as many devices as possible and all. Making android use java and be cross platform means that the job of worrying about processors and stuff have been moved from the application developer to the hardware manufacturer.
But, there’s a problem with this design choice of the android OS. Using Java means that there is a layer between the application and the hardware. This layer is a source of performance degradation. If I write a piece of code in a native language such as C or C++ or anything, it runs directly on the processor. However, java requires a JVM to run. Thus, the processor runs the JVM which in turn runs the Java code. And no matter how much the JVM tries, it can never match the processor in terms of performance. This is the entire reason that android seems slower and uses more resources to get the same thing done than, say, iOS.
iOS uses the Swift programming language at present. The code is compiled into machine code that executes directly on the processor. This is the entire reason that an iPhone can do the same thing an android can with less resources. JVM brings with it not only a layer of indirection over the processor, it must also perform critical bookkeeping operations that takes up memory and computing resources. If android applications were built and compiled to native code, it would have taken away this layer that serves as a performance reducer. But, this would also bring with it one of the two:
- Lock the android system into using a single type of processor. Thereby reducing it’s uptake by manufacturers.
- Force the application developer to release multiple copies of the same application for different hardware platforms.
The 2nd option is favored by developers at present. Some applications include a bit of native code to get the job done. Applications like Whatsapp contain a bit of code written in C to get that extra performance when doing computing intensive operations. One way to include native code into applications is by including copies of the code compiled for every possible processor into the application. But, in this case, the application would become extremely large.
Say I have a code that’s 1 MB in size. I compile it for 8 different processors, this makes my application 8 MB larger than if I only compile for a single processor. But if I compile for only one processor, I cannot run it on any other processor. One way to overcome this problem is by using app marketplace that can detect and provide the correct version of the application. I can produce 8 different versions of my application, each containing code compiled for one of the 8 different processors and upload it to a platform that can detect the processor and provide the correct version.
The Google Play Store is capable of detecting and providing the proper version to the user. The user would never notice the difference in the application from one platform to the next. As a developer, I would be more than happy to compile and upload different versions for different platforms if the app store is capable of providing the correct version to it’s users.
Deciding to use Java in the name of cross platform compatibility was a bad design choice in my opinion. A choice that’s extremely difficult to change at this stage. So, we will continue to have phones that cannot compete with iOS in terms of performance and resources used.
Although android has it’s fair share of bad design choices, it’s the best thing we have at the moment. Until another OS is developed that can overcome the shortcomings of android, it’s very likely that we’ll continue to have android around. And, as it is, getting a new OS to become popular enough to compete with android is going to be extremely difficult given how big the android ecosystem has become. Another option is to gradually deploy a subsystem that would enable developing native application while keeping the java based subsystem in place for legacy applications. Either way, as users, and developers, we just have to wait and watch the path android takes.