May 22, 2020
Among the many areas of Delphi enhanced in 10.4 there is the Runtime Library, which will have many quality and performance enhancements.
Delphi Runtime Library is one of the foundations of the product, as the UI libraries such as VCL and FireMonkey and also database access libraries and many third party components reply on the core RTL. That is why changes to the RTL are particularly relevant, as they tend to affect all developers. Here are some key changes about to become available.
Bit Counting Standard Functions
We have introduced new standard functions for common low-level bit processing operations, listed below.
-
Count Leading Zeros: Counts the number of leading zero bits preceding the most significant one bit of the parameter X. If X is zero, it returns the bit width. i.e. 32 for CountLeadingZeros32 and 64 for CountLeadingZeros64
-
Count Trailing Zeros: Counts the number of trailing zero bits following the least significant one bit of the parameter X. If X is zero, it returns the bit width. i.e. 32 for CountTrailingZeros32 and 64 for CountTrailingZeros64.
-
Count Population: Counts the number of 1 of the parameter X. Return value will be in the range from 0 to the bit width. i.e. 32 for CountPopulation32 and 64 for CountPopulation64
Additional Features for Classic Classes
- The TCustomIniFile class has bew methods WriteInt64 and ReadInt64
- The TGUID type has a new IsEmpty method
- The Items property of the TJSONArray class is now a default array property, allowing you to write myJArray[2] rather than myJArray.Items[2]
Better Stream Buffering
The CopyFrom function of the base TStream class used to have a fixed constant buffer for copying data (set to 60K). This can be very inefficient for copying large streams. The new default is 1MB, but the method has an additional parameter you can use to provide a specific buffer size depending on the copy operation you are doing (source and target streams). The new signature of the method is
// class TStream
function CopyFrom(const Source: TStream; Count: Int64 = 0;
BufferSize: Integer = $100000): Int64;
Performance Optimization
- JSON reading optimization: TJSONReader is now 50% faster
- Optimized assigning a sorted StringList to another StringList
- RTTI performance improvements include:
- TRttiMethod.Invoke is ~ 4 times faster
- TVirtualInterface invocation is ~ 1.7 times faster
- TRttiType.GetXxxx(AName) methods are ~ 10 times faster
- For TValue several operations are faster
- The QuickSort operation in System.Classes is now more efficient
FreeAndNil
We updated the signature of the FreeAndNil procedure, to avoid its use with interface references and other unsupported data types. It is now declared to require a reference to a TObject:
procedure FreeAndNil(const [ref] Obj: TObject); inline;
This means that incorrect usage of FreeAndNil will now cause a compiler error. In the past, incorrect usage would not be caught, leading to difficult bugs. Note that although the parameter is declared as const, the by-reference variable is indeed modified.
Additional Assorted Features
- We have removed some dependencies blocking certain console apps to run on Windows Server Core
- The TStringHelper.GetHashCode method has been updated not to uppercase the string before hashing it, so its result matches other internal operations like the TStringComparer class.
That's just a partial anticipation. We also did quite some work on the Parallel Programming Library, AppTethering, the REST and HTTP client libraries and more of the other Delphi RTL subsystems. Hope these improvements, even if relatively minor, will be appreciated for their positive impact in every day Delphi developers work.
This is a preview of an upcoming release of RAD Studio. There can always be last-minute bugs or changes. Nothing here is final until the release is officially made available. Sign up for our 10.4 launch webinar next week.
posted by
marcocantu @ 4:48AM | 18 Comments
[0 Pending]
18 Comments
Coming Delphi 10.4 Runtime Library Enhancements
Don't get me wrong, but these improvements should have been
present years ago, you as PM should be doing more work to promote
the product, it seems that Embarcadero does not have the manpower
to evolve the product, always running after competitors and
implementing and promoting things for "oldschool" developers.
IMHO, Embarcadero should rethink a lot of how to target their
market. Look at Microsoft, with .NET Core, the awesome work they
are doing, the all new awesome things coming each release, those are
wonderful to see, not the Embarcadero ones.
By the way, congratulations to the small RTL improvements.
Comment by Marco Cestari on May 22, 09:26
Coming Delphi 10.4 Runtime Library Enhancements
> Look at Microsoft...
and what? There is a slight different in company size and resources
(like 1 :10K), and still we have a component for embedding their
Edge Chromium in a Win32 app before they do. With all of their
money and developers, Microsoft still have a confused migration
strategy for any existing Windows desktop app.How do you write a
Windows client app with .NET Core? Using the coming Xamarin
Forms redesign? FireMonkey is ahead today...
We should try to do even more, I understand the request, but we are
doing a lot. And you cannot really compare us with the largest
corporation in the world....
Comment by Marco Cantu
[http://twitter.com/marcocantu]
on May 23, 05:26
Coming Delphi 10.4 Runtime Library Enhancements
Is delighted with the upcoming release of the 10.4, don't know
whether in 10.4 this problem be solved:
https://quality.embarcadero.com/browse/RSP-27949
Comment by Jack on May 23, 23:08
Coming Delphi 10.4 Runtime Library Enhancements
We do appreciate!
-A Delphi Developer
Comment by Anonymouse on May 24, 03:52
Coming Delphi 10.4 Runtime Library Enhancements
Hi Marco,
The bit counting routines are a good addition —
used a lot in chess programming. Are they
compiling to the BSF, BSR and POPCOUNT
assemble instructions, or some other algorithm?
Here's a good link to the latest bit counting
algorithms:
https://www.chessprogramming.org/Population_C
ount
Best regards,
Steve
Comment by Steve Maughan
[https://www.alignmix.com]
on May 24, 09:23
Coming Delphi 10.4 Runtime Library Enhancements
Can you explain technically why the parameter of FreeAndNil is of
the type const ref? The documentation indicates that ref can be used
to pass structs as references. And surely, nobody is expecting a
constant parameter to be modified. Why doesn't an var parameter
work?
Comment by Bastian on May 24, 13:43
Coming Delphi 10.4 Runtime Library Enhancements
Jack,
nope that was reported very late in the 10.3.3 cycle, we'll consider
it for the future
Bastian,
a const ref is a parameter passed by reference (not copied) but not to
be modified. Var is a modifiable by design.
Comment by Marco Cantu
[http://www.marcocantu.com]
on May 25, 02:09
Coming Delphi 10.4 Runtime Library Enhancements
Thank you for your reply. I think I discovered the answer to my
question myself: var parameters don't work because you can't use
descendant classes as parameters without casting to TObject. I still
don't understand why the ref decorator was added. Documentation
mentions [ref] only structs while FreeAndNil() is certainly for class
instances. And I don't understand you comment, because if I call
FreeAndNil() I want the reference to be modified to nil - therefore,
the (value of the) reference is not constant.
Comment by Bastian on May 25, 06:27
Coming Delphi 10.4 Runtime Library Enhancements
There are very nice features in this 10.4 release. Personally, I was
hoping for the implementation of a third IDE view (in addition to
CODE view and FORM-DESIGN view): DIAGRAM VIEW.
Comment by Peter Aschbacher on May 25, 08:26
Coming Delphi 10.4 Runtime Library Enhancements
Thank you for sharing.
I am really looking forward to these essential improvements.
Comment by Thomas Vedel
[]
on May 26, 04:53
Coming Delphi 10.4 Runtime Library Enhancements
In section where you are talking about Better Stream
Buffering you claim that the new default size of
BufferSize is 1MB but based on the shown code for
CopyFrom method declaration the default size is
100K bytes.
So someone must have made a typo.
Comment by SilverWarior on May 26, 06:37
Coming Delphi 10.4 Runtime Library Enhancements
copied from the source code:
function CopyFrom(const Source: TStream; Count: Int64 = 0; BufferSize: Integer = $100000): Int64;
I can hear the second patch coming :)
Comment by mvanrijnen on May 28, 00:34
Coming Delphi 10.4 Runtime Library Enhancements
mvanrijnen, it is an error in the doc, not in the code, so no hotfix for
this. The parameter is customizable, so you can change it as you see
fit. before it was hard-coded and difficult to modify.
Comment by Marco Cantu
[http://twitter.com/marcocantu]
on May 28, 07:43
Coming Delphi 10.4 Runtime Library Enhancements
i copied the code direct from the source code.
Comment by mvanrijnen on May 28, 12:24
Coming Delphi 10.4 Runtime Library Enhancements
No error! $100.000 is 1MB !
Comment by on May 29, 07:08
Coming Delphi 10.4 Runtime Library Enhancements
In some languages underscore '_' character used as decimal separator
for integer constants. for example $100_000 is more readable then
$100000.
Comment by Erez on June 3, 05:50
Coming Delphi 10.4 Runtime Library Enhancements
> Look at Microsoft ...
> There is a slight different in company size and
resources (like 1 :10K)
Well, not all of them are working on .Net or
Visual Studio.
> and still we have a component for embedding
their Edge Chromium in a Win32 app before they
do.
Really? I can‘t get my head around this. The
component is using the WebView2 control which
is written from Microsoft and its nature is:
„ The Microsoft Edge WebView2 control enables
you to host web content in your Windows app.“
How can you have a component before Microsoft,
when you are you using the control from
Microsoft?
> How do you write a
Windows client app with .NET Core?
Using WinForms and WPF (both can use .Net
Framework or .Net Core)
Comment by Sir Rufo on June 9, 00:43
Coming Delphi 10.4 Runtime Library Enhancements
"...And you cannot really compare us with the largest
corporation in the world...."
But products of Emb costs like in largest
corporation of the world...
Comment by Black Shark
[https://bshark.org]
on July 29, 07:18
Post Your Comment
Click
here for posting
your feedback to this blog.
There are currently 0 pending (unapproved) messages.