2

In simple what is ART (Android run-time) and DART in Android, I read about it here but I don't really understand its importance and usage.

Also I searched here in Stackoverflow for any related question before I ask about that.

Misha Akopov
  • 12,241
  • 27
  • 68
  • 82
Marzouk
  • 2,650
  • 3
  • 25
  • 56
  • They're similar to JVM as far as I know. They read the and turn the code in to an executable format. I think Dalvik is pre lollipop (5). – Script47 Aug 08 '15 at 03:58
  • @Script47 I think ART is a new runtime for android in addation to Dalvik, ART is faster and using AOT instead of JIT in Android Dalvik VM but i need to know more about it, i found an important link here: https://infinum.co/the-capsized-eight/articles/art-vs-dalvik-introducing-the-new-android-runtime-in-kit-kat – Marzouk Aug 08 '15 at 04:04
  • 1
    When you said "Dart", are you talking about the new programming language? If it is about that here I show you an interesting link about this language with android apps http://arstechnica.com/gadgets/2015/05/googles-dart-language-on-android-aims-for-java-free-120-fps-apps/ – Jorge Casariego Aug 08 '15 at 04:34
  • 1
    @Marzouk Related Google IO video on ART: https://youtu.be/EBlTzQsUoOw Also DART is a language aimed at the web - related Google IO video on Dart: https://youtu.be/bsGgfUreyZw – Morrison Chang Aug 08 '15 at 04:34

1 Answers1

5

ART

ART is the new Android Runtime. The idea is to replace the Dalvik Virtual Machine with an ahead-of-time on-device compiler suite called dex2oat and a new runtime environment for apps. So if you install an application, it is first compiled to native code by using one of the dex2oat compilers, for example Quick(default in 5.0, 5.1) or Optimizing (default from 6.0), and stored in a so called oat file, which is an ELF shared object. When the app is executed, the runtime loads the content of the oat file into a preinitialized app process. The advantage of AOT compilation is, that you can do state-of-the-art optimizations because it does not execute at runtime. So we get faster apps but slower installation time.

DART

As you gave the link to the Android Dev page, I assume you are NOT talking about the DART language but about the Dalvik Runtime.
Dalvik is Android's bytecode interpreter (and JIT compiler) that used to interpret and optimize app code on the fly while executing it. So compared to a AOT compilation, the amount of optimization that can be done is restricted by the fact that longer optimization time slows down the actual execution of the application. Dalvik is superseded by ART in Android 5. Still, apps' code is stored as dex files which are the input format for the ART compilers. Also, for debugging purposes and for devices with low persistens memory, the interpreter is still around, even though it is not default and it might be a lighter version.

user3363866
  • 457
  • 2
  • 11
  • 1
    actually even when instructing `dex2oat` to compile `everything`, which is not the default option, some code is still left in bytecode format for interpretation, like the class initialisers. The default option leaves additional code to be interpreted, like rarely used functions. – Paschalis Oct 21 '15 at 22:27
  • 1
    Actually, I recently discovered that using the `Optimizing` backend together with the compuler filter`everything` also includes class initializers. I guess you are in particular talking about the `Quick` backend? Anyway, I guess there are still code fragments that are not compiled town to native code. – user3363866 Mar 21 '16 at 12:12
  • yes, it should have been the `Quick` backend on `Android M`! – Paschalis Mar 21 '16 at 14:13
  • Actually this is strange since M uses ``Optimizing`` by default, probably a fallback that seems to happen in some rare cases... – user3363866 May 10 '16 at 09:44