More concretely, I’m asking this: why aren’t applications compiled fully to native code before distribution rather than bytecode that runs on some virtual machine or runtime environment?

Implementation details aside, fundamentally, an Android application consists of bytecode, static resources, etc. In the Java world, I understand that the main appeal of having the JVM is to allow for enhanced portability and maybe also improved security. I know Android uses ART, but it remains that the applications are composed of processor-independent bytecode that leads to all this complex design to convert it into runnable code in some efficient manner. See: ART optimizing profiles, JIT compilation, JIT/AOT Hybrid Compilation… that’s a lot of work to support this complex design.

Android only officially supports arm64 currently, so why the extra complexity? Is this a vestigial remnant of the past? If so, with the move up in minimum supported versions, I should think Android should be transitioning to a binary distribution model at a natural point where compatibility is breaking. What benefit is being realized from all this runtime complexity?

  • Dr. Jenkem@lemmy.blugatch.tube
    link
    fedilink
    English
    arrow-up
    9
    arrow-down
    1
    ·
    1 year ago

    X86 android devices exist, wether they are officially supported or not, I don’t know. C/C++ is prone to memory corruption vulnerabilities, using a higher level language like Java nearly entirely cuts out that class of vulnerabilities. You mention the complexity of Java, but Java is just a lot easier to write than c/c++. So I ask you, why would android switch to the complexity of c/c++ for applications where Java is sufficient?

    • henfredemars@lemmy.worldOP
      link
      fedilink
      English
      arrow-up
      2
      arrow-down
      1
      ·
      1 year ago

      Thank you for the insight, however, I think that my question is somewhat different because I’m interested in the implementation choice rather than the language choice. To answer your question, I don’t think Android should switch to C/C++. Instead, I don’t understand why Android goes to such great lengths to avoid compiling whatever language is in use in advance. Naively from the outside looking in it appears this would greatly simplify the platform.

      For example, I think it would be an improvement to use Java but compile the whole thing to a native image in the cloud and distribute the compiled binaries. We already have Java AOT capabilities in Android, therefore this appears to be technically feasible. Only one ISA is targeted officially. It’s not a great academic leap to think apps could be built off the phone instead to avoid the complex optimization problems.

      I am ignoring Chromebooks a bit. I did not know that you could run Android apps on that platform and didn’t think to consider it because I didn’t see x86 listed on Wikipedia as an officially supported architecture.

      • minorninth@lemmy.world
        link
        fedilink
        English
        arrow-up
        3
        ·
        1 year ago

        Who would it simplify things for?

        Not for the developer. For developers, compiling in advance would just slow them down and remove a lot of the cool things you can do with Java today like hot-swapping and reflection.

        Not for the user. The current system is totally transparent to the user.

        You’re proposing making things simpler for the Android OS, but worse for the developer. That’s the exact opposite of what they want. A lot of Android is quite complex in ways that make things easier for developers, on purpose.