Static Typing Still Matters

I ran across a very interesting story yesterday.  Apparently genetic researchers are having some real trouble with their spreadsheets: important data is being wrongly interpreted by Excel as specific data formats and ends up getting mangled irreversibly, leading to data corruption.  For example, the gene identifier “2310009E13″ got converted to the floating point value “2.31E+13,” and the tumor suppressor DEC1 [Deleted in Esophageal Cancer 1] was being converted to ’1-DEC.’ Continue reading ‘Static Typing Still Matters’ »

Reaching A Human Being

As you may know, those of you out there who are active on StackOverflow and other StackExchange sites, they’ve got a site called Area51 that lets people propose new sites for the StackExchange network.  Proposals that get enough support get launched as beta sites, and successful betas “graduate” to full-fledged SE sites.

Since the purpose of StackExchange has been explicitly stated as not being about discussions, debates, or other “forum chat” stuff but about establishing definitive, authoritative answers to questions that can be answered definitively, I came up with a proposal yesterday that fits that mission perfectly, and would provide a sorely-needed resource in today’s world.  The basic focus of the site would be “How do I cut through useless automated support and reach an actual human being at company X?”  Anyone who’s ever grappled with this problem will know exactly what I’m talking about and why a site like this would be a useful resource. Continue reading ‘Reaching A Human Being’ »

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’ »

The internet: A ship lost at C

34 years ago, Tony Hoare gave a very interesting, and somewhat prophetic, Turing Award lecture.  In case anyone’s not familiar with him, he’s one of the great pioneers of computer science.  Among other things, he invented Quicksort, and the CASE statement. Continue reading ‘The internet: A ship lost at C’ »

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’ »

Beds and burgers

What do a bed and a burger have in common?  Not much, at first glance.  You eat a burger and sleep in a bed, and certainly not the other way around.  (You might eat a burger while in bed, if you’re a slob, though.)  But they seem like two completely different products, because they are.

So, let’s be a bit more specific.  What do a bed and a burger have in common economically?

Aha! Now we’re getting somewhere.  That’s obvious: they’re both near-ubiquitous consumer goods.  Produced on a different scale, certainly–you’ll probably go through hundreds or even thousands of burgers between buying one bed and buying your next one–but (in the US at least) you’re almost certainly going to buy both during your life.

Oh, and one other interesting point: they both have to be made to order, because they will go bad if you leave them sitting out for too long. Continue reading ‘Beds and burgers’ »

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’ »

Fixed my blog

So apparently I got hacked somehow. Not sure what happened, but someone found a way in to my WordPress installation and started using it to serve spammy ad links.  I’ve rooted out the problem and installed a WP security plugin that will watch for and work to prevent future attacks, so hopefully this won’t happen again.

As a minor note, anyone who’s left comments on here, someone might know your email address now.  Aside from that, this shouldn’t cause any problems for my readers.