Only one correction: in the descending languages of dBase II :) xbase calls. Clipper is already descending.
Originally dBase II had a very simplified language with syntax that reminded a little COBOL but applied more directly to something that was a little new at the time, the one of the relational database. Access to database members was done by simple imperative commands.
On the PC came dBase III with some things that started to move slightly away from this because the language started to have more programming resources and started to have a syntax that reminded a little Pascal or C, but it was just something very punctual and new.
For performance and ease of distribution someone decided to create a dBase compiler, the one of the Clipper. With time some Features were being added to get more expensive programming language, being able to extend some things. There they invented this notation that looked like an access to a compound object, as was the struct
from C, then you put the name of the object, the operator (if we can call it that) that some say is contextualized and the member that could be a field from the database table or a function that acts on it. It only works in tables and this context is always in which table the operation will be made.
The coolest part is that people could stop naming prefixed fields using the table name. At first I needed it because you were left with no visual context, which obviously complicated readability. Allowing, but not obliging, the name of the table is no longer necessary to give names with hungarian notation in the fields. What was a relief because the fields could only have 10 characters in the name.
The Clipper 5 changed everything, they decided to break with the dBase that was really sinking and turned into a programming language that by chance accessed a database. This notation strengthened and in fact, although the previous syntax worked through the language’s excellent preprocessor, Clipper 5 actually looked more like C (a touch of BASIC) than COBOL, and the use of prefixes became the standard.
Of course, Totvs did not understand this and did not have a default to use the prefix or not even in its newer version of ERP which was 100% written in Clipper 5. So they still use Hungarian notation. I suggested to fix this before it became impractical to change, which gives to imagine how important the gain would be and have 4 extra characters to better express in the field names. Did not accept.
When the ADVPL appeared they continued the same way, and in fact it would be difficult to change at that time (I would still try to change at least the novelties, which doesn’t look beautiful, but helps).
I can’t tell if the Clipper Summer 87 had a performance difference between using one shape or another, but it was probably the same as the Clipper 5 that had a very small difference, one that you can barely measure even in large volumes. I have never measured in Harbour and ADVPL less yet, but it is highly likely, and by history may even have some additional cost, but still irrelevant, you should not worry about it. IF ADVPL get too slow it won’t surprise me, but I doubt it will be very serious (good had a bug in Clipper Summer 87 SKIP -1
) was tens or hundreds of times slower than the SKIP 1
, and the tree allowed to make both at the same time. A lot of people bought Joiner’s pump just because of this :)
I don’t know ADVPL measurement methods except taking the Time()
:)
I doubt there’s a way to optimize it, and it’s worth it. Anyway it’s almost certain that it will be premature optimization, you’re not needing it for your code to become faster. " I guarantee" that if someone moves a little bit in those internal functions they can give a bigger gain, and nobody wants to do this.
For reasons of readability you should forget that there is such a dbSelectArea()
or SELECT
.
Of course, it works better when you don’t use Hungarian notation. As they use I don’t even know if I should use the prefix (some cases have no way not to use or complicates the code too much), it would be more readable because there is no redundancy. But I still prefer its use as standard.
I can not talk about the implementation of ADVPL but in Harbour the function analyzes the context that it is and makes exchange for internal access, so simply is falling into a if
that changes a value. The fact that this possibility exists has already slowed everything down, even if you are not using this prefix, but again irrelevantly. The compiler controls the context state globally, it is even made.
Reinforcement that in a language basically of script that runs on a VM (which for ADVPL is not optimized) it does not even tickle, you lose absurdly more for other reasons.
I think "abusive" use the two selection mechanisms of the table, should choose one or the other.
Try this:
ZX1->(dbSetOrder(1), dbGoTop(), dbSeek(cChave))
I put in the Github for future reference.
This improvement is only for the sake of readability, not having so much redundancy, will not improve performance. Anyway this dbGotTop()
shouldn’t make any sense, but it might be because of some problem of implementing the access system to SQL tables. I don’t know if you noticed you use the methods of accessing old Clipper DBF tables in a kind of cursor generated by query in the database through SQL.
My DbSeek()
and other functions had a parameter with index order. I put it out for everyone to use, practically nobody used, I think they believed that writing more lines gave the impression of being more productive.
Until recently I could still use only 10 characters in ADVPL. Some things now (right now) can use more characters, but I don’t know if field names. At least in table fields custom I wouldn’t use Hungarian notation, even to help differentiate.
Maybe it’s a perception problem. I saw no difficulty in reading the grouping of expressions (I don’t like to call the whole set of expression, since each part is executed in sequence separately) of Maniero, I used a lot in codeblocks until, before Harbour (HB has native multiline codeblock). I believe that if it had been a case of poor legibility, it would not have been given as an example. I don’t know in ADVPL, but in Harbour it would be enough to break in several lines with
;
if legibility is the problem. On the issue of timing I agree that only comes to the case if the difference is significant.– Bacco