Erik@Grijjy
-
Content Count
36 -
Joined
-
Last visited
-
Days Won
10
Posts posted by Erik@Grijjy
-
-
We present an implementation of multicast events that is as lightweight as regular Delphi events in common scenario's. Also - for those interested - we show a couple of not-so-common Delphi language features that are used in the implementation.
https://blog.grijjy.com/2023/04/27/lightweight-multicast-events/- 2
- 4
-
13 hours ago, Edwin Yip said:FYI, XE4 can compile the tests, after removing the inline var statements.
Great! Thanks for testing!
-
9 hours ago, Rollo62 said:Very interesting article, I love
C++DelphiEspecially the use case samples are great, where I think this could make it possible to be used in a nested way, what I consider for some time.
Something like that:
Thanks!
Yes, the nested case is definitely possible. Your THtmlStringBuilder class would probably have to maintain some sort of state stack so you can match your Enter and Leave calls. This will also ensure you output proper (X)HTML.BTW: This pattern isn't a trick and doesn't depend on any compiler quirks. It is just a feature of generics in Delphi (and possibly other OOP languages). I remember using this pattern first with Delphi at least 5 years ago, and I don't see any reason why future compilers would change this behavior. It may not be supported by the very first (few) versions of Delphi that introduced generics, but I have no way to test that.
-
-
Need an exception logging solution for macOS? In this post we add Intel macOS support to our error reporting building blocks.
https://blog.grijjy.com/2021/10/18/build-your-own-error-reporter-part-3-macos-intel/
- 5
-
1 minute ago, Anders Melander said:Some benchmarks comparing the performance of the DD and QD types to the native Single and Double types would be appreciated, if you have them.
I've searched for performance numbers on the QD C++ library but couldn't find any relevant ones. The pdf contains some numbers but they are very old (Pentium II) and quite meaningless since the only comparison made is to the MPFUN Fortran library.
Also the QD page you link to state that the C++ library isn't thread safe. Is the same true for your implementation?
I have attached a spreadsheet I created a couple of years ago, comparing DD and QD to Single and Double, as well as to some well-known arbitrary precision libraries.
Results may be a bit different now if I would run these tests again, but I think will still be in the same ballpark.
In short, DD is 2-10 times slower than Double, but 5-100 times faster than other arbitrary precision libraries using the same precision.
Likewise, QD is 4-100 times slower than Double, but 5-250 times faster than other libraries.
You can also do some simple benchmarking by running the included Mandelbrot sample at different levels of precision (for a magnification level that works at Double precision).
Since this library directly uses the QD C++ library, it has the same limitations (such as thread safety). Although I would assume that most operations would be thread safe since as long as you don't mutate the same DD/QD value from multiple threads. But I haven't checked the C++ source code for this, so I am not sure.
- 3
- 2
-
Need more precision than Single and Double can provide? Then maybe this will help:
- 7
- 4
-
Growing impatient while building your FireMonkey app for macOS, iOS or Android?
This post shows a way to (significantly) decrease the amount of time it takes for your app to build on these platforms.
- 5
- 1
-
We have open sourced our Deployment Manager to simplify deployment of a large number of files or folders to iOS or Android.
- 5
- 2
-
Get the most out of your GPU by writing custom shaders for FireMonkey!
- 3
- 2
-
7 hours ago, balabuev said:The price is - you cannot have DOMs, smaller than the OS memory page (4KB).
True, but for such small DOMs, memory isn't the issue anyway, so the overhead is negligible. Although you still get the advantage of reduced memory fragmentation though...
-
Delphi 10.4 (finally) switched to a new version of the Android NDK. The GNU-STL had been deprecated for a long time, and Delphi finally switched to libc++.
Thanks for pointing this out. I will make the change in the official repo.
- 1
-
1 minute ago, Attila Kovacs said:Can't compile the code because of the inline variables 😕
Then maybe now is a good time to upgrade to the latest Delphi version😉
- 1
- 2
-
6 minutes ago, David Heffernan said:Would be nice to localise the disabling of overflow checks to just the hashing routines.
Your wish is my command. Guess I was a bit lazy earlier...
Pushed an updated for this.
- 3
- 2
-
8 minutes ago, Kryvich said:Converting one of my program from SimpleXML to Neslib.Xml was not difficult, but I ran into an exception EIntOverflow in the procedure TXmlPointerMap.Map.
Glad you like it, and thanks for pointing out this issue. It only happens when you compile with Overflow Checking turned on. The hash functions I use should be compiled with overflow checking turned off, so I just added an {$OVERFLOWCHECKS OFF} directive to the Neslib.Xml.Types unit. Could you pull the latest version and try again?
- 1
-
43 minutes ago, Kas Ob. said:Great article and neat library, thank you !
Now, i wonder if a memory manager is next on your workshop desk ?
I genuinely think it is a matter of when, not if.Happy to hear! Don't know about creating a memory manager though. Very advanced stuff. And there are already some pretty good 3rd party memory managers out there.
Although it would be nice to have a high performance memory manager for mobile platforms as well. Maybe something like Microsoft's Mimalloc.
-
49 minutes ago, Rollo62 said:Great stuff, thanks for that.
What is your next project, are you going to implement similar structure to the JSON parser ?
Glad you like it! Could be interesting to see if this can by applied to JSON as well. Wouldn't want to break the existing API though...
-
Check out some of the interesting algorithms and data structures used to create an extremely light-weight XML DOM.
https://blog.grijjy.com/2020/10/07/an-xml-dom-with-just-8-bytes-per-node/
- 4
- 6
-
Another post about Custom Managed Records. This time, this new language feature is used to create smart pointers.
https://blog.grijjy.com/2020/08/12/custom-managed-records-for-smart-pointers/
- 5
-
@Stefan Glienke I agree that the implementation is lacking and would like to see a more C++ like implementation. And it would be great if you could overload the "." or "^" operator.
That being said, the current implementation still has its uses...
-
I guess it is also a matter of taste.
It took a while for me to get used to the "aesthetic" of inline variables, but now I love them (especially with type inference) and can't imagine why I had an aversion against them.
I have seen this type of CMR in C++ code so much, that I got used to it and started to miss it in Delphi (until now). Now, I actually think it improves readability and safety, although I can imagine people feel the opposite. (For some reason, I tend to write "Mutex.Free" in finally parts instead of "Mutex.Release" to leave a lock, because of the muscle memory of freeing stuff inside of finally blocks. With CMRs, this kind of mistake is not possible😉).
An yes, coding conventions can help improve readability. The name Create for a constructor has an association with classes for many people. Calling it something else (like Instantiate) could help, as would turning it into a static class function instead of a constructor.
As with many things, there are often many solutions to a problem. A CMR is just an additional tool in your toolbox...
-
Check out how you can use Custom Managed Records to reduce the number of try..finally blocks you write.
https://blog.grijjy.com/2020/08/03/automate-restorable-operations-with-custom-managed-records/
- 5
- 1
-
1 hour ago, Lars Fosdal said:Neat!
Did it survive patch 2?
Yes it did!
- 1
-
Check out how you can use Delphi's new Custom Managed Records feature to wrap C(++) APIs.
https://blog.grijjy.com/2020/07/20/wrapping-c-apis-with-custom-managed-records/
- 3
Lightweight Multicast Events
in Tips / Blogs / Tutorials / Videos
Posted
As Anders mentioned above, there are other solutions out there that work with older Delphi versions.
My focus was on keeping it extremely light weight so it doesn't have more overhead than regular events in common cases. And Custom Managed Records are one of the things that make that possible. But you could remove the CMR functionality, but then the users are responsible for cleaning up the multicast events. But that may be only a small price to pay.