Archive for the ‘Delphi’ Category.

Memory management: still a non-issue

I got assigned an interesting bug to fix today at work:  Performing a certain operation in our program caused an enormous memory leak, producing a FastMM report file that weighed in at over 150 MB, representing a serious amount of RAM in our program.  A bit of debugging made it obvious that a certain interfaced object was at the root of the problem, and it had a refcount of 1 when the program ended.  I found the object that was holding a reference to it and went looking for what was holding it up… and it turned out to have a refcount of over 4700 when the program ended! Continue reading ‘Memory management: still a non-issue’ »

DWS Externals progress

I’ve been working on the stub-building JIT for external routines in DWS lately, and I just checked in a bunch of updates.  The JIT will currently handle parameters of most basic types, and return values of integer, enumerated, or object types.  (Still working on the rest.)  So it’s not complete yet, but it’s getting there. Continue reading ‘DWS Externals progress’ »

Expression Trees: abusing operator overloading for fun and profit

Quick, what should this routine produce?

procedure Test;
var
   expr: TExpression;
   result: string;
begin
   expr := 'Value';
   expr := expr = 5;
   result := expr;
   writeln(result);
end;

There are three basic answers here:

  1. Wait, you’re assigning a string to it, and then a boolean comparison against an integer… does that even compile?
  2. Well, first you’re assigning a string, then a boolean comparison against an integer, then turning it into a string… well, TExpression must be some sort of thing like a Variant.  So the output should be “False”.
  3. If TExpression is a record, the output could be just about anything.

If you answered 3), you’re probably Stefan Glienke, or someone like him who already knows the trick.  When I do this, the output is “(Value = 5)”.  If you want to know how that’s possible in ordinary Delphi code, read on. Continue reading ‘Expression Trees: abusing operator overloading for fun and profit’ »

External routines in DWS

I’ve been working with Eric Grange on adding a new feature to the DWS compiler recently: external routines.  The goal of this feature is to allow DWS code to call into native routines like Delphi code can call into routines in a DLL by writing a function signature and marking it external, without having to use a TdwsUnit component and create a bunch of heavy-overhead binding code. Continue reading ‘External routines in DWS’ »

The case of the one-thread race condition

You know what’s even worse than a race condition between two threads in your code?

A race condition in one thread in your code, because there are good solutions and debugging techniques for tracking down multi-threading conflicts, but they don’t work when there’s only one thread involved.

That’s right.  I just spent the last few hours tracking down what turned out to be a reentrancy problem. Continue reading ‘The case of the one-thread race condition’ »

New Year, new job, new town, same me

A lot’s happened in my life over the last few weeks, but most of it revolves around one basic fact: I quit my job at WideOrbit to take a new one with De Novo Software.  The project I’m working on now is a program for flow cytometry, a type of analysis of medical sample data used in diagnoses and research.  (In Delphi, of course.)  It looks like it’s going to be a lot of fun to work on. Continue reading ‘New Year, new job, new town, same me’ »

Always Review Your Code

I got a request at work yesterday to look at an issue one of our clients was having.  A certain service didn’t seem to be doing anything at all, with no failure messages in the server logs.  After asking a few questions and checking out the log, I determined that the initialization code for that service had never run when the server started up, so I pulled up a local copy on my dev system to figure out why. Continue reading ‘Always Review Your Code’ »

First look at Oxygene for Android development

Jolyon Smith has been posting a lot of really rosy stuff about Oxygene lately.  And he even commented on a recent blog post of mine,  in response to my frustration about Embarcadero blatantly ripping off paying customers by not including Android support as part of the baseline Delphi installation:

[Oxygene is] a better Pascal even than Delphi these days and fully supports Android (and iOS) development using the platform native frameworks, so you get to learn “proper” Android development (portable skills) without having to swallow the Java pill.

Thing is, I’ve been doing some serious looking at Oxygene too lately.  I haven’t reached all of the same conclusions he has, though.  But then again, I’ve been trying to do different stuff. Continue reading ‘First look at Oxygene for Android development’ »

Delphi and Productivity

If you haven’t seen Gabr’s latest post about Delphi language features, it’s worth looking at. I don’t agree with everything he posted, but he’s got some good points.

But he’s also got some annoying problems in the comments department.  Some obnoxious troll is spamming up almost half of the (extremely large) set of comments under the post with a bunch of preaching about how Python is soooo much better than Delphi because it’s less verbose.  His thesis seems to be that since you can write equivalent functionality with (as he claims) one-tenth the lines of code, that Python is ten times more productive than Delphi. Continue reading ‘Delphi and Productivity’ »

Delphi XE5: Promised Android support not included!

This isn’t the post I was planning on writing. I was really looking forward to this latest release.  I really wanted to like it.  I really wanted to use it, and I really wanted to be able to talk on here about how awesome it is.  Afterall, this release was going to finally bring Android support to Delphi, which has been something it’s needed for several years now.

Unfortunately… it doesn’t.  I just got my SA download and installed it, and there’s no Android support anywhere to be found.  Apparently that’s not part of Delphi; it’s an “add-on pack” that costs 140% of what I already paid for SA this year!  All that’s in Delphi XE5 itself is the Desktop development stuff I already have, which has scarcely changed at all since XE2.  With pricing that high, you’d almost think someone in Embarcadero marketing is deliberately trying to drive users to Oxygene! Continue reading ‘Delphi XE5: Promised Android support not included!’ »