by rogerbinns · 13y ago · 0 comments
It provides a processor independent application format. It is obvious now that ARM has won, but not so several years ago. There are many technical benefits to an abstract format including bytecode verification, and the consequent ability to run multiple applications in the same address space because you can't create pointers. JIT/hotspot style execution can also provide better performance than C.
In any event providing a CPU neutral application format isn't a bad decision - others have done it too.
> It does drain device resources, especially RAM.
That claim needs to be substantiated. Is native code significantly denser than bytecode? The mobile vendors have all gone with GC. Mark and sweep style GC has more RAM in play by design than something like reference counting, but there is no requirement that mark/sweep is used - Dalvik could use reference counting. Again there are tradeoffs but calling them a drain seems a large stretch.
It's a minor point, but Apple created ARC specifically as a streamlined reference counting alternative to GC, which was never used in iOS and is now deprecated in Mountain Lion.
You do not need to do so in Android (Java), iOS (ObjC), Windows Phone (C#) etc.
It's a minor point and I agree with what you said, but I wanted it addressed in case someone who've not familiar with ARC gets the wrong impression :)
It's paradoxical however that to increase the portability of certain types of apps across mobile ecosystems, eg. iOS and Android, and now Ubuntu, your best bet can be to write the portable part in native C or C++, bypassing the Dalvik layer using JNI/NDK. This is apparently the common way to make cross-platform mobile games.
On memory consumption: I haven't made any measurements, but the Android .dex bytecode format has been designed with low space requirements in mind. See http://www.youtube.com/watch?v=ptjedOZEXPM . However, all apps run in their own VM process, with lots of common structures shared with them using an initial shared VM process and clever forking.
I always thought one of the main original motivations to use Java was because it's so well spread among developers. Since in the early days before the JIT compiler, there must have been a really obvious overhead even with the interpreter hand-coded in assembly. But they must have wanted to use a well known higher level language with good IDE support etc.
Ubuntu mobile apparently uses Qt: "It uses QML to give you a really slick, easy development experience for native apps with engines in C or C++, and JavaScript for UI glue that isn’t performance critical. We also give you full native OpenGL, which the top games companies are using to make incredible games." It seems actually pretty nice for developers: http://developer.ubuntu.com/get-started/gomobile/