Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Scripting language/Compile Qt DLL from Metadata?
Forum Updated to NodeBB v4.3 + New Features

Scripting language/Compile Qt DLL from Metadata?

Scheduled Pinned Locked Moved Unsolved General and Desktop
14 Posts 5 Posters 4.1k Views 2 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • P Offline
    P Offline
    primem0ver
    wrote on 28 Feb 2017, 10:12 last edited by primem0ver
    #1

    Be patient because this question requires a little background to answer appropriately

    I am writing a large application that will make use of scripting for specific functionality. The script language that comes with Qt is too sophisticated for some of the target demographic that this application is meant for. The script language I am looking to use would need to be simple, easily read and learned, and void of the requirement of special characters in variable names or things like braces in function definitions. I have done a lot of research and have not found a good language that is still maintained on a regular basis (one older language called Falcon may have sufficed... but it is no longer useful as it has fallen into disrepair without updates.)

    Basically I want to be able to call Qt functions using a simple syntax. Theoretically I could do this making use of Qt's equivalent of .NET reflection class using metadata and the moc system. However, I would like to improve upon this if possible (for the sake of performance) by either using a virtual machine, or by somehow being able to compile executable code from script fragments (which will be a common phenomena in this application). What would really be fantastic is to be able compile a DLL from the script based on Qt Metadata... is this even remotely possible?

    1 Reply Last reply
    0
    • I Offline
      I Offline
      iam1me
      wrote on 28 Feb 2017, 10:33 last edited by iam1me
      #2

      Anything is possible if you are willing to devote the time and effort. Developing a Domain Specific Languages (DSL) is a common technique for providing a simplified interface to your application. Scripting languages like Javascript are often extended with application-specific functionality and data for this purpose, as Qt does. If Javascript is too complex you might consider VBScript. VBScript is more verbose, but uses less special characters and such. Since this appears to be your first attempt atcreating a DSL I suggest you stick with implementing a well-defined language like VBScript rather than attempting to create your own (unless it is very simple). If you can, take a course on compiler theory - that will give you many of the tools you need for this kind of work.

      It is possible to develop a compiler that produces binary dlls and such on the fly that you can dynamically load, but I would highly advise you avoid this for the time being. I think you will find the challenge of developing a parser and interpreter for your chosen scripting language to be more than enough of a challenge your first time through. Again - I highly advise you take a course on Compiler Theory if you are serious about this. If you can't take a course, then you can get a book like this: https://www.amazon.com/Compilers-Principles-Techniques-Tools-2nd/dp/0321486811/ref=sr_1_1?ie=UTF8&qid=1488277925&sr=8-1&keywords=compiler+theory

      1 Reply Last reply
      0
      • V Offline
        V Offline
        VRonin
        wrote on 28 Feb 2017, 10:38 last edited by VRonin
        #3

        Would python be an option? you can easily use PyQt to integrate with Qt

        "La mort n'est rien, mais vivre vaincu et sans gloire, c'est mourir tous les jours"
        ~Napoleon Bonaparte

        On a crusade to banish setIndexWidget() from the holy land of Qt

        M P 2 Replies Last reply 28 Feb 2017, 11:05
        2
        • V VRonin
          28 Feb 2017, 10:38

          Would python be an option? you can easily use PyQt to integrate with Qt

          M Offline
          M Offline
          mrjj
          Lifetime Qt Champion
          wrote on 28 Feb 2017, 11:05 last edited by
          #4

          Hi
          Besides calling Qt function, what other language constructs do you need?
          if/then/else
          variables
          array
          etc ?

          +1 for python as there is no { } as u ask about

          1 Reply Last reply
          0
          • V VRonin
            28 Feb 2017, 10:38

            Would python be an option? you can easily use PyQt to integrate with Qt

            P Offline
            P Offline
            primem0ver
            wrote on 28 Feb 2017, 21:49 last edited by primem0ver
            #5

            @VRonin Python Syntax is appropriate. However, I do not like Python because of its lazy (IMO) lack of basic programming features (unless it has been updated recently to include them). It is terribly inefficient as a result. A classic example is the Python for loop which wastes both time and memory. Technically, they do not exist as Python essentially turns for loops into a "foreach" loop. Creating a collection of integer objects to run a basic counter is insane in my book.

            Visual Basic is good too though a bit messy when it comes to OOP. An ojbect oriented version of BASIC that is not Microsoft specific would be a nice candidate. Unfortunately I am not sure that one exists.

            @mrjj said in Scripting language/Compile Qt DLL from Metadata?:

            Hi
            Besides calling Qt function, what other language constructs do you need?
            +1 for python as there is no { } as u ask about

            Pretty much the things you mentioned plus objects. I need variables to be able to hold an object and perform operations on them. The point is to write scripts to perform the manipulation of objects to be presented. Kind of like Flash's ActionScript.

            EDIT: Plus the ability to define functions. The perfect example of the kind of language (syntax wise) is Papyrus Script that is used by Bethesda games. Very, very easy to learn and read even if the modding tools are a pain to use because they don't always work properly.

            M 1 Reply Last reply 28 Feb 2017, 22:09
            0
            • S Offline
              S Offline
              SGaist
              Lifetime Qt Champion
              wrote on 28 Feb 2017, 21:59 last edited by
              #6

              Hi,

              If you would like to provide your own DSL, then LLVM might be worth considering.

              Here is a presentation about implementing a small DSL with LLVM.

              Hope it helps

              Interested in AI ? www.idiap.ch
              Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

              1 Reply Last reply
              1
              • P primem0ver
                28 Feb 2017, 21:49

                @VRonin Python Syntax is appropriate. However, I do not like Python because of its lazy (IMO) lack of basic programming features (unless it has been updated recently to include them). It is terribly inefficient as a result. A classic example is the Python for loop which wastes both time and memory. Technically, they do not exist as Python essentially turns for loops into a "foreach" loop. Creating a collection of integer objects to run a basic counter is insane in my book.

                Visual Basic is good too though a bit messy when it comes to OOP. An ojbect oriented version of BASIC that is not Microsoft specific would be a nice candidate. Unfortunately I am not sure that one exists.

                @mrjj said in Scripting language/Compile Qt DLL from Metadata?:

                Hi
                Besides calling Qt function, what other language constructs do you need?
                +1 for python as there is no { } as u ask about

                Pretty much the things you mentioned plus objects. I need variables to be able to hold an object and perform operations on them. The point is to write scripts to perform the manipulation of objects to be presented. Kind of like Flash's ActionScript.

                EDIT: Plus the ability to define functions. The perfect example of the kind of language (syntax wise) is Papyrus Script that is used by Bethesda games. Very, very easy to learn and read even if the modding tools are a pain to use because they don't always work properly.

                M Offline
                M Offline
                mrjj
                Lifetime Qt Champion
                wrote on 28 Feb 2017, 22:09 last edited by mrjj
                #7

                @primem0ver
                Hi
                Well, most ECMAScript based/inspired script language
                Well , what about lua then ?
                https://www.lua.org/

                Or this is also pretty cool
                http://www.angelcode.com/angelscript/
                But most likely too advanced and c++ like in syntax.

                There is also the good old ( @SGaist , valid point! , its deprecated but very solid )
                http://doc.qt.io/qt-5/qtscript-index.html
                Which can "cache it"
                http://doc.qt.io/qt-5/qscriptprogram.html#details

                I would go with JavaScript as its very easy to integrate and for simple stuff, its pretty basic.
                However it does have {} for functions and single threaded.

                P 1 Reply Last reply 1 Mar 2017, 03:34
                1
                • S Offline
                  S Offline
                  SGaist
                  Lifetime Qt Champion
                  wrote on 28 Feb 2017, 22:13 last edited by
                  #8

                  I'd avoid QtScript since it has been officially deprecated and removed from the official binary package. You can still built it by hand though but it's not necessarily a good idea for a new project.

                  Interested in AI ? www.idiap.ch
                  Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                  1 Reply Last reply
                  0
                  • M mrjj
                    28 Feb 2017, 22:09

                    @primem0ver
                    Hi
                    Well, most ECMAScript based/inspired script language
                    Well , what about lua then ?
                    https://www.lua.org/

                    Or this is also pretty cool
                    http://www.angelcode.com/angelscript/
                    But most likely too advanced and c++ like in syntax.

                    There is also the good old ( @SGaist , valid point! , its deprecated but very solid )
                    http://doc.qt.io/qt-5/qtscript-index.html
                    Which can "cache it"
                    http://doc.qt.io/qt-5/qscriptprogram.html#details

                    I would go with JavaScript as its very easy to integrate and for simple stuff, its pretty basic.
                    However it does have {} for functions and single threaded.

                    P Offline
                    P Offline
                    primem0ver
                    wrote on 1 Mar 2017, 03:34 last edited by primem0ver 3 Jan 2017, 03:38
                    #9

                    @mrjj
                    Java/ECMAScript is too full of "unnecessary" symbols that I refer to in my OP. Personally... I love the C style syntax and if it weren't for the more varied nature of my target population I would be perfectly fine with embedding Qt's version of ECMAScript; however I also recognize that people with a non-programming background may take one look at a file full of braces and other symbols they are not used too and say "I can't learn that!" This is what I am trying to avoid.

                    LUA is a nice language from a syntax perspective but it does not handle object oriented programming well because its only true object type is the "table". I really have no patience for dealing with its convoluted table structures.

                    @everyone
                    The problem is that I cannot find a script language that suites my needs. Like I said above... I have research this extensively over a period of time. This is the reason for my OP (original post).

                    Recently I have found a need in another project to create a very simplistic script like "language" for a solution in a .NET program. System.Reflection in .NET makes this pretty easy to do. I could do the same thing I did for this recent project in Qt because of the metadata used by Qt's object system. This gave me the idea of "what if I could somehow use the metadata to make it easier to do linking?" and post my original question. My current on the fly "translation" of the recent script I created does not solve the issue of the need for efficiency in my larger Qt project that could be resolved by either a VM or even better... the ability to compile a DLL based on linking to functions using Qt metadata (which was my original curiosity).

                    One things that may help you understand the nature of what I am trying to do: Cold Fusion is an ideal language as it uses a VM, it has a basic syntax, AND it is natively embedded into xml (which is where many of the script fragments will be placed). It would be fairly simple to write a "translation" utility that turns script text into Cold Fusion XML directives. Unfortunately it is a proprietary Adobe product. In my experience Adobe products cost way more than they are worth; especially considering the decline of Flash after they bought it from Macromedia and that Flash is their only other script technology.

                    @SGaist : I have looked into LLVM and scripting languages that use it. Unfortunately, I have already looked into the big lanaguages which already exist on this platform. I am afraid that they don't really suite what I am trying to do very well. I appreciate the link though as it seems to contain some information I was looking for about creating my own language using that particular platform.

                    1 Reply Last reply
                    0
                    • I Offline
                      I Offline
                      iam1me
                      wrote on 1 Mar 2017, 04:41 last edited by iam1me 3 Jan 2017, 05:16
                      #10

                      @primem0ver - have you considered providing your users with a visual workflow editor? For non-programmers, a visual workflow maybe easier to work with. Various products provide such an interface for their less technical users, while also providing a more fully featured programming/scripting language like java script for the more advanced users. Unreal Engine provides Blueprints for users who want to avoid c++ programming: https://docs.unrealengine.com/latest/INT/Engine/Blueprints/

                      Microsft provides a Workflow Foundation for Windows .NET Applications that I've used before. I've also worked on in-house workflow engines before. You can make them as fully featured or as simplified as you want. The Windows Workflow Foundation basically provides a visual programming language - you can do basically anything and everything that you could do with C#. The in-house one I worked on provided a script activity for advanced functionality, but the rest of the visual blocks provided high-level activities like send an email to a manager for approving a Purchase Request. Or: run a report and email it to me when it completes. Or: update a record in the database. No curly braces required!

                      P 1 Reply Last reply 2 Mar 2017, 03:37
                      0
                      • I iam1me
                        1 Mar 2017, 04:41

                        @primem0ver - have you considered providing your users with a visual workflow editor? For non-programmers, a visual workflow maybe easier to work with. Various products provide such an interface for their less technical users, while also providing a more fully featured programming/scripting language like java script for the more advanced users. Unreal Engine provides Blueprints for users who want to avoid c++ programming: https://docs.unrealengine.com/latest/INT/Engine/Blueprints/

                        Microsft provides a Workflow Foundation for Windows .NET Applications that I've used before. I've also worked on in-house workflow engines before. You can make them as fully featured or as simplified as you want. The Windows Workflow Foundation basically provides a visual programming language - you can do basically anything and everything that you could do with C#. The in-house one I worked on provided a script activity for advanced functionality, but the rest of the visual blocks provided high-level activities like send an email to a manager for approving a Purchase Request. Or: run a report and email it to me when it completes. Or: update a record in the database. No curly braces required!

                        P Offline
                        P Offline
                        primem0ver
                        wrote on 2 Mar 2017, 03:37 last edited by primem0ver 3 Feb 2017, 03:40
                        #11

                        @iam1me
                        Thanks for that suggestion. It is a really good one which I may implement. However...

                        @everyone
                        I think I just thought of a way I may be able to do exactly what I wanted to do when I posted this question. Tell me what you all think. I believe I actually can convert my own script language to a compiled Qt DLL by "cheating." The idea is that I use a parser to convert my symbolic script code into C++ code and then compile the C++ code into a DLL using Qt's command line compiler. If I were to decide on a strongly typed syntax, I could use am1me's suggestion for helping non-programmers not have to worry about types while the programmers should be fine with using types.

                        1 Reply Last reply
                        0
                        • S Offline
                          S Offline
                          SGaist
                          Lifetime Qt Champion
                          wrote on 2 Mar 2017, 08:16 last edited by
                          #12

                          Just one thing: Qt doesn't have any compiler, it's "just" a framework. It will be whatever your platform provides.

                          Interested in AI ? www.idiap.ch
                          Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                          1 Reply Last reply
                          1
                          • P Offline
                            P Offline
                            primem0ver
                            wrote on 2 Mar 2017, 17:27 last edited by
                            #13

                            Huh? Then how does the Qt Creator work? IT compiles stuff doesn't it? Personally I use the plugin for Visual Studio but the documentation says you can compile stuff from Qt Creator.

                            M 1 Reply Last reply 2 Mar 2017, 17:30
                            0
                            • P primem0ver
                              2 Mar 2017, 17:27

                              Huh? Then how does the Qt Creator work? IT compiles stuff doesn't it? Personally I use the plugin for Visual Studio but the documentation says you can compile stuff from Qt Creator.

                              M Offline
                              M Offline
                              mrjj
                              Lifetime Qt Champion
                              wrote on 2 Mar 2017, 17:30 last edited by mrjj 3 Feb 2017, 17:31
                              #14

                              @primem0ver
                              Creator is an IDE
                              You can make it work with most compilers.
                              It calls external tool for compiling.
                              The compiler is not part of Qt.
                              ( except the mingw on windows. there the compiler is included in the installer)

                              So no, there is no Qt c++ compiler. It will be Visual Studio or mingw or Xcode or gcc or what ever a platform offers. :)

                              1 Reply Last reply
                              2

                              1/14

                              28 Feb 2017, 10:12

                              • Login

                              • Login or register to search.
                              1 out of 14
                              • First post
                                1/14
                                Last post
                              0
                              • Categories
                              • Recent
                              • Tags
                              • Popular
                              • Users
                              • Groups
                              • Search
                              • Get Qt Extensions
                              • Unsolved