-
Content Count
324 -
Joined
-
Last visited
-
Days Won
25
Everything posted by Arnaud Bouchez
-
The Case of Delphi Const String Parameters
Arnaud Bouchez replied to Mike Torrettinni's topic in RTL and Delphi Object Pascal
All this is a void discussion. This code is just broken and should be fixed. It has nothing to do with const or whatever. The compiler is doing what it should, but the code is plain wrong. I fully agree with @David Heffernan here. About the "address", it should be pointer(Value) not @Value. pointer(value) returns the actual pointer of the string content in heap, so will change. It is a faster alternative to @value[1] which works also with value='' -> pointer(value)=nil. @Value returns the memory adress of the local Value variable on the stack, so won't change. -
Performance of MOVE vs + for concatenating mixed type values
Arnaud Bouchez replied to Mike Torrettinni's topic in Algorithms, Data Structures and Class Design
Binary is not text, so it is pointless for your problem. You need the integers to be written as text, not as 4 bytes binary. You could directly write to the TWriteCachedFileStream, too, without any temporary string. And append the integer values using a shortstring and old str() instead of IntToStr() which uses the heap. -
Security - How freaky can you get!
Arnaud Bouchez replied to Clément's topic in Algorithms, Data Structures and Class Design
Signing the executable is the key here. And also make a minimal security audit. A password should be hashed, and never stored in the executable itself. It has nothing to do with Delphi. It was a poor security design of the application. About logic security, and reverse engeniering, Java or C# are much worse than Delphi. You can easily decompile Java or C# executable.... unless it has been obfuscated explicitly. I can tell you that I "hacked" so many C# dlls which we lost the source... 😉 Whereas a Delphi exe is compiled, and lack a lot of RTTI, so it is much more difficult to get something about it. -
Performance of MOVE vs + for concatenating mixed type values
Arnaud Bouchez replied to Mike Torrettinni's topic in Algorithms, Data Structures and Class Design
Note that you don't store the content, you re-assign each new line. So you are testing something non reallistic, which is worthless trying to optimize it. What is slow is not data moving, but memory allocation. One performance problem is the temporary allocation of strings, if you call Integer.ToString. For our mORMot TTextWriter, we don't use any temporary allocation, and even have pre-computed values for the smallest integers. Note that Delphi TStringBuilder will actually be slower on Win32 than naive concatenation. It also allocate a temporary string for integer appending... 😞 https://www.delphitools.info/2013/10/30/efficient-string-building-in-delphi/3/ I would stick with naive string concatenation, and I guess it will be fast enough in practice. It would be premature optimization otherwise. -
git and Delphi tooling?
Arnaud Bouchez replied to Lars Fosdal's topic in Project Planning and -Management
Git for Desktop is just a bloated Electron app.. I would not recommend it. I don't use any gui tool for git. For simple git process, I use - on Linux, I use some simple scripts: https://github.com/synopse/mORMot2/blob/master/commit.sh and https://github.com/synopse/mORMot2/blob/master/kompare.sh on Linux - for mORMot, I made a simple VCL app which calls a source comparison tool, then call some scripts. https://github.com/synopse/mORMot/tree/master/SQLite3/Documentation/SourceCodeRep (which also update a fossil repository altogether with github - for standalone/private repositories, https://fossil-scm.org/home/doc/trunk/www/fossil-v-git.wiki is awesome, Windows native, with much more features than git and it has a build-in web ui, and the ability to mirror to git) -
How to calculate class size using TMemoryStream.size?
Arnaud Bouchez replied to Jenifer's topic in Algorithms, Data Structures and Class Design
Asking the very same question here and in SO is not very fair. -
Our Open Source mORMot has a powerful MVC Web development model, based on Mustache templates for HTML/CSS views, and interfaces/classes to write the Controller and the Model. Check https://synopse.info/files/html/Synopse mORMot Framework SAD 1.18.html#TITLE_498 and
-
I guess this is a python runtime limitation. Due to the https://en.wikipedia.org/wiki/Global_interpreter_lock then the engines are not thread-safe. Whereas for instance, we use SpiderMonkey (for running JavaScript) with a per-thread engine, with no problem.
-
is it possible to undeclare an identifier?
Arnaud Bouchez replied to dummzeuch's topic in General Help
I guess the only way is to use a "free" name like "ErrorMsg" instead of "Error"... -
auto-generated REST APIs?
Arnaud Bouchez replied to David Schwartz's topic in Network, Cloud and Web
This is not TMS DB Remote for sure. But a request like GET /tms/xdata/Customer?$filter=Country/Name eq 'USA'&$orderby=Name&$top=10 seems very close to a SQL SELECT. Security seems pretty basic: is there something more than the CRUD permissions of https://download.tmssoftware.com/business/xdata/doc/web/entity_sets_permissions.html ? I guess the https://download.tmssoftware.com/business/xdata/doc/web/onentityget_event.html callback seems a bit manual to handle. Even if the client is authenticated, how to you go deeper into the authorization? For instance, if you have a DB with all customers for all salers, how to prevent one saler to get the customers of other salers from the same table? So not any arbitrary SQL statement could be executed, for sure. But the client side is still deciding what it queries, unless the server is bloated with authorization code. What I would like to emphase is that it may be a 3-tier physical architecture, but it is still a 2-tier logical Architecture. The logic is still in the client. A much cleaner n-Tier architecture would be to create a real business layer (logical 3-tier) - or even better an application layer (logicial 4-tier as in DDD), and expose only safe and efficient REST endpoints to the clients. Then the server will query the data, and expose it as DTOs to the clients, depending on each bounded context (business layer) or each use-case (app layer). The client side is still much too tied to the underlying database. In a clean SOA architecture, you don't start from the database, but from the client use-cases. -
Micro optimization - effect of defined and not used local variables
Arnaud Bouchez replied to Mike Torrettinni's topic in Algorithms, Data Structures and Class Design
Some hints about performance on REAL bottlenecks: It covers, among others, the tip of a sub-function if you have some temporary managed variables (like string). The associated code, proving the slide assumptions, is available at https://synopse.info/files/slides/EKON22_2_High_Performance_Pascal_Code_On_Servers.zip Worth I look to understand how it works in practice. But remember: "Premature Optimization if the Root of All Evil !" (DK) -
auto-generated REST APIs?
Arnaud Bouchez replied to David Schwartz's topic in Network, Cloud and Web
It is clearly a wrong good idea. I don't see the benefit in respect to executing the SQL and return some JSON - which is a bad idea per se. I just answered on SO why direct exposition of the database to a REST/HTTP/JSON client is not a good idea. https://stackoverflow.com/a/64936643/458259 It is still a 2-Tier architecture, from the logical point of view. Of course, it is a 3-Tier architecture from the physical point of view, but what matters is the logical point of view, and adding a physical layer is not a benefit here. -
Did you try with FMX? Then you can switch the rendering engine behind it.
-
Do you speak about Direct 2D 1.1 or Direct 2D 1.0? 😉 At least with GDI (GDI+) or Graphics32 we have consistent performance.
-
@FPiette Direct2D is no silver bullet either. It has been reported to be slower than GDI, due to wrongly implemented drivers, and is somewhat deprecated/unoptimized/unused. @Mike James Don't forget about GDI+ which is part of Windows, and has good performance, with nice features like Alpha channel and good antialiaising. Which kind of drawing do you need?
-
So many "goto" in the source code. 🙂
-
Anyone who uses FastSpring as the payment processor received their payment for the last month?
Arnaud Bouchez replied to Edwin Yip's topic in General Help
I had a similar problem decades ago with a French payment processor called "Yaskifo". Small startup which offered best prices at that time. But with wrong management of their internal costs, and which were sued by French banks at that time... Yaskifo owned me thousands of Euros, which I never saw back... Once their company was bankrupted, all customers could just weep. I don't know anything about FastSpring, but in doubt, my advice would be to switch to a bigger and safer alternative - at least joined to some well known bank or company. Even if their fee is higher. -
You would need two memory managers, one per CPU socket.... Which is not possible with the Delphi RTL yet. You may try to use a per-thread memory manager, not FastMM4, which uses a per-thread arena for small blocks. There are some around for Delphi - just google for it.
-
Some tools - like cnpack IIRC - allow to format the text into source code string after being pasted.
-
Runtime create new "fields" with RTTI on a tComponent
Arnaud Bouchez replied to microtronx's topic in RTL and Delphi Object Pascal
Not possible, as François wrote, and also not useful. What would be the purpose of adding new properties at runtime? How to you access them? If what you expect is to make public something private, then you can trick the class by inheriting it locally, publishing the properties, then hard-casting to your type. If what you expect is to add some fields to an existing class, it is not possible because the class instance size if hardcoded during compilation. If what you expect is to have some additional information linked to an existing class, maintain a dictionary/map with the instances, and create a co-object associated with the main object lifetime, in which you put the needed data. If what you expect is to have some additional information linked to an existing class (as a variation to the previous item), inherit from this class or even better nest this class into a main owner class/TComponenet, which will have your expected behavior. -
Why is public class method marked as used, while it's not actually used?
Arnaud Bouchez replied to Mike Torrettinni's topic in Algorithms, Data Structures and Class Design
@David Heffernan , come out of @Stefan Glienke body! Now both Delphi reference guys have enabled their internal Technical English Compiler (tm) in paranoid mode! 😄 -
Why is public class method marked as used, while it's not actually used?
Arnaud Bouchez replied to Mike Torrettinni's topic in Algorithms, Data Structures and Class Design
Exactly. This is one of the reasons why enabling extended RTTI did increase the exe size by a big margin, and why I usually disable it unless I know I will actually need it. -
They just rewrite a regexp-like engine, which are usually using byte codes. Note that when a regexp uses JIT, it is faster, but not in all cases. For pascal source code of a very fast regexp engine, check https://github.com/BeRo1985/flre - you will see it is complex to make such things fast! But to be fair, my guess is that Everything as a tool is fast not because its pattern search is fast, but because all the file names are already cached in memory. So it doesn't have to call the Windows API to get all the file names. The real bottleneck is not the search itself, but the OS API calls. Byte-code search in the list may result in the search being a bit faster, but for only a few percent. So this performance statement is more like a marketing statement - not false, but not the real performance trick. As another reference code, perhaps easier to read than FLRE, check our Open Source TMatch object in https://github.com/synopse/mORMot2/blob/master/src/core/mormot.core.search.pas It is very fast e.g. to find e.g. '*.pas' or 'toto*.pas' or '*inside*'. When I mean fast, it is fast (using algorithms like Holub and Durian (2005) SBNDM2 algorithm). And if you want to see some code about an expression search engine, using an AST and some kind of byte codes, check the TExprParserMatch class in the same unit.
-
Interesting sort implementation, does not fit into usual API tough
Arnaud Bouchez replied to Tommi Prami's topic in Algorithms, Data Structures and Class Design
Nice to read. But I am not sure indeed where it should be used in practice. -
Take look at Zeos/ZDBC. https://sourceforge.net/projects/zeoslib/ They are Open Source, and with very good performance. If you bypass its TDataSet descendants, and use directly the ZDBC layer, you will get even better performance than alternatives, e.g. when you retrieve only one row of data (e.g. to fill a single class properties). And it has very good FPC support, too. But I guess you may be able to use your current version of FireDac with the latest Delphi, with minor changes to the source code...