Is MQL compiled or interpreted? - page 2

 
Amir Yacoby:
Interpreters are just not suited for trading. It involves interpreting each statement while running it, very poor for trading. The only thing I was not sure of is if it produce native or intermidiate code. Although I guess any one who designs such a platform would go for native compiled code, the most reasonable choice. 

I'm not sure what you mean. There is lot of web-based trading clients running JavaScript. And also many others providing their own scripting languages, such as Pine in TV.

 
Stanislav Korotky:

I'm not sure what you mean. There is lot of web-based trading clients running JavaScript. And also many others providing their own scripting languages, such as Pine in TV.

I don't know about them but surely they will not get in an intepreted script language the prformance of a compiled oop language.
* the need to intepret while running makes it not suitable.
 
nicholi shen:

I've always taken the "knowledge" that MQL is a "compiled" language at face value. Someone in another forum is claiming that MQL is in fact encrypted and then interpreted.

Back in the day, I think this was called P-code for "precompiled code" or "portable code" depending upon the context.

This slideshow, second page, describes this a bit for "portable code."

https://www.slideshare.net/Sandeep_Rv/p-code

I've always just assumed that MQL was compiled to P-code and interpreted somehow, much as described in this link.

P code
P code
  • 2012.12.04
  • Sandeep Rv, Intern Follow
  • www.slideshare.net
SYSTEM  SOFTWARE     PCODE     R.  V.  COLLEGE  OF  E…
 
Anthony Garot:

Back in the day, I think this was called P-code for "precompiled code" or "portable code" depending upon the context.

This slideshow, second page, describes this a bit for "portable code."

https://www.slideshare.net/Sandeep_Rv/p-code

I've always just assumed that MQL was compiled to P-code and interpreted somehow, much as described in this link.

This is the cross platform code, like what java did with java virtual machine(this is what allows java to run on all kind of systems, windows pc, mac etc). It could be done this way with mql5 compiling it to bytecode but it would be slower then just compile into machine code because the intepretation to machine would be carried out only later, at runtime.
 

Let's say for sake of argument that MQL is compiled. If that is so - shouldn't these two source files compile and produce ex4's with an identical file hashes?


#property strict

void OnStart()
{
   bool b = false;
}
#property strict

void OnStart()
{
   bool a = false;
}

result: 

Different hashes. 

 
nicholi shen:

Let's say for sake of argument that MQL is compiled. If that is so - shouldn't these two source files compile and produce an ex4 with an identical file hash?


result: 

Different hashes. 

Every time you compile even the same source file you'll get different executable. This fuzzification is done intentionally to make it harder to decompile.

 
Amir Yacoby:
I don't know about them but surely they will not get in an intepreted script language the prformance of a compiled oop language.
* the need to intepret while running makes it not suitable.

This depends from use case. If it's not HFT or some kind of deep learning/data mining - scripting language can fit as well.

 
Stanislav Korotky:

This is not a question of beleif. This is a fact. MQL5 is definitely a compiled language, producing native 32 and 64 bit code. You can find some posts about compilation on the russian forum, for example this one.

The main proof of the fact is that the speed of compiled mql5 program is very close to a compiled c++ program. This can't be for an interpreter.

Yes, the final output is encrypted, but this does not mean that compilation is somehow impossible.

As for the original question, I'm not sure I get the point. If you change the source code and do not recompile it, you'll get old error messages from the running old executable.

Many Python binding modules that wrap C++ libraries also run at nearly the speed of a native C++ program. What I'm not understanding is if the MQL source code is being compiled to machine code then how do run-time errors know the exact line number and char-count to point to in the original source file?

 
Stanislav Korotky:

Every time you compile even the same source file you'll get different executable. This fuzzification is done intentionally to make it harder to decompile.

Ok, I understand now...  Thanks for the clarification. 

 
nicholi shen:

Let's say for sake of argument that MQL is compiled. If that is so - shouldn't these two source files compile and produce ex4's with an identical file hashes?


result: 

Different hashes. 

An interpreter usually executes the program. It does not create a file. This is done by compilers. 
And even if it would, the fact that the files are not identical can be asked on the output of an interpreter as well, meaning it does not prove it's not compiled.
Stanislav Korotky:

Every time you compile even the same source file you'll get different executable. This fuzzification is done intentionally to make it harder to decompile.

Nice to know, makes sense.
Reason: