DragonFax DragonFax - 3 years ago 290
Dart Question

Is the Dart VM still used?

I've been using dart/flutter for a few projects, and I'm really enjoying it.

I've read that when building a mobile app, dart builds a native app with native code. But I've also read that dart has its own VM for performance.

What I'm trying to understand is if that VM is what is used when you build a mobile app, or is it building other code that it compiles for the native app. And if its doing something else, what is the dart VM still used for?

Answer Source

Short answer: yes, Dart VM is still being used when you build your mobile app.

Now longer answer: Dart VM has two different operation modes a JIT one and an AOT one.

In the JIT mode Dart VM is capable of dynamically loading Dart source, parsing it and compiling it to native machine code on the fly to execute it. This mode is used when you develop your app and provides features such as debugging, hot reload, etc.

In the AOT mode Dart VM does not support dynamic loading/parsing/compilation of Dart source code. It only supports loading and executing precompiled machine code. However even precompiled machine code still needs VM to execute, because VM provides runtime system which contains garbage collector, various native methods needed for dart:* libraries to function, runtime type information, dynamic method lookup, etc. This mode is used in your deployed app.

Where does precompiled machine code for the AOT mode comes from? This code is generated by (a special mode of the) VM from your Flutter application when you build your app in the release mode.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download