How Does Dart AOT Work?
Asked Answered
T

1

10

In my search for how Dart AOT works, I have not found many resources except this video. I would like to know how it is that code can be compiled down to native machine code, such as Android or iOS, when there exists different pieces of hardware that code needs to run on.

From what I understand, there are only descriptions of apps produced in Flutter. That description (written in Dart) is then compiled down to native machine code, but how? A program written in Swift is different from a program written in Kotlin.

Tribute answered 25/4, 2018 at 0:57 Comment(0)
F
15

A compiler creates the binary code from Dart source code. For mobile applications the source code is compiled for multiple processors ARM, ARM64, x64 and for both platforms - Android and iOS. This means there are multiple resulting binary files for each supported processor and platform combination.

From what I understand, there are only descriptions of apps produced in Flutter.

Not sure what you mean by that. The concept of source code and compilation to a target platform is basically the same for each programming language. JIT (Just in Time) compiles at runtime on-the-fly while AOT (Ahead of Time) compiles before the application is deployed and launched.

A program written in Swift is different from a program written in Kotlin.

Also not sure what you mean by that. Swift can compile to native code and Java to Java bytecode. Swift is AoT while Java is JiT. The end result is always binary code for the target platform and CPU.

Finely answered 25/4, 2018 at 4:52 Comment(7)
The first quote: Isn't a widget just an abstract description of what the app should be? A Stateless/Stateful widget one one platform is different than another, correct?Tribute
The second quote: I'm using Flutter to make two different applications essentially, one for Swift and another for Kotlin. Are they compiled separately?Tribute
Yes, for one the Swift compiler is invoked and for the other the Kotlin compiler. The results of the compiled Dart and Kotlin or Swift are packed together in a deployablePlessor
Thank you very muchTribute
You're my Dart/Flutter hero. HahaTribute
Swift can compile to native code and to Java bytecode. What do you mean by this, can you elaborate? Is this a mistake? The closest resource I found to what you suggest is this, it certainly doesn't state it's possible 😅Genie
@BenButtenworth thanks for the hint. I meant "Java to Java bytecode" -> fixedPlessor

© 2022 - 2024 — McMap. All rights reserved.