The Wiert Corner – irregular stream of stuff

Jeroen W. Pluimers on .NET, C#, Delphi, databases, and personal interests

  • My badges

  • Twitter Updates

  • My Flickr Stream

  • Pages

  • All categories

  • Enter your email address to subscribe to this blog and receive notifications of new posts by email.

    Join 1,854 other subscribers

Archive for the ‘Delphi’ Category

Multi-parameter FreeAndNil plus InitialiseNil methods – interesting code ceremony reduction by David Heffernan

Posted by jpluimers on 2020/03/05

I’m probably getting a truckload of anti-FreeAndNil folks over me, but there are cases this comes in useful, so having an overloaded version cutting down code ceremony makes sense: [WayBack] interface – Avoiding nested try…finally blocks in Delphi – Stack Overflow

Which means I need to update my type safe FreeAndNil one day.

This should be relatively straightforward, given that David published a python generator for his Delphi code [WayBack].

–jeroen

Via: [WayBack] Interesting approach by David Heffernan (*1) to the nested try..finally blocks because of multiple object creations: Overloaded InitializeNil and FreeA… – Thomas Mueller (dummzeuch) – Google+

Read the rest of this entry »

Posted in Delphi, Development, Software Development | Leave a Comment »

Use SetString if your source memory reagion with characters is not null-terminated…

Posted by jpluimers on 2020/03/03

Too many people forget this (including myself) every now and then) so here is a reminder to use the [WayBackSetString method when assigning strings from memory regions having characters but no null terminator:

Anyway, assuming that you use a Unicode Delphi you want to use SetString in its place:

SetString(password, PWideChar(Credential.CredentialBlob), Credential.CredentialBlobSize div 2);

It was by David Heffernan commenting on [WayBack] I have this code sample on StackOverflow using a function WideCharToWideString… I can’t seem to find anything on this function… – Nils Guillermin – Google+.

Note that like the above Delphi 2009 link (where it is a WideChar function to Unicode string conversion function), it was also available in Delphi 2007 and earlier as [WayBack] SetString.

–jeroen

 

Posted in Delphi, Development, Software Development | Leave a Comment »

What is the easiest way of getting Delphi to accept a newly added file as a frame and to treat it as such? – Stack Overflow

Posted by jpluimers on 2020/02/26

As this is still an issue with current Delphi versions: every now and then it looses which designers are needed for a frame:

[WayBack] What is the easiest way of getting Delphi to accept a newly added file as a frame and to treat it as such? – Stack Overflow (by Brian Frost)

<DCCReference Include="x\y\z\myFrame.pas">
  <Form>frameMy</Form> 
  <FormType>dfm</FormType>
  <DesignClass>TFrame</DesignClass>
</DCCReference>

Then check your .dfm file to see if it starts with the correct inherited or object as per Delphi – TInterfacedDataModule revisted – use ‘inherited’ in your .dfm files when your datamodules look like forms in the designer.

Oh and at design time, be very careful embedding frames. Better not to do it at all and for certain: do not embed frames in a nested way: [WayBack] Frames in 10.2.2 Hi Has anyone else had issues with frames under 10.2.2? The project seems to have lost its links to the frames? If I went to the Too… – Vince Bartlett – Google+

–jeroen

Posted in Delphi, Development, Software Development | 1 Comment »

Not all XSD mappings to programming language constructs are possible

Posted by jpluimers on 2020/02/26

This post is a reminder to myself that not all mappings from XSD to programming languages are possible.

There are many impossible cases, so this is just a general reminder.

A Delphi specific case for instance is the mapping of enumerations: one reason is that XSD enumerations are case sensitive, but the Delphi language is not: [WayBackUsing XML Enumerations with Delphi XML Data Binding Wizard – Stack Overflow.

More generic examples from my answer to the above question:

  • In XSD you can derive from an existing type in two ways: extending it and limiting it. Object Oriented languages only allow you extend when deriving.
  • Delphi is not alone in these kinds of limitations. Generating wrappers from XSD schema’s is the field of specialized tools, even in the Java or .NET world.

I’ve seen horrible things with wildcards that are sort of mappable to Java, but not to C#. This could likely go on for much longer…

–jeroen

Posted in C#, Delphi, Development, Java, Java Platform, Software Development, XML, XML/XSD, XSD | 2 Comments »

Delphi Conference 2018 – Barnsten.com

Posted by jpluimers on 2020/02/25

I missed this one, so I was glad I archived it because I was curious for Daan van der Werf – Delphi op de werkvloer “Groothandel & Magazijn”.

So here it is: [WayBack] Delphi Conference 2018 – Barnsten.com, with fixed and archived links where possible.

Presentations and code from the Delphi Conference 2018

–jeroen

Posted in Conferences, Delphi, Development, Event, Software Development | 2 Comments »

TInterlockedHelper for Delphi interfaces: Spring.Reactive.pas

Posted by jpluimers on 2020/02/25

Reminder so self: [WayBacksglienke / Spring4D / source / Source / Reactive / Spring.Reactive.pas — Bitbucket fragments:

type
  TInterlocked = SyncObjs.TInterlocked;
  TInterlockedHelper = class helper for TInterlocked // TODO: move to Spring.pas
    class function CompareExchange<T: IInterface>(var Target: T; const Value, Comparand: T): T; overload; static;
    class function Exchange<T: IInterface>(var Target: T; const Value: T): T; overload; static;
  end;

{$REGION 'TInterlockedHelper'}

class function TInterlockedHelper.CompareExchange<T>(var Target: T;
  const Value, Comparand: T): T;
begin
  Result := Default(T);
  PPointer(@Result)^ := CompareExchange(PPointer(@Target)^, PPointer(@Value)^, PPointer(@Comparand)^);
  if PPointer(@Result)^ = PPointer(@Comparand)^ then
  begin
    if Assigned(Value) then
      Value._AddRef;
  end
  else
    if Assigned(Result) then
      Result._AddRef;
end;

class function TInterlockedHelper.Exchange<T>(var Target: T;
  const Value: T): T;
begin
  Result := Default(T);
  PPointer(@Result)^ := Exchange(PPointer(@Target)^, PPointer(@Value)^);
  if Assigned(Value) then
    Value._AddRef;
end;

{$ENDREGION}a

–jeroen

Posted in Delphi, Development, Software Development | Leave a Comment »

Delphi memory allocators and configuration notes in multi-threaded environments with high allocation/deallocation rates

Posted by jpluimers on 2020/02/20

From an interesting discussion at [Archive.is/WayBack] FaceBook: Delphi developer thread by Jarto Tarpio with some measurements by Jarto Tarpio and André Mussche.

  • Manipulation of strings and lists in Delphi have high memory allocation/deallocation rates, so HTTP related services with high call rates are affected more than regular services
  •  FastMM:
    • conditional defines that can help are NeverSleepOnThreadContention, UseSwitchToThread, and UseReleaseStack then measure.
    • has one huge advantage: It’s very, very good at keeping memory fragmentation at bay
    • default settings are for applications that use lots of CPU, but have no really high memory allocation/deallocation rates
    • has very good debugging facilities
    • Under FullDebugMode address space is never released back to the operating system so once the address space has been exhausted there is very little room to manoeuvre.
  • TCMalloc:
    • is very good at multi-threaded memory management with high allocation/deallocation rates
    • needs to be persuaded to releases memory to the OS:
      it only releases to the system under two occasions: Freeing another part of the memory, or asking it to release all parts marked as freed.

    • has no debugging facilities

The differences make it a challenge to integrate in your development and deployment process: because of the debugging facilities, you’d like FastMM in all your environments, but TCMalloc in multi-threaded environments with high allocation/deallocation rates.

One possibility is to have your CI environment deliver both in all stages, run all tests on both, then choose the final one depending on your run-time configuration.

That gives a burden on configuring your Continuous Integration, but the gain might outweigh this cost.

Relevant links from the Facebook thread:

–jeroen

Posted in Delphi, Development, FastMM, Software Development | 5 Comments »

Does anyone knows a existing implementation of bcrypt or scrypt for delphi?

Posted by jpluimers on 2020/02/19

For my link archive: [WayBack] Does anyone knows a existing implementation of bcrypt or scrypt for delphi? – Fabian S. Biehn – Google+:

–jeroen

Posted in Delphi, Development, Encryption, Power User, Security, Software Development | Leave a Comment »

Some interesting Delphi MVVM posts…

Posted by jpluimers on 2020/02/18

Via [WayBack] We kick off a week of MVVM with an introduction of the Model-View-ViewModel pattern and how data binding is used to realize it. – Erik van Bilsen – Google+:

I wrote (and gave a few conference talks) about DSharp before, so the above is very interesting.

–jeroen

References:

Posted in Delphi, Development, Software Development | 2 Comments »

Happy Delphi 25th anniversary: follow hash tags #Delphi25 and #Delphi25th

Posted by jpluimers on 2020/02/14

I wish I could have prepared something more substantial for the 25th Delphi birthday.

Alas: life has been tough (see below), so please keep an eye on these search terms, hash tags and start posts from past Delphi team key members:

Search term: “Interview with Anders Hejlsberg and Chuck Jazdzewski #Delphi25th”; highlights from it:

  • “The men in this video are responsible for an incalculable amount of software, in one way or another. It boggles the mind to think about their impact on our industry.
    I know, right? If you aren’t using software they were directly involved in, then you are using software inspired by their software.”
  • Delphi 1 being postponed 6 months to ensure the visual designer and live data worked properly; the side effect was top notch quality of other product areas
  • Shipping the RTL and VCL code was very important
  • “If it was done right, we wouldn’t have a job” – had me truly LOL! It is so true! The Windows API was powerful, but hard to use – slightly better today, but still Delphi run circles around any other UI for Win32 tool – VB included.
  • Method Pointers changed the perspective of a lot of software development, even outside the Delphi world
  • Peter Sollich working on the compiler (Wish Peter Sollich was mentioned more; he was instrumental to the compiler.)
  • Garbage Collection is beautiful, but adds a truckload of complexity interfacing to the non-garbage collected underlying Windows API
  • The power of the VCL component model working irrespective of the state (having a Windows Class, Window Handle, etc) of the underlying Windows controls
  • The automatic recreation of underlying controls when certain component properties change is still important today on the supported platforms, for instance when switching from landscape to portrait mode
  • Reference counting (which was already with large strings) only gets you so far, as it can leave isolated islands that never get collected; mark and sweep was hardly used in any other environment
  • The beta/field-test/code names (like Delphi, Wasabi, Mango) depended on the group of people they were sent to
  • “Very important was that the Delphi 2.0 compiler and VCL was long underway before Delphi 1 was released. That made the transition from Win16 to Win32 so much easier.
    Yes, and really interesting in terms of strategic planning”
  • “I think Monet was ObjectVision 1.0 I think -and ObjectVision 3.0 was bundle with TurboC as I remenber it – I was PM on that in Scandinavia. :)”
  • Chuck is now working at Google on a new framework for Android Development called “Compose”.
  • Anders worked for a short while on Visual J++, then on C# and .NET, then adding TypeScript, and helped Microsoft move from inward oriented company to opening up to open source. He now spends his time committing code to github (github.com/ahejlsberg) because he wanted to go back to coding instead of managing.
  • “If playback doesn’t begin shortly, try restarting your device.” It stopped playing as soon as you switched to YouTube.
    Sorry. Must be a network issue. We will send out a replay link.”
  • “The first time I used Pascal, it was Compas Pascal – also written by Anders Heijlsberg. Now he is behind C# and TypeScript – he surely is leaving a major mark on the runestones of software development!”
  • DogFood is important; Turbo Pascal and Delphi were among the first; C# and TypeScript now do this too.
  • “Will the anniversary page Delphi.embarcadero.com be available in future also ?
    Yes, that is the plan. We made it Delphi.embarcadero.com instead of Delphi25. so we can keep it around. Plus we have more content comming on there.”
  • The Delphi compiler version actually started at 1.0 for Turbo Pascal 1.0
  • “Official MS Windows Me image for Virtual Box can be found at https://archive.org/details/win_me_archive_vdi
  • DavidI: Special respect to my “Twin separated at birth” Charlie Calvert for training the world on Delphi !!!
  • [WayBack] (PDF) Borland Software Craftsmanship: A New Look at Process, Quality and Productivity
    A:This is a great paper. By coincidence I actually saw it less than two days ago!
  • “Don’t forget Cary Jensen, I have met him at the first Delphi courses in Amsterdam ~24 years ago. I hope he is well!”
  • “Don’t forget InterBase has been there all the time along the way too! And still going strong, and across all the same target platforms!”
  • “How about a line profiler built-in, rather than having to purchase and install AQTime?”
  • “This site has VirtualBox virtual machine images for all legacy versions of Windows, including “Window 3.1” … http://virtualdiskimages.weebly.com/virtualbox.html
  • “I agree with the very useful feature of being able to make Windows versions of the mobile apps. This is one, that is being used exactly for that… multipurpose. https://play.google.com/store/apps/details?id=com.danvaegt.SmartWeighClient

A few of my recent tweets:

 

Delphi 25th pages

Read the rest of this entry »

Posted in Delphi, Development, Software Development | Leave a Comment »