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. QT command line + JIT compile
Forum Updated to NodeBB v4.3 + New Features

QT command line + JIT compile

Scheduled Pinned Locked Moved Unsolved General and Desktop
6 Posts 4 Posters 492 Views 1 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.
  • M Offline
    M Offline
    mhsgoud
    wrote on 9 Aug 2022, 20:54 last edited by
    #1

    Hello,
    I am trying to write a command line widget in QT, where inserted codes should be compiled in runtime (something similar to Matlab). Is there any such built-in functionality in QT? I have found C++ JIT compilation libraries which are mainly used for game development and run under debug mode. I am wondering how Matlab for instance compiles C++ in runtime.

    1 Reply Last reply
    0
    • C Offline
      C Offline
      ChrisW67
      wrote on 10 Aug 2022, 02:04 last edited by
      #2

      AFAICT Matlab doesn't "compile C++ in runtime". Matlab has an interpreted scripting language that is not C++. Matlab scripts that can interface with custom functions authored in C or C++ (and vice versa).

      To implement your own interpreted language will require defining a language grammar and producing a parser that can recognise that and trigger appropriate behaviour in response. Tools like Yacc can help with this. There's nothing in Qt like Yacc.

      Qt Script and QJSEngine provide some scriptability to Qt programs.

      M 1 Reply Last reply 10 Aug 2022, 20:57
      2
      • C Offline
        C Offline
        candy76041820
        wrote on 10 Aug 2022, 12:12 last edited by
        #3

        Or, maybe, just ship a g++ with your program and call it with pipes, like what Autoconf and OJ/fiddler do.

        1 Reply Last reply
        1
        • C ChrisW67
          10 Aug 2022, 02:04

          AFAICT Matlab doesn't "compile C++ in runtime". Matlab has an interpreted scripting language that is not C++. Matlab scripts that can interface with custom functions authored in C or C++ (and vice versa).

          To implement your own interpreted language will require defining a language grammar and producing a parser that can recognise that and trigger appropriate behaviour in response. Tools like Yacc can help with this. There's nothing in Qt like Yacc.

          Qt Script and QJSEngine provide some scriptability to Qt programs.

          M Offline
          M Offline
          mhsgoud
          wrote on 10 Aug 2022, 20:57 last edited by
          #4

          @ChrisW67 thanks for your answer, I know that Matlab has a scripting language interfacing with core c++ functions, but it also does JIT compilation (I suppose in c++)
          https://nl.mathworks.com/products/matlab/matlab-execution-engine.html

          S 1 Reply Last reply 11 Aug 2022, 07:50
          0
          • C Offline
            C Offline
            ChrisW67
            wrote on 11 Aug 2022, 04:21 last edited by
            #5

            The JIT process is summed up fairly well in What does a just-in-time (JIT) compiler do? and how a JIT process executes code. Once a bit of p-code is executed the JIT compiler can cache the machine instructions to make subsequent executions faster. With intelligence, a JIT compiler can choose not to compile some p-code for which the overhead exceeds to run time.

            MATLAB converts its script language code into an internal p-code that is independent of the physical platform on which it runs. This is effectively what the MATLAB parser generates.
            The p-code can be executed on a software VM (and remain platform agnostic) or converted on-the-fly (the JIT compiler) into machine instructions for the actual hardware platform.

            To make your own JIT compiler you either need to invent all these pieces or generate an existing p-code for something like the Java JVM or Microsoft CLR. If your source high level language is C++ then you can probably use LLVM to some of the heavy lifting.

            1 Reply Last reply
            1
            • M mhsgoud
              10 Aug 2022, 20:57

              @ChrisW67 thanks for your answer, I know that Matlab has a scripting language interfacing with core c++ functions, but it also does JIT compilation (I suppose in c++)
              https://nl.mathworks.com/products/matlab/matlab-execution-engine.html

              S Offline
              S Offline
              SimonSchroeder
              wrote on 11 Aug 2022, 07:50 last edited by SimonSchroeder 8 Nov 2022, 07:51
              #6

              @mhsgoud said in QT command line + JIT compile:

              but it also does JIT compilation (I suppose in c++)

              How should it do JIT compilation in C++ if you write MATLAB code and not C++? From the link you provided:

              The improved architecture uses just-in-time (JIT) compilation of all MATLAB code [emphasis mine]

              1 Reply Last reply
              1

              1/6

              9 Aug 2022, 20:54

              • Login

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