Archive for the ‘Development’ Category
Posted by jpluimers on 2021/02/11
[WayBack] One second code: Do YOU know how much your computer can do in a second? is a quiz version of the [WayBack] Numbers Every Programmer Should Know By Year.
[WayBack] About this game revealed it was made by 3 people curious in the speed of their hardware which – not surprisingly – has been relatively stable over the last decade or so.
Source code is at [WayBack] GitHub – kamalmarhubi/one-second: Fun performance game!
I bumped into it via these tweets:
I like games like this (ever played the The Deadlock Empire multi-threading game?), so I played the computers-are-fast.github.io tests, and learned a lot:
Read the rest of this entry »
Posted in Conference Topics, Conferences, Development, Event, Hardware, Power User, Software Development | Leave a Comment »
Posted by jpluimers on 2021/02/11
I tried searching for F2084 Internal Error: MA1263 – Google Search which happened on a complete up to date Delphi 10.1 Berlin installation.
It came from a large unit testing application using truckloads of generic language constructs, and large unit uses cycles.
Could not find anything useful. The error disappeared after recompiling the same application:

–jeroen
Posted in Delphi, Delphi 10.1 Berlin (BigBen), Development, Software Development | Leave a Comment »
Posted by jpluimers on 2021/02/10
Document locations changed, so here are some links to newer and older documentation on LCID related things:
- Delphi: a few short notes on LoadString and loading shell resource strings for specific LCIDs, for which I need to check which ones have suffered from link rot.
- [WayBack] MAKELCID macro | Microsoft Docs:
Creates a locale identifier from a language identifier and a sort order identifier.
- Setting and restoring the default user language:
- API calls:
- Saving/restoring data between locales:
- [WayBack] Using Persistent Locale Data – Windows applications | Microsoft Docs
Using Persistent Locale Data
A globalized application often persists or transmits data, for example, time and date. When deciding how your application should handle data persistence, remember that data is not guaranteed to be the same from computer to computer or between runs of the application. This is true for both locales that ship with Windows and custom locales.
Design of the application must take into account a variety of locale-related data changes that can occur. For example:
- Currency symbols can change as countries adopt the Euro.
- Regional preferences can change. For example, the format d/m/y might change to the format m/d/y for a particular locale.
- The spelling of day names can change due to spelling reforms. Additionally, casing can change for month or day names.
An application that persists data should use locale-independent formats for storage and data interchange. Examples are hard-coded or standard formats; the invariant locale LOCALE_NAME_INVARIANT; and binary storage formats.
If persistent sorting data is required, the application must use the CompareStringOrdinal function. Remember that an invariant format does not remain invariant for sorting, only for locale and calendar data.
Use the User Default Locale for Data Presentation
To present persistent data, it is best for the application to reformat the data using the user default locale. Use of this locale allows user overrides. For more information, see LOCALE_USER_DEFAULT.
More Delphi related links:
–jeroen
Posted in Development, Internet, link rot, Power User, Software Development, Windows Development, WWW - the World Wide Web of information | Leave a Comment »
Posted by jpluimers on 2021/02/10
A long time ago, I write a question [WayBack] delphi – Should the compiler hint/warn when passing object instances directly as const interface parameters? – Stack Overflow in 2010.
It was marked by (now former) compiler engineer Barry Kelly [WayBack1/WayBack2] as bug:
It’s a bug. The conversion from instance to interface reference in RunLeakCrash should be to a temporary variable, keeping it alive for the duration of RunLeakCrash.
Added to that was a comment that this has happened since at least Delphi 6, so I filed a bug WayBack QualityCentral Report #: 90482 The compiler should keep a hidden reference when passing freshly created object instances directly as const interface parameters.
Just for years later, it was marked with “As Designed” which means it is never going to be fixed, especially since in the mean time Embarcadero got rid of most the senior Delphi R&D team members and went down the path of hiring contractors.
The problem is that I run into the two manifestations every now and then, and it usually takes a long time debugging to zoom into the actual location of the spots.
First manifestation: crash
This is the bug in the first manifestation (by now the root interface is IInterface instead of IUnknown, and you usually have an interface derived from it):
Read the rest of this entry »
Posted in Conference Topics, Conferences, Delphi, Development, Event, Software Development, Undocumented Delphi | Leave a Comment »
Posted by jpluimers on 2021/02/09
For my archive: the [WayBack] How do I pretty-print JSON in Delphi? – Stack Overflow answer by [WayBack] Bob:
If you do not want to use any external library, and you’re using a Delphi XE5 or newer, there is a very handy TJson.Format() function in the REST.Json unit.
uses json, REST.Json;
{ ... }
function FormatJSON(json: String): String;
var
tmpJson: TJsonObject;
begin
tmpJson := TJSONObject.ParseJSONValue(json);
Result := TJson.Format(tmpJson);
FreeAndNil(tmpJson);
end;
–jeroen
Posted in Delphi, Development, JavaScript/ECMAScript, JSON, Scripting, Software Development | 2 Comments »
Posted by jpluimers on 2021/02/04
Every now and then it is good to read back this [WayBack] thread by @Nick_Craver: “
I’ve talked with so, so many new devs over the years and far too many are afraid to try because they’re afraid to fafavor, share your failures.
So do me a favor, share your failures. Not just the successes. It’s not just about learning from them. Sometimes it’s just about people knowing they happen.
Reminder: you see the successes people are proud of and want to shout from the rooftops for all to see. Far, far fewer people share all the failures leading up to those successes. Yet those missteps are almost always far more numerous.
Hi, I’m a dev. I’ve caused more production outages that I can count. I’ve deleted a production database by accident. I’ve missed hundreds of bugs in code reviews. I try my best. I try to not repeat mistakes. It still happens sometimes. I still think my impact has been a net good.
[…]”
The thing about mistakes is that they do happen, and we need to learn from them. Almost always, it is useless to blame, but do your best to prevent them from happening again by doing blameless post-mortem.
We do however need to become better engineers, so this thread is relevant as well, because the impact of some is not been a net good:
[Cached] WayBack: thread by @www_ora_tion_ca: “This is wildly disingenuous, I speak as a flight instructor and major IT incident investigator. Modern software authors have the professional discipline of a cute puppy in comparison to aviation practitioners. […]”. quoting [WayBack] Alex Stamos on Twitter: “I agree with Chris. This is the kind of thinking that leads to “Why can’t we just have building codes for software? It worked to protect against earthquakes and fire!” Earthquakes and fire aren’t conscious adversaries. Try writing a standards document on how to win at chess.”
My biggest faults:
Read the rest of this entry »
Posted in Agile, Code Quality, Development, Software Development | Leave a Comment »
Posted by jpluimers on 2021/02/04
From a while back: [WayBack] delphi – Faster DirectoryExists function? – Stack Overflow:
Q
I use
DirectoryExists (const PathName : String);
to check if a directory is reachable from a computer or not. But if the directory does not exist and the path name is a network path, i.e.
\\computer1\Data
the method takes a very long time to return.
There must be a faster way to determine that a network folder is not reachable. Or can I configure some timeout parameter that DirectoryExists uses internally (I looked at the source code but it just delegates to GetFileAttributes which is defined in kernel32)?
Any ideas?
A
There is no faster way:
any function accessing anything on a remote share will timeout when that share is not available.
If the cause of your timeouts is automatic disconnecting of shares, then these link may help you:
If the application can continue without the completion of the check, then you can put the check in a separate thread, and upon completion of the check, you can update your status in the UI.
Be aware that when you try a multi-threading way, that you have to disprove your code is free of race-conditions and memory leaks. Time-outs in combination with exceptions usually make that a hard task.
Related:
–jeroen
Posted in Delphi, Development, Software Development | Leave a Comment »