Exploring Flutter’s Inner Workings: Ahead Of Time(AOT) versus Just In Time(JIT)

Discover Flutter development phases: JIT for real-time changes, DEVC for web optimization, and AOT for multi-platform deployment. Simplifying versatile application development.

Shirsh Shukla
5 min readJan 15, 2024

Welcome to the behind-the-scenes world of Flutter! This article discusses the differences between Ahead Of Time (AOT) and Just In Time (JIT) compilation. Get ready to learn how these techniques influence development and deployment, making Flutter a powerhouse for building dynamic applications. Let’s jump in!

If you’d like a quick and easy explanation, watch this video:

As you know, we have to go through two different phases whenever we create any Dart or Flutter application, the development phase and the deployment phase. The development phase is when you write, run, debug and test your application. Alternatively, the deployment phase is also referred to as the production mode or release mode and is when you are about to release your final application.

To develop desktop or mobile applications, you need to compile them with the JIT (Just-In-Time) compiler, along with a Dart virtual machine. However, when deploying the application, AOT (Ahead-Of-Time) compilation is required. AOT produces native-specific code based on your requirements, instead of relying on JIT.

For web applications, you need to compile using the devc compiler, which is a Dart development time compiler. This compiler transforms your Dart application into JavaScript code. For the final release deployment, instead of devc, you should use the dart2js compiler. dart2js is a Dart-to-JavaScript compiler that converts your code into optimized JavaScript code for web browsers.

The reason for having two different compilation techniques for development and deployment is straightforward. As a software developer, a rapid development cycle and dynamic compilation are desired. On the other hand, end-users prefer applications that start quickly and are optimized in terms of size and performance. These contrasting requirements lead to the use of JIT and devc during development and AOT and dart2js for deployment.

Now, let’s delve into each section in depth and discuss the development phase. When developing desktop or mobile applications, the program is handed over to JIT, a Just-In-Time compiler. In contrast to a regular compiler, JIT allows you to modify source code while the program is running, eliminating the need to stop the application and recompile.

JIT performs runtime translation of your code, known as dynamic compilation or compilation on the fly. This feature enables Flutter to support hot reloading. Combining JIT with the Dart virtual machine allows you to execute your code on any device, irrespective of its architecture.

Executing your Flutter application involves dispatching your code to any connected device, whether it’s an Android phone, iOS phone, or a desktop application. Regardless of device architecture or hardware, you can deploy your code seamlessly. This is the approach for developing desktop and mobile applications using Flutter and Dart.

Let us look at the development of a web application. Generally, in this case, a dart program is compiled using a compiler called devc, which stands for dart development and compiler. It is a smart compiler that converts dart code into highly optimized javascript code that runs on Google Chrome.

The smart compiler will be seen by them because when we have a modification to the dart application, it will be dispatched in your final output instead of compiling the entire code. With this technique, your development time will definitely be sped up.

Now. let’s discuss four strategies for deploying a Flutter application: which is a Stand-alone app, AOT complied, web, and a Native app.

In the case of deploying a stand-alone application, your Dart program is compiled using the normal Dart compiler, and the compiled code can only be executed on the machine where the virtual machine can be found.

In order to run this panel application, you must have the virtual machine, otherwise you cannot run the stand-alone programs. The question arises as to where I can get the DVM. You can get it with the Dart SDK or the Flutter SDK.

AOT compiled is a very important part of Flutter and Dart application deployment. The Dart program is compiled using a technique called AOT, which is ahead-of-time compilation. Before your program is deployed, this kind of combination occurs. By using AOT compilation, it converts your Dart program into a specific platform-specific executable binary file using a kind of translation.

For Android we can get the .apk, for iOS we can get the .iap, and for Windows we can get the .exe. It is this secret that allows Dart and Flutter to have the feature of multi-platform deployment.

Let’s take a look at deploying a web application. When you deploy a web application, the dart application is compiled using dart2js, which is Dart2 Javascript comparator. It converts your dart application into optimized Javascript code that can be executed on any web browser.

Here’s how you deploy the native application. If your dart application is being compiled with the dart to native compiler, we are able to compile it into platform-specific code, such as for Windows, Linux, and Mac, using the dart to native compiler.

That’s it for this article. As part of my research, I collected information from multiple websites from various sources. In case of inaccuracies or misinterpretations, please let me know by commenting below. Your insights contribute to the content’s continuous improvement and accuracy.

If you got something wrong? Mention it in the comments. I would love to improve.
I am Shirsh Shukla, a creative Developer, and a Technology lover. You can find me on LinkedIn or maybe follow me on Twitter or just walk over my portfolio for more details. And of course, you can follow me on GitHub as well.

Have a nice day!🙂

--

--

Shirsh Shukla

SDE at Reliance Jio | Mobile Application Developer | Speaker | Technical Writer | community member at Stack Overflow | Organizer @FlutterIndore