Is MQL compiled or interpreted? - page 4

 
nicholi shen:

Fascinating... I'm curious to know how the original source is compiled into the ex5 in order to provide run-time debugging... 

The line numbers are part of the way a compiler builds the data, usually in a tree structure, and the nodes contain the original line number. So the source line numbers is not something that proves anything. When you compile with debug mode, usually it inserts more data in those tokens of the trees, and some cases (in the environments I worked with) it inserts exit routines (calls to the debugger program) before and after each statement. This means after each statement is run, the debugger is called. This allows the breakpoints.
 
nicholi shen:

But the question was about a "normal" compilation... how is the exact line number and char known to the terminal when the program was explicitly compiled NOT using the debugger?

If non-debug compiled version mentions line and char location, there can be only one conclusion.

 
alphatrading:

Hmm, I don't understand how one can read from Renat's post that MQL in general is natively compiled.

He is very clear about the fact that the runtime (MetaTrader) is capable of executing old interpreted  and new natively compiled code. He is also clear about the fact native compilation is specific to the MT5-x64 version only. So, MQL4 and MQL5 in MT5-x32 is still interpreted code, as it always was since MQL2. Just look at the speeds. Can it be more clear?

Or, to express it in another way: compare the speed of the same code compiled in build 225 and compiled in build 1090. You will be surprised to find that build 225 is sometimes faster. This is because MetaQuotes introduced so much overhead over the years which is not related to trading functionality but to obfuscation etc.

Now hopefully nobody comes out and claims that build 225 was natively compiling. That build was neither obfuscated nor protected, you may call it "open-source". One can literally watch it interpreting the MQL byte-codes.

 
alphatrading:
Or, to express it in another way: compare the speed of the same code compiled in build 225 and compiled in build 1090. You will be surprised to find that build 225 is many times faster. This is because MetaQuotes introduced so much overhead over the years which is not related to trading functionality but to obfuscation etc.
In my translated version I understand from his first post the following:
1. New compiler released in may,2015 for MQL5.
2. It also includes optimization for 64bit mt installations.
3. The added optimization, does not affect badly the 32bit installations and older versions. both, 32 and 64 bit, use the new compiler starting build 1108 (it has more than just this optimization).

Nothing about old interpreter.
 
Amir Yacoby:
In my translated version I understand from his first post the following:
1. New compiler released in may,2015 for MQL5.
2. It also includes optimization for 64bit mt installations.
3. The added optimization, does not affect badly the 32bit installations and older versions. both, 32 and 64 bit, use the new compiler starting build 1108 (it has more than just this optimization).

Nothing about old interpreter.

What he calls "optimization" is the new native compiler specific to MT5-x64. Average users don't know the term "compiler" but they understand "optimization". Marketing...

2nd sentence: "...так и для старых версий терминалов." => "and for old terminals"

 
alphatrading:
What he calles "optimization" is the new native compiler specific to MT5-x64.
But he shows tests for the new compiler in those columns:
Mt5 1111 x 64 (2nd column)
Mt5 New 1111 (3rd column) 

 
And it doesn't mean that before the new compiler there was an interpreter. This was clearly visible, believe me, you notice one.
 
Amir Yacoby:
And it doesn't mean that before the new compiler there was an interpreter. This was clearly visible, believe me, you notice one.

If you don't want to believe start build 225 in a debugger. And you shall see...
And if build 1090 is not faster, that means exactly what?

And it was light...


ps: The table Renat posted shows the speeds of the native compiler and compare it to the speeds of the interpreted MQL in former versions. That's 5-20 times slower. Do you need any more reasons?

 
alphatrading:
If you don't want to believe start build 225 in a debugger. And you shall see...
And if build 1090 is not faster, that means exactly what?

And it was light...
Compilers are faster for the same source then interpreters, in general. If during the builds it became slower, it means one of 2:
1. That the previous build(225) was compiled and the current is intepreted (nonesense)
2. That as you said, they added extra stuff to the executable that was not in 225
 

May I cite from Renat's summary directly to shed light on the switch from interpreted MQL to natively compiled MQL:

<citation>

Summary:

2. The new 64-bit MQL5 compiler is faster than the current MQL5 from 2 to 10 times.                        <=== This is because of the switch from interpreted to compiled.

3. The new compiler is very close to the quality and speed of the Visual Studio 2012 x64 compiler.    <=== Makes sense because now native code is produced.

What does this give traders?

The ability to do more calculations at the same time and think less about switching to a DLL.                    <==== As now speed in MQL5 can be similar to speed in a DLL.

</citation>

Again, one must not forget that this is only available with the 64-bit compiler. Here an interesting question arises. It is my understanding that MQL code compiled with the 64-bit compiler is only executable in the MT5-x64 version. Is this assumption correct?
Reason: