Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

Are Qt/QML apps native or hybrid



  • Hello to all Qt people here,

    I'm programming in the world of Qt/QML and have come here just to know about the pros and cons of Qt/QML when they say they're cross-platform. I want to know, at what price.

    • I suppose when Qt/QML is cross platform, hence it's hybrid. But hybrid apps are said to essentially be 'websites', and they don’t work offline. But my Qt/QML apps can be run and work correctly even if my PC or mobile is not connected to the Internet. Eventually, is Qt/QML hybrid or native?

    • Among the cons of hybrid solutions are these that they can never deliver same efficiency, processing speed and stability as native codes. If it's right, so a QML or even Felgo programmer can never create a major and important Android app on Qt Creator to be as perfect as the one created by Java on Android Studio. Is this wrong? If not, and it's true, so if we want to create great mobile apps either for Android or iOS, using the world of Qt, it is but wasting time and we'd better go for Java and Swift.

    • Qt is merely based on C++ and it's its most significant point. QML is based on JavaScript (which is a hybrid language, hence a negative point for QML), C++ and OpenGL. I want to know how does QML use C++ and OpenGL to keep itself from being hybrid and take advantages of those two languages to be as close as possible to native code so that the apps created by it don't lack the features of efficiency, stability and speed?

    • The last question is that, what do the managers and experts of the Qt company do to address the matters above when they're strongly dealing with evolving and updating Qt gradually?

    Thanks so much for your time.


  • Lifetime Qt Champion

    Hi
    1: Often hybrid is used about applications that mix native code with web tech and runs
    in a browser. QML is cross-compiled to the target and is in that regards native.
    So QML is not hybrid in that sense. Using https://www.qt.io/qt-examples-for-webassembly
    would be such hybrid.

    2: Performance wise, Qt would not hinder to make the next block buster app.
    However, not all mobile concepts have a Qt wrapper so sometimes you must use native code/calls
    anyway.

    3: QML is made with c++. it uses javascript for interface logic and small tasks but for anything heavy
    you are recommended to make that in c++ and interface with the frontend.
    Its all compiled to the target so its really not hybrid or suffer any penalty
    to efficiency, stability and speed.

    4: They extend and refine QML to support new features and new platforms.



  • @mrjj

    Thank you so much for the answer.

    1- What does "cross-compiled to the target" in QML mean, please?
    2- I couldn't understand this section. Would you paraphrase it, please?
    3- So we must create the design part in QML and all the major code doing the real task in .cpp files. Was it what you meant? And when you say "compiled to the target" does it mean it's the behavior of native apps and not web based apps?


  • Lifetime Qt Champion

    @qcoderpro

    And when you say "compiled to the target" does it mean it's the behavior of native apps and not web based apps?

    Sure, C++ is a compiled language that results in native machine code - unlike Java which is compiled to machine independent code.

    Note that there is also a QtQuick compiler. I have not used that myself so I cannot say much about it.

    Regards



  • @aha_1980
    Thank you.
    Does your first sentence mean that, in some cases creating an Android app using C++ may be better than the one created by Java, because of their different methods of compilation? If so, in what context is it better? I guess "speed".

    For the QtQuick compiler, I hope another expert here gives some clear explanation.


  • Lifetime Qt Champion

    @qcoderpro I would not say that C++ is faster than Java, nor vice versa. Both can produce very fast, but also very slow programs if you use them wrong.

    Java has the Just-in-Time compiler to optimize at run time, which can gain performance for some programs. On the other hand, it has the Garbage Collector which can make your app slow if it starts to clean up at the wrong moment. I'd take that as a small advantage for C++ ;)



  • @aha_1980
    Thank you very much.
    Now all it remains is the questions I asked to reply to @mrjj


  • Lifetime Qt Champion

    Hi
    1- What does "cross-compiled to the target" in QML mean, please?

    (*)it means that the Qt you are using is made for the target/platform/architecture. When you, as example, make an app for Andriod, both Qt/QML(system) and your code is compiled with a compiler that can generate code for the given platform.

    2- I couldn't understand this section. Would you paraphrase it, please?

    (*)Qt/QML is as fast as any other native application.
    However, Not all mobile features is wrapped by Qt so most apps will mix
    both Qt/QML and some native calls.

    3- So we must create the design part in QML and all the major code doing the real task in .cpp files. Was it what you meant? And when you say "compiled to the target" does it mean it's the behavior of native apps and not web based apps?
    (*) Yes
    Both because not all can be done with the javascript but also
    due to it was designed this way. Using QML as front end and a c++
    backend for maximum UX flexibility and max performance.



  • @mrjj

    Thank you very much. I think I got all the things I wanted to.
    you also encouraged me and made me confident to continue with Qt. Thanks. :)


  • Lifetime Qt Champion

    @qcoderpro
    Super. Happy programming.
    Btw. just in case you didnt notice before
    https://qmlbook.github.io/



  • @mrjj
    Thanks. :)


Log in to reply