Home | Shorter Path | About Me
Home
About Me
RSS Feed

Planners (you know you want it)

Archive

2004

01

02

03

04

05

06

07

08

09

10

11

12

 

2005

01

02

03

04

05

06

07

08

09

10

11

12

 

2006

01

02

03

04

05

06

07

08

09

10

11

12


Blogroll
 
Borland
Allen Bauer
Anders Ohlsson
Chris Bensen
Malcolm Groves
Michael Swindell
Steve Trefethen
Borland Blogs
TeamB
TeamB Blog Server
Nick Hodges
Other
Algorithms for the Masses
Brad Abrams
Chris Brumme
Chris Pratley
Dan Miser
Don Box
Falafel Flogs
iunknown.com
Joel on Software
Matt Pietrek
Suzanne Cook
The Daily WTF
The New Old Thing
Wintellog

Archive for 09/2004

Random act of kindness, part 4: The Return
Wednesday, September 29, 2004 04:28 PM

Previously on Random acts of kindness: search engines exhibit cruel and unusual behavior by pointing misguided souls to this page.

First, let me just say that Cute Names Disorder is far more serious a problem than I could ever imagine. In addition to the usual searches, I now seem to get requests for "cute partner names", "cute names to call each other", and even "cute names for couples to call each other." CND even spreads into the electronic world, with a request for "cute computer names." I'm not sure how to respond to that, but "seek professional help" comes to mind.

Moving on:

"Borland Diamondback picture"

Well, I can do better than that: moving pictures. It's the next big thing, you know. Here are two BDNtv episodes showing Diamondback:

"John Kaster's picture"

Fine, as long as you don't use it to scare little children. Full size image (don't know why you'd need one, but at this point I'm not about to ask) can be found here.

By the way, John and his lovely wife and daughter had most of TeamB in their house last week, after BorCon. Unfortunately for me, I couldn't stay because I'm allergic to cats. The reason I'm boring you with this pointless little story is the following search phrase:

"Random cats of kindness"

Looking back, I guess I had it coming. While I can't really provide any useful information about this (as if that ever stopped me), I would like to point out that this could be a good name for a rock band.

"Allen's gummy bears"

That's right. Apparently, after looking for his gummy bears in the usual places (pockets, the kitchen, under the sofa), Allen decided to expand the search to the virtual realm. Google, who probably ate all of them, cleverly covered its tracks by returning my page in its search results (the electronic equivalent of the cunning "Hey! Look behind you" defense).

"Pronounce Yggdrasil"

I just did. Now you jump on one leg and make funny noises.

"Malcolm X window AK-47"

OK, looks like it's time to stop before someone gets hurt.

|

More BorCon
Tuesday, September 14, 2004 12:59 PM

More cool stuff here at BorCon. If you're not here, you're missing out, and should try to make it next year.

So far today, I've attended the ".NET Remoting with Delphi 8 and C#" session by Lino Tadros, and Corbin Dunn's "CodeDOM Delphi". Even though I was already familiar with most of the things in Lino's talk, he did give a couple of tips I found extremely valuable.

Corbin's talk was pretty interesting, too. Corbin is responsible for the CodeDOM in the Delphi IDE. He's also responsible - or to blame, if you like - for a lot of cool IDE features, such as the new tool palette and the refactoring tools in Diamondback. There really wasn't enough time to get into all of the details, but the entire paper and code for the session are available electronically (at the moment, only to BorCon attendees, but hopefully it will be made public soon).

And it's only lunchtime - still lots of interesting sessions ahead. If you still don't know what you're missing, I'll do my best to make you feel bad about it.

|

End of day one
Monday, September 13, 2004 10:31 PM

No more live blogging for me - I'm way too tired. Also, the two sessions that actually justified it for me (Allen's and Danny's) are over, and I wrote pretty much all I could about them. If you want the latest update on the Diamondback preview/meet the Delphi team session, read Nick's or Robert's blog entries.

Nick, by the way, won the 2004 "Spirit of Delphi" Award. It's a lot heavier than it sounds. Even better, it has sharp pointy edges. You could do some serious damage with that thing.

One thing about the Diamondback preview: Borland is being very open about it. This is a new, very encouraging approach. They went as far as giving everyone here a CD with the preview version. I think it's a great idea.

|

Danny's talk
Monday, September 13, 2004 03:31 PM

I'm live-blogging from Danny Thorpe's "What's new in the Delphi compiler" session. John Kaster had 4 hours to run through almost 200 slides. Danny has 4 slides in 1 hour - and, as he says, it's going to be tight. Oh, and live bloggers have been specifically asked to correctly spell anything we copy from the slides.

Let's move on to the technical stuff:

For..in loops

This is basically an enumeration, similar to the for each C# construct. It's no longer necessary to define an index in order to enumerate items. The enumerator class can do additional things, such as pre-fetch records to improve performance.

The elements you get back from enumeration are read-only. Write-back elements are not supported by the .NET Framework, although it might be possible (in a future version) for Win32. The compiler can take advantage of special circumstances to optimize the loop (for example, when looping over arrays).

In .NET, enumeration is based on the IEnumerable interface. In Win32, the compiler looks for a specific pattern.

Some things about enumeration: enumeration does not guarantee a specific order. Enumerators can also be transactional.

Here's how it works:

procedure Test(list: TStringList);
var
  s: string;
begin
  for s in list do
    writeln(s);
end;

There are several ways of implementing a collection supported by the for..in construct:

  • a class implementing the IEnumerable interface (for .NET only).
  • a class with a public function called GetEnumerator.
  • Compiler recognized primitive types (arrays, sets, and strings). Delphi will supports enumerating over sets, in addition to C#-like support for array enumeration.

When implementing the GetEnumerator method, you return a class implementing a specific pattern:

public
  function GetCurrent: TObject;
  function MoveNext: Boolean;
  property Current: TObject read GetCurrent;
end;

(the type returned by GetCurrent is the type being enumerated).

Multiunitnamespaces

In Delphi 8, each unit is considered a separate namespace. In Diamondback, it will be possible to include multiple units into a single namespace. The problem was how to do this without breaking the Delphi make logic.

It's important to note that there is no relationship between an assembly file name and namespaces within it. A single assemble can contain multiple namespaces, and a single namespace can contain modules from multiple assemblies (this actually lets you contribute to namespaces from someone else). The Delphi uses clause refers to namespaces, not assemblies.

The Diamondback solution uses a little trick: the rightmost name in a Delphi unit name is dropped from the namespace. For example, Borland.Vcl.Classes and Borland.Vcl.Controls will both belong to the Borland.Vcl namespace.

When using a Delphi unit, you have several options:

  • Specify the full unit name. This is how it's done today.
  • Access the entire namespace. This is only possible when linking against packages/assemblies.
  • Use a wildcard. The syntax "uses Borland.Vcl.*" will locate all units that match the pattern. Note that this could link in the entire VCL to your application. although most of that will be removed by the smart linker, the compiler still has to pull in the symbols from all of these units, which may require a lot of resources and considerably slow-down compilation. This syntax also disables initialization sections for units that are not explicitly referenced.

Global variables and procedures (placed in a per-unit class in Delphi 8) will be emitted as members of a class with the same name as the unit, placed in a module called "Units" - so global variables from Borland.Vcl.Classes will be placed in a class called Borland.Vcl.Units.Classes.

Function inlining

The idea of function inlining is to copy the code within a function into the call site for that function. When the function is small enough, this can produce a significant performance boost, because it eliminates the cost of actually calling the function. On the other hand, function inlining can cause code bloat, so it should be used with care.

A new directive, inline, tells the compiler to inline a function. Another option is to have the compiler look for inlining candidates automatically, but that can be very inefficient. Function inlining is supported in both Win32 and .NET, even though the JIT compiler already does some inlining.

The inline directive is a suggestion. The compiler may choose to ignore it if - Danny's words - "it thinks you're wrong or you're stupid." Also, the Delphi compiler is a single-pass, top-down compiler, so the function body must be seen by the compiler before calls to it can be inlined. Circular unit references will also defeat inlining. Finally, asm routines cannot be inlined.

Another restriction on inlining is that inlinable code has limited access to private or protected symbols, especially in .NET, since once the code is moved outside the class to which it belongs, it loses access to that class's private and protected symbols.

An interesting side effect of inlining is that it increases unit brittleness. If an inlined function changes, all units that use it must be recompiled - even if the function is in a unit's implementation section. In the past, changes to the implementation section had no affect on other units.

Inlining is controlled by a compiler directive: {$INLINE ON/OFF/AUTO}. The default is ON. AUTO means the compiler will examine inlinable functions.

Miscellaneous improvements

There are some code generation improvements, and some new features:

  • Unicode identifiers, with support for UTF-8 and Unicode source files.
  • Do not use Unicode identifiers in published properties or methods.
  • Improved overload discrimination.
  • Forward declarations for record types (.NET only).

Future directions

Some things considered for the future:

  • Supporting .NET 2.0, including parameterized types (generics).
  • Support for partial classes and anonymous methods - even though those are not supported by the CLR, they are implemented by C#.

|

Live blogging from Allen's talk
Monday, September 13, 2004 10:01 AM

In the spirit of live blogging, here are my notes from Allen Bauer's "What's new in Delphi" talk.

Allen is focusing on IDE features. As he notes, this release of Delphi is about making the developers productive. There are new features in a lot of areas - designers, editors, debuggers, and refactoring.

The Galileo IDE supports multiple personalities: Delphi for Win32, Delphi for .NET, C#. Note: this means nothing in regard to the actual SKUs. Allen makes it clear - the engineers are allowed to talk about anything in the product, except SKUs, release dates, and product names.

New debugging features:

  • Win32 and .NET debuggers working simultaneously (for example, debug a Win32 client for a .NET Web service and the Web service itself at the same time).
  • Debugging .NET code hosted in a Win32 process.
  • AppDomain support in the Module view.
  • Better stack traces in Win32.
  • Locals view - see local variables in stack frames (during a stack trace).
  • Improvements to the exception notifications.
  • Breakpoints improvements - in-place editing, enable/disable using a checkbox.
  • IL disassembly view.
  • Full SSE support.
  • Unicode-enabled view.
  • Better IIS debugging.

Refactoring:

  • Rename identifier (works even within a project group, including projects that contain both Delphi and C# code). This is based on the actual uses clause, not just what's listed in the project group.
  • Extract method
  • Extract resource string
  • Sync Edit (like JBuilder - text replacement in a pure lexical fashion, works within a selected block)
  • Find unit or namespace
  • Declare field
  • Declare variable
  • C# and Delphi (Win32 and .NET)

Good news for long-time Delphi developers - the floating designer is back for VCL and VCL.NET. Lots of people liked this. The designer now supports drag-and-drop from the palette, like the WinForms designer.

Another improvement is the Structure view - an extension of the object tree view which includes a lot more information, so it's useful in more modes. Memorable quote: "The JBuilder guys stole a lot of things from Delphi - it's their turn to get ripped off."

Allen's showing off Corbin's new and improved tool palette, with features such as filtering, customizable categories, button sizes, and color schemes.

Other cool features:

Help Insight - displays (in HTML) information about a symbol, based on XML documentation, including Microsoft's documentation, and the hyperlinks actually work.

History tab - keeps a history of changes. The number of versions is configurable. This is useful even if you use a source control system, because you don't always check in every little change. You can even see the difference between a version of the file and the (unsaved) editor buffer.

Finally, the IDE startup time will be improved. The R&D team are going to spend some time just on performance.

|

Blogging from Borcon
Monday, September 13, 2004 08:02 AM

So, I'm sitting right outside the convention center, ready for the first day (second, if you count the opening keynote, or third, if you count the preconference tutorials) of BorCon. Going to be an interesting day - quite a  few sessions I'd like to attend.

We've just finished breakfast, and the "General Session", which I'm going to skip, is about to begin. Here's what I don't get: breakfast was at 7:00. For a company that's committed to the developer, as Dale said last night, Borland should know that Real Programmers don't get up before 10:00 (at least).

I didn't get to the preconference tutorials. I would have liked to hear Danny's talk, but was too jet-lagged. Nick summarized it nicely, though.

The opening keynote was, frankly, one of the most boring I've ever heard. Dale came up with a new TLA, SDO (Software Delivery Optimization, I think), that's going to be Borland's next message after ALM. I guess this is about Borland's acquisition of ESTIMATE Professional. They also showed a long-term project management concept which I (and anyone I talked to later) didn't get at all.

The coolest part of the opening keynote was probably the awards (oh, and the dancers). Dale gave one of those big checks that photograph really well but are probably not easily accepted at the bank - $1,000,000 to Carnegie-Mellon. The President's Award went to Allen Bauer, who made the obligatory "wow" expression upon seeing the check. Good for you, Allen - well deserved.

|

Non-client area in .NET
Friday, September 03, 2004 10:33 AM

Among the hundreds of ridiculous search phrases leading to this blog, there are a few valid technical issues. For some, there is very little information available out there. One of these is the issue of non-client messages in .NET.

The .NET Framework does a pretty good job of wrapping the existing Win32 functionality in managed objects, while providing a lot of new functionality. However, because of the sheer size of the platform, Microsoft chose not to include certain capabilities in versions 1.0 and 1.1 of the Framework. The bits left out are usually the least-frequently used parts of Win32, but if you need them, you're stuck.

Non-client message handling is one of the things left behind. If you need to handle non-client messages in your applications or custom components, there are no events you can handle, and no methods you can override. You can, however, still handle these messages in the old Win32 way - checking the message number in the window procedure and interpreting the message record yourself.

The way to do this is to override the control's WndProc method. WndProc is a protected method called as part of the control's message processing, and pretty much corresponds to the traditional window procedure. By overriding it, you can handle any message received by the control. Since the Windows messages are not defined in the .NET Framework, you'll have to declare any message constants (and other related values and structures) yourself. So, if you wanted to handle the WM_NCHITTEST message, for example, so that dragging any part of the window would move it, you'd write this code:

public class MovableForm : System.Windows.Forms.Form
{
    //[...]

    private const int WM_NCHITTEST = 0x0084;
    private const int HTCLIENT = 1;
    private const int HTCAPTION = 2;

    protected override void WndProc(ref Message m)
    {
        base.WndProc (ref m);
        if (m.Msg == WM_NCHITTEST)
        {
            if (m.Result.ToInt32() == HTCLIENT)
            {
                m.Result = new IntPtr(HTCAPTION);
            }
        }
    }
}

Or, in Delphi:

procedure TWinForm.WndProc(var m: Message);
const
  WM_NCHITTEST = $0084;
  HTCLIENT = 1;
  HTCAPTION = 2;
begin
  inherited WndProc(m);
  if m.Msg = WM_NCHITTEST then
  begin
    if m.Result.ToInt32 = HTCLIENT then
      m.Result := IntPtr.Create(HTCAPTION);
  end;
end;

|

Copyright 2004 Yorai Aminov