|
| How Delphi fits into .Net |
| With Delphi 7, Borland took a first stab at integrating with .Net. Unfortunately, they were limited for time, and had to defer a full integration to release 8 : Delphi 8 for .Net. Fortunately, it has been worth the wait. | |
| Delphi is now one of a number of languages that have been implemented for .Net (over 20 languages are eligible for implementation). Borland are the first third party to be licenced. | |
| Just like C# and Visual Basic, Delphi code combines with the Framework classes to create applications - they are combined into Intermediate Language (IL) code, which is stored into managed modules in an asembly. They are extracted on the target machine and Just-In-Time compiled and executed by the Common Language Runtime (CLR) just as if they were written in C# or Visual Basic and so on. | |
| The Common Type System |
| The Common Type System (CTS) is part and parcel of the .Net Framework. In order for language indepedance, data types in the language must be mapped into .Net Framework data types - the CTS data types. These are mostly a special type of class (there are no primitive data types in the framework) called Structures which are fixed in size, and hence efficuently manageable by the the CLR. | |
| For example, the Delphi Integer data type is mapped to the framework System.Int32 structure. Integer in Delphi was a primitive, but is now treated as a structure. | |
| Strings are proper classes in .Net since they are variable in size. The Delphi String primitive data type is mapped to the System.String framework class. Be particularly wary of string handling in Delphi for .Net. They are individually handled as 1-indexed, but in Framework string manipulation routines - they are 0-indexed. It is easy to slip up on this : Borland had to preserve the 1-based indexing of the primitive type, but then had no choice about the 0-based indexing of the Framework routines. See System.String.IndexOf for an example. | |
| The following table illustrates the mapping of data values from Delphi data types to .Net CTS types. Click on a blue value to see either the native or .Net definition : | |
|
|
| * The TDateTime type is implemented as a hybrid of the original TDateTime record and the System.DateTime type for reverse compatibility. | |
| The Integrated Development Editor (IDE) |
| This has changed significantly - components are now provided via a tabbed structure on the right hand side of the screen. The IDE also has a split personality. When developing VCL Forms and console applications, the form looks familiar - a WinForms application form takes on the look and feel of a form in Microsoft' Visual Studio. | |
| The component properties box has taken on the Microsoft look and feel. Some of the original IDE niceties are gone - adding a button to the form and typing does not automatically furnish the button caption value - you have to select the caption property first. | |
| When running applications, a vastly more detailed debug error box appears, often giving more detailed error messages and contextual information. | |
| The Delphi VCL |
| Borland wisely respected the existing non-.Net Delphi user and application base, and provided a gentle migration path into .Net. At the same time, however, they introduced a bit of confusion. How can it be that the original Visual Component Library (VCL) is available for .Net applications? Surely you must use the .Net Framework visual components and classes? | |
| Not true - the VCL was developed as a wrapper to .Net Framework - extending the framework classes to suit the existing users with their familiarity of VCL. | |
| This allows existing applications to be migrated to .Net with relatively little change, and allows users to write new applications in .Net without a huge learning curve. It also allows new applications to be written once, but compiled into Win32 and .Net applications. | |
| However, the VCL implementation creates Windows platform specific code, and for this reason, is not recommended for new .Net applications. | |
| It is not clear how long VCL will be supported by Borland, but it is likely to be a number of years. | |
| Where DelphiBasics helps |
| Borland had a dilemna when shipping Delphi 8. They were now intertwined with Microsoft's .Net strategy for good and bad. The good is that the Micosoft MSDN help files are vast, and fully cover all aspects of the Framework and more. The bad is that they are too large to extend with Delphi syntax and examples. | |
| The DelphiBasics site has documented a key subset of the Framework Namespaces, in the same style as the Delphi 7 run-time references : each class method has example code with output to assist in understanding. | |
| In case of dispute, each page has a link back to the MSDN reference page. | |
| There are also a number of tutorials to get things going. | |
| | | | |