Can C++ totally replace Javascript?



  • hey guys

    Im pretty new to programming and qt/qml. I've looked at a few QML examples and noticed most of them can make use of C++ or Javascript for logic. Now i don't actually use C++, i use Python but its bindings of Qt allow its users to do nearly everything C++ can when working with QML, so all my questions will refer to C++ not python.

    The qml example "Same Game", is made with the logic purely being external javascript files. My question is: is it possible for C++ or any Qt language binding to totally replace Javascript and perform all the logic in the "Same Game" example or any other qml app and get the same results that Javascript could?

    I don't really know Javascript, but I know it would be silly not to make use of Javascript, and i plan to within the same qml file, but any external files i would rather it be a .cpp file rather than a .js one.



  • Yes, but it may not be that much flexible and quick to develop in. There is nothing JS can do that you can't do in C++, but due to its static nature, C++ is a tad less suited for certain tasks.

    With QML in particular, JS saves you a lot of time, and you can always go back and convert performance critical parts of your app to C++ code. JS itself is not all that different from C++, well, in a lot of ways it is a lot different, it is dynamically typed, it is interpreted and it has a totally different OOP paradigm, but in terms of syntax it is still a C based language, just as C++.

    JS is easy, once you overcome the idiotically designed OOP in JS you will become comfortable with it quickly. Especially for QML, where you will hardly ever need to write OOP JS at all, you might as well ignore OOP and use JS as a simple scripting language, as it was originally intended before someone got the moronic idea to force a scripting language to become an application development language.



  • Thanks utcenter. After reading your reply i think it's best that i try to learn some Javascript.



  • You cant go wrong with C++. Python and JavaScript. Having these three languages under your belt, equips you for just about any programming related task, System, Desktop, Network, Game, Web, ...


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.