So, I’ve been pretty vocal about my displeasure in reading up and toying with the Android SDK. I want to try to set the record straight.
So let me begin by saying a few things. Fundamentally, from an opinion perspective, I am of the camp that believes that VMs are a wonderful thing. Virtual Machines have allowed for safe compartmentalization of execution, distributed resiliency, more efficient use of resources, and so much more. They make automation turn from a gear work, to an aetherous form of magic that seems to have only existed in the writings of Tolkein. That being said, I’ve never liked Java, or their many purpose built VMs. In fact, through the years, I’ve immediately discounted any Java developer who refused to admit that Java ( there are exceptions ) was a horribly broken mess. Primarly because, as a systems engineer I saw the performance of many large applications on servers and mainframes. Nothing ever really compared in terms of wanton gluttony in resource allocation and general lack of stability as did Java VMs and app servers. Web logic is widely regarded as the single largest piece of crap to have ever made a system engineers life hell. No system engineer alive that I know, has ever had a kind word to say about this thing. Web sphere, same deal. JBoss, and Jrocket also have a similar user base of system engineers who would readily glass the development team for these products should they ever encounter them in a bar. We’ve all lost nights over this stuff. 4 am responses to events that should not have happened. Purchase orders for equipment that should not have been needed. And oh the support contracts, consultants, and goddamned developers.
Now, you might be thinking “Well fuck you. You’re a sysadmin. What do you know about development?”
I’m not the guy you go to for your Tomcat environment build outs, though I used to be fresh out of college. Today, I am the guy that does the engine work on automation systems that run private clouds. Big ones. I know a hell of a lot more about scalability than most. I work with APIs J2EE Apps, and APIs to Python, C, etc alike. Oracle, SQLite, and bizarre custom rolled datastructures are what I access directly when the APIs fail to meet needs. I switch up languages constantly to meet use case requirements. Any given week I am reading docs just to remember syntax differences between what I coded in last week. I jump versions of languages based on supported releases, and support contracts. My code executes across the planet and often times across thousands of systems in one go. I don’t even have a title anymore. I am part developer, part system engineer, and part policy maker. Security is a concern too, for probably obvious reasons.
So I have a deep love, as I said before of VMs. And from that love of VMs I see Dalvik as being a neat bit of software. Some day it may be of use in the grander world of virtualization. I don’t hate Dalvik for being Dalvik. In fact, I quite love that someone is finally integrating Java execution directly into a generic VM. Java should never have been deployed as a product without something like Dalvik to back it up. Purpose built VMs are bad design. If everyone builds a purpose built VM, suddenly you have a hell of a lot of VMs… running inside of VMs that are dedicated to running that VM. There’s layers of abstraction and optimization in play that result in some pretty nasty resource allocation and scheduling foul ups. And, it’s completely unnecessary. Java was designed by a guy with a vision of 2010 way back in 1995. It was a brilliant idea for its time. But, as it turns out some of it’s base assumptions were mistakes. Some of us saw this from day one.
Java is a wonderful idea, that is if you are a computer scientist ( horrible term btw ). It’s what a developer would think of as a near perfect language. And in a lot of ways it is pretty awesome. I am not a fan of some of the nomenclature chosen for class and object identification ( I much prefer python on this front ), but it really did redefine object oriented design forever. The problem primarily from my standpoint results directly from this being a developer designed language. Sun produced a target JVM to demonstrate the language on. It worked. It was cross platform. And it integrated with web browsers, at least until Microsoft deployed the “Microsoft JVM”. Heh, I’ll avoid bagging on that. We all know what a clusterfuck that was. Java solved a hell of a lot of problems for a hell of a lot of people. And certainly for a long time it was a great solution. Hell I used Java for a long time to handle web content uploads exceeding a few megs. It was really the only way until flash offered a solution. But, the issue that Java had was in serving data. See, there’s a fundamental difference between an app that spins up, executes, and dies in a shortish amount of time, and an application that’s expected to run for years on shared resources.
In a typical application dev process, a customer comes to a dev team ( project managers, designers, devs, DBAs, … ) and they work together to setup a list of requirements, and a set of high level operating flows, and eventually detailed designs. All too often, this design occurs without the proper level of input being made by the guys whose systems this stuff has to run on. This doesn’t happen at good shops. And if you see infrastructure team members in design discussions, your shop is doing some damned fine work get yourself a cookie. Now, while the dev team is focusing on a number of issues related to business value of user requirements, the infrastructure team is trying to achieve business value by protecting the other applications they serve, as well as the resources they actually have available. That means knowing demands of apps, meeting those demands, and never failing to provide the services that their developers and consequently users rely on. Java tries to protect developers from themselves by taking over the resource allocation front and automating tasks related to it. Problem is, generally that approach doesn’t scale very well if the optimization isn’t working 100%. Additionally, as I pointed out before, sometimes the JVMs optimization may end up at odds with other layers of optimization.
Now you must be thinking, what the fuck does any of this have to do with android? Dalvik is awesome right? It can run any language and optimize everything through it. And android is a little tiny Dalvik ran fiefdom. Dalvik is a generalized VM. Yep, a lot of the issues I’ve had with Java over the years go away here. Additionally, those problems occurred on big beefy servers. They share little in common with a hand held personal device. This is absolutely true. I was just trying to open your minds to the land outside the VM. That’s essential to understanding the fundamental issues I have with the Android SDK today. There are some similarities between those server apps and your typical android app. Google made a design call to allow multitasking, and there was much rejoicing. This gives developers a bunch of options, including one that gave Apple the heebeejeebees ( not in aspell? ). Apple was afraid developers would run background processes that could impact the usability of their device. Some of us freedom loving Americans aren’t afraid to have the right to choose what apps are best for us, but some of our nanny state friends aren’t so brave. End result? Android has had some apps that have severely impacted the usability of their device. And there’s where one of the key similarities lie between Android and servers. Apps that multitask are now residing on a shared platform. Background processes will run for days, possibly months, maybe even years depending on the user and their general level of OCD when it comes to keeping connected to their nearest cell tower. And that means resource management on the android just got really freaking hard.
Now, let’s say some stuff about the Android devices. For cell phones they are embedded devices. That is to say, it’s “different” from a laptop or a server. Differences are many. But ultimately it’s a reduction in resource availability across the board, and the introduction of some severe bottlenecks. It’s a small device too, so HID and UI differences are pretty drastic. The results are, we’re dealing with an emerging deployment platform. This is fun, exciting work, and lots of opportunity for successes and failures. I am not going to address TVs, and Tablets for now.
So cell phones. I have apps, you have apps, our friends have apps. What are people using, what are people buying? I’ve only bought 3 apps ever. I bought a PDAnet license for my Droid so I could tether. I bought an alternate lock screen for my iphone so I could get a bunch of awesome info without having to unlock my phone. And I bought a game for my droid, because it was a great way to keep me awake during conference calls. This seems to parallel the sort of use cases people want out of their apps. Entertainment, usability optimization, and special purpose.
Entertainment, usually means games. And I have played some fun freaking games on the droid, as well as the iphone. But, the stuff I see on the iphone today puts the Droid to shame. And I don’t think that is going to change soon. Apple, is generally not known for being a superior gaming platform, in spite of their generally resource rich devices. Why the hell is the iphone suddenly the mobile device gaming mecca? Simply put, Apple allowed native development. Quake 2 wasn’t written in ruby, the Unreal Engine wasn’t written in Java, and Python isn’t going to be running the next Call of Duty bastardization. Game developers, don’t need kid gloves when it comes to optimization. Like systems engineers, they get business value out of pushing the upper limits of what their platforms can do. They get paid to optimize by hand literally. They don’t want a hiccup in their game caused by a rogue optimization process or some 3rd party background task, they want their game to immerse the user define an experience and be utterly true to it. Solitaire will run fine on your droid, but don’t expect the next great 3d racer. Now, of course there are other reasons that iphone has excelled, they were around first and have a larger market audience, also the Android devices have generally had far inferior touch detection to that of the iphones which have been leading in the charts in accuracy. Also, the moving target that is the Android platform and device family causes some issues for game developers optimizing at all. There’s certainly a hell of a lot more in play here to cause trouble. But, in my opinion, one of the few places a rogue or novice game developer can hope to compete against an established game design studio is on embedded devices. The limitations of the device provide a somewhat more equal sized playing field, and one that is not insurmountable for a small team with limited resources. But, it’s the attention to detail, those 10% extras, that the hungrier developers can produce that will will be so groundbreaking. If you don’t provide them with the ability to operate with the mittens off, that opportunity disappears.
Now, you might be saying… well what about the NDK? It still executes through Dalvik, but it bypasses most of the optimization. Yeah sort of, all calls moving through it are still subject to the will of its scheduler, and then subject again to the will of resource management on the Android linux layer where it is properly identified as just another user process. Also, background tasks in Dalvik continue to be blissfully unaware of the applications real needs and will pummel it as they see fit. However, the NDK presents another far more serious problem.
Google’s Android team should never have released the NDK. And that’s primarily because the Android marketplace does not operate much like a market place at all so much as it does like a flea market. You walk into a mall and you can be pretty certain everything sold there is moderately safe and legal. You go shopping at a church flea market and there’s a good chance some hippies will be selling pot brownies, a senile old vet will be selling a browning machine gun, and some sketchy looking rednecks will be selling some plasmas that fell off of a truck. Android’s marketplace is like the flea market. Their approval process is virtually nonexistent, which results in the possibility for an ( reasonable level of ) anonymous developer to add dangerous applications. The lack of a central authority in signing of packages results in the possibility of people masquerading as each other. And the lack of robust ACLs results in people simply clicking accept on the “app wants access to..” page. End result is? the NDK provides a nice big happy open door to kernel and linux environment attacks. Which means rooting the crap out of users just became that much easier. At least if Dalvik was handling everything, some of this could have been mitigated. The security problem fundamentally with the NDK in terms of Dalvik, is that it literally does not execute at the end of the day in Dalvik. The optimization problem with the NDK is that Dalvik should have no interaction with native code execution. It’s inefficient, and pointless.
So am I for native code execution? or am I for Dalvik? Truthfully? I want to see open native code SDK. But, if Google decides they gotta have Dalvik, I’d rather from a security standpoint that they went with JUST Dalvik and nothing else. You can’t have both here. You are either optimizing and securing inside of Dalvik or you are doing it inside linux. One or the other, definitely not both. As to why I’d rather have an open native SDK, I don’t believe that embedded devices as they exist today, benefit from a VM such as Dalvik. I don’t believe that Dalvik has the resources it needs, and I believe that it hurts developers in the long run because of that. But more to the point, I’m not a nanny state fan. I was glad to hear that Android decided to allow multitasking, and I don’t want anyone making me put on mickey mouse gloves before I get my pointers on.
At the end of the day, a lot of this is personal opinion. But, I do know a bunch of developers that have been turned off completely by the Java centric SDK that Android relies on. Very few embedded device developers I know have any desire to learn Java. Most game developers working on these devices would rather code in C or some near equivalent. And when it comes right down to it, either you have a generic VM handling all the execution, or you have no VM. If you can’t figure that out, you are doomed to fall flat on your face. To date, Dalvik has only provided Java SDK interfaces. It can do more for Google, but it hasn’t. And no clean comparison can occur between the two until it can. However, we do know that as things are now, Android has some very serious problems that Google is seemingly having trouble coping with. That concerns me as a customer.