Is QML translated into native code at the compilation time or is it interpreted at runtime the way JavaScript is ran in web browsers?

AFAIK, there seem to be no straight and detailed explanation in the Qt documentation, but some Qt hackers try to explain it:

QML is compiled to an optimized bytecode-like stream and the JavaScript expressions pass through an optimized evaluator for simple expressions.

There also is related QTBUG task QtQuick startup time needs to be improved; cache compiled QML between runs

My understanding is that QML status hasn't been settled completely and engineers don't declare it fixed, so they have freedom to improve it in future.

ATM, it best advice is to mix C++ with QML, having all application logic in C++ and presentation in QML, but ideally divided into smaller QML files, not in a single large QML file.


With Qt 5.3 and an enterprise license, there is actually a way to have it precompiled.

https://doc.qt.io/QtQuickCompiler/

This is useful for iOS where Apple doesn't allow JIT code generation.

Tags:

C++

Qt

Qml