Buffer overflows - page 2

 
JC:

Didn't strike me as any more vague than the perennial question about "what other language is MQL most like?" Or something like https://www.mql5.com/en/forum/210326, which WR answered far more helpfully...

MQL is MQL I never understood this need to compare it to an other language.
 
Alain Verleyen:
MQL is MQL I never understood this need to compare it to an other language.

What about the 432,756,913 people with prior experience of other programming languages, wanting to know what differences they need to focus on when starting with MQL?

 
JC:

What about the 432,756,913 people with prior experience of other programming languages, wanting to know what differences they need to focus on when starting with MQL?

In my opinion you need to learn a language on itself, not by searching differences or similarities with others. Anyway people do as they want, I don't care.

 
JC:

What about the 432,756,913 people with prior experience of other programming languages, wanting to know what differences they need to focus on when starting with MQL?


Since I'm one of those, can you please write a quick summary of differences, so I don't have to go through documentation?

Comparison to any one of the C++, Java, C#, Python, Pascal, Fortran, Cobol, Rust, Dart, will be enough. 

 
Drazen Penic:

Since I'm one of those, can you please write a quick summary of differences, so I don't have to go through documentation?

Comparison to any one of the C++, Java, C#, Python, Pascal, Fortran, Cobol, Rust, Dart, will be enough. 

Given your profile history, I'm not sure why you're asking this.

There have been lots of these summaries over the years on this forum, so I won't repeat them. Instead, I'll cover - briefly - something which is much less commonly discussed.

MQL is fairly similar to languages such as C# or Java - similar syntax, classes and inheritance, managed memory access etc. But every modern language is two things: its syntax and, quite separately, its "framework" / "standard class library" / whatever you want to call it. Learning to write in C# is at least as much about learning the .NET Framework as it is about the syntax of the C# language. Similarly, there are the really quite separate topics of learning MQL syntax and then learning how to use the language to place trades, or draw objects on a chart etc.

The big, big surprise with MQL is that the language has classes and inheritance, but its "framework" doesn't make any use of them at all (for legacy reasons).

You might expect that the MQL environment would expose some sort of Orders collection, containing some sort of Order class which represents each open order with the broker. For example, you might expect to write code something like the following:

for (int i = 0; i < MQLEnvironment.Orders.length; i++) {
        Order* pOrder = MQLEnvironment.Orders[i];
        // And now, examine properties of an open order or trade by looking 
        // at properties of the pOrder object such as pOrder.profit
}

Completely wrong. When coming from another environment of an otherwise-comparable language, that's probably the biggest preconception which someone needs to throw out.

Instead, MQL has static "pools" of data, in effect arrays, which you loop through and then query using functions specific to that pool. For example, to enumerate pending orders in MQL5, you do the following:

  • Get a count of the orders using OrdersTotal()
  • Loop through to the total
  • Do OrderGetTicket() to retrieve the broker ticket number for the order at each array index N. This also makes that order the "context" for the following step...
  • Query properties of the currently-selected order using functions such as OrderGetDouble()
There are various semi-official libraries which do add to MQL the sort of class-based access outlined above, but they don't form part of the official language and its documentation. 
 
JC:

Given your profile history, I'm not sure why you're asking this.

It was sarcastic

 
Alain Verleyen:

It was sarcastic

It did seem likely to be some terse Eastern European humour, but it's raining outside and I couldn't resist the opportunity to rant a little about the legacy, antiquated elements of MQL5. 

 
JC:

It did seem likely to be some terse Eastern European humour, but it's raining outside and I couldn't resist the opportunity to rant a little about the legacy, antiquated elements of MQL5. 

This forum lacks humour for sure, you still have to talk about Python, Pascal, Fortran, Cobol, Rust and Dart.
 
JC:

Short answer: no.

In the sense you're asking about, MQL is more similar to something like C# than C++. Memory access is "managed". MQL code doesn't have raw memory pointers and can't directly address any arbitrary section of memory in the same way as C/C++.

But various types of invalid-memory exception remain possible, as they do in comparable languages such as C# or Java. For example: out-of-bounds access to an array, or trying to use an object which has been deleted.

Nice answer. Thanks

 
William Roeder:

You posted a vague question, you got a vague answer and a request for more information which you never provided. "You might wanna stop asking because you are not going to get helpful answers that way."
          How To Ask Questions The Smart Way
          Dealing with rudeness

How come most other answers are not vague? Are you the only supplier?

Reason: