Monday, October 27, 2008

Delphi Prism, some first thoughts

Delphi Prism is announced in this Embarcadero press release. Delphi Prism is based on Oxygene from Remobjects, so I think you could say Delphi Prism is Remobject's Oxygene. Read Remobjects press release here.

Added: Interview with marc hoffman, Chief Architect at Remobjects on Bitwise Magazine.

After five years of several solutions and directions, it looks like Delphi for .NET has finally found a good home.

Although Delphi .NET only exists for only about four years, there have been a lot of changes in the strategy executed by Borland, Borland/CodeGear and now Embarcadero. So let's take a brief look at the Delphi for .NET history:

2004 - Delphi 8 (Borland)
Delphi for .NET is born for the .NET Framework version 1.1. Delphi for .NET is positioned as a first class .NET citizen. It offers .NET 1.1 development for Winforms, ASP.NET and VCL.NET, which is the .NET variant of the VCL, offering a highly compatible framework based on .NET.

2005 - Delphi 2005 (Borland)
Delphi 2005 offers the same as Delphi 8 but Delphi 2005 has a lot improvements in quality.

2006 - Delphi 2006 (Borland)
Delphi 2006 still has support for the .NET Framework 1.1 (Winforms, ASP.NET and VCL.NET) Delphi 2006 offers a stable IDE for this developments. The fact that it does not support .NET 2.0 shows the trouble that Borland had to keep up with Microsoft.

2007 - Delphi 2007 (CodeGear/Borland)
Delphi 2007 finally supports .NET 2.0, but unfortunately the Winforms support is dropped. (Only ASP.NET and VCL.NET is supported)

2008 - Delphi 2008 (Embarcadero)
Delphi 2009 has become a Visual Studio Plugin based on Oxygene (formely known as Chrome) offering support for all available Microsoft .NET technology's (2.0, 3.0, 3.5))
Unfortunately it looks like VCL.NET is dropped.

It is not likely that the Delphi for .NET product strategy will be nominated for best executed product strategy ever.

However this is a very strong sign of the new spirit that Embarcadero is bringing to Delphi. It proofs that the buyout by Embarcadero is the best thing that happened to Delphi (and of course CodeGear) in the last five years.

Back to Delphi Prism:

Delphi Prism the pros
1. Instant support for all Microsoft .NET technologies.
2. The Delphi language is now at same level as C#, VB.NET, so the choice for the Delphi language can be made much easier. (Hack it is the same IDE)
3. Delphi for Win32 can focus on Win32 again, will not be hold back by .NET technologies.

Delphi Prism the cons
1. Less compatibilty with Delphi Win32 technologies, due to pure .NET and languages changes/additions. (Compared to VCL-VCL.NET, VCL-Winforms)
2. After Winforms, now VCL.NET dropped, and that will not please every body.

All with all the pros weigh more than the cons in my opinion.

Why use Delphi Prism?
This question is not answered easily. I think a lot of Delphi developers went for C# in the last four years. For example we decided in 2007 to standarize our .NET development on Visual Studio C# due to the dropping of Winforms in Delphi 2007 (Basicaly due to the mixed/confusing messages by Borland).

Although we don't know all the ins and outs yet (sure will hear a lot more the coming week) this is by far the best thing ever that happened to Delphi for .NET.

Wednesday, October 22, 2008

Exploring anonymous methods

New in Delphi 2009 are anonymous methods. Anonymous methods are methods without a name, which are able to do something on local variables where they are implemented. In fact they are a reference to a method.
Anonymous methods are a bit magic, at least they were to me, and hard to explain.
A nice place to use them is together with generics types. For instance the Sort method of a TList<T> is a natural place to use them:

function(const Item1, Item2: TPerson): Integer
Result :
= CompareText(Item1.LastName,

A cool thing about anonymous methods is that it can execute your code (incl. local vars) in another place. This can be another unit or even another thread.

Implementing them in your daily code however is another thing. How to do that? Well here are my first explorations: Let's say we have this simple application that has a TStringList where we want to do some searching on the strings, based on the users input. I came up with this:

//Declaration of the anon reference
//The passed string will be searched on
to function(s : string) : Integer;

//Implement a method to execute
//1. Ask a string to search
//2. Execute the referenced method "proc"
function TForm4.FindString(proc: TAnonStrProc)
: Integer;
SearchStr : string;
Result :
= -1;
if InputQuery('Search', 'Search a string',
then begin
Result :
= proc(SearchStr);

//Create a string list
procedure TForm4.Button1Click(Sender: TObject);
sla : TStrings;
i,j : Integer;
Index, Count : integer;
sla :
= TStringList.Create;
//Call the FindString method with anon method
//to get the index of string in the list
//Note that it does someting with our local
//variable sla
Index := FindString(function(s : string) : Integer
Result :
= sla.IndexOf(s);
'Index: ' + IntToStr(Index));

//Call the FindString method with anon method
//to get the count of a searched string
Count := FindString(function(s : string) : Integer
str : string;
i : integer;
Result :
= 0;
for str in sla do begin
if str = s then
'Count: ' + IntToStr(Count));

Please note that this example probably won't make it in the daily code, but it shows in a simple manner how they work. Because of the fact that our anonymouse method can take any method as long that it has a string as parameter you can call one method FindString with different implementations by passing different methods.

Well I think anonymous methods are cool. Implement them in your daily code wisely is not that simple. The working however, which seems magic at first, is after some exploring not that hard to follow.

Monday, October 20, 2008

Round the table

The 11th Episode on the the podcast @ dicusses some interesting things like anonymous methods, Garbage Collection ("To Dispose() or not to Dispose() ) and the speed of the TStringbuilder.

Great stuff! Enjoy!

Monday, October 06, 2008

Speculating on .NET plans #3

Although there are not much details unveiled yet, Nick Hodges made some statements about a new CodeGear product/project/plan called Delphi Prism at the SDN Conference in the Netherlands.
Marco Cantu was the first to blog about this statements, soon followed by Bob Swart, and Tim Anderson.

But no official statement yet! As it looks the official announcement will be made during the PDC Conference by the end of this month. (According to Allen Bauer's blogpost)

What we know now is that Delphi Prism will be a Visual Studio plugin, which I think is great news. As you might know I speculated somewhat over the Delphi .NET (That was the former name of the product) roadmap in previous blogposts, here(#2), here and here. Looks like my speculations were pretty accurate. :-P

I guess this will be the end of the speculation part although there are much questions unanswered, which I am sure will be answered in the near future.