Delphi Prism Reviewers Guide

By: Nick Hodges

Abstract: The Delphi Prism Reviewers Guide is designed to inform reviewers about the features and capabilities of Delphi Prism.

    Introduction

Thank you for taking the time to review Delphi Prism. This guide is designed to inform you about the capabilities, features, and attributes of the product so that you can be fully informed when writing your review. Delphi Prism is a brand new product, and so this guide will help you get familiar with it.

    General Overview of Delphi Prism

Delphi Prism is a feature-rich, powerful development tool for the .NET 3.5 Framework. By providing a powerful Object Pascal language that enables access to the entire .NET framework and a powerful, complete Integrated Development Environment (IDE), Delphi Prism is a complete .NET development tool. Delphi Prism developers can design and deploy applications for ASP.NET, Windows Forms, and Windows Presentation Foundation (WPF). In addition, Delphi Prism is focused on running against the Common Language Runtime (CLR) any where that it may be deployed, including the Mono platform on Linux and the Mac.

    Prerequisites and System Requirements

Delphi Prism requires the following prerequisites:

    Hardware Requirements

  • Minimum: 1.6 GHz CPU, 384 MB RAM, 1024x768 display, 5400 RPM hard disk
  • Recommended: 2.2 GHz or higher CPU, 1024 MB or more RAM, 1280x1024 display, 7200 RPM or higher hard disk
    • On Windows Vista: 2.4 GHz CPU, 768 MB RAM
  • 1 GB of available space required on system drive
  • 2 GB of available space required on installation drive (includes space for .NET Framework and SDK)
  • Mouse or compatible pointing device

    Supported Operating Systems

  • Windows XP Service Pack 2 or above
  • Windows Server 2003 Service Pack 1 or above
  • Windows Server 2003 R2 or above
  • Windows Vista
  • Windows Server 2008

Delphi Prism will run on both 32-bit and 64-bit operating systems.

    Installation

The Delphi Prism installer is normally downloaded from the web. Media kits containing the entire product are also available.

The installation executable will install the entire product. If a current install of Visual Studio 2008 is already present on the machine, then Delphi Prism will integrate into that existing installation. If there is no Visual Studio 2008 present, then Delphi Prism will install the Visual Studio Shell before installing Delphi Prism into the Shell.

    Editions

Delphi Prism has two different editions to cater to different market segments – Professional, and Enterprise.

    Professional

The Professional edition of Delphi Prism is designed for developers who need a general purpose, .NET development tool with limited or local-only database access. The Professional edition includes the full-featured IDE, the Delphi Prism language, local access to InterBase and Blackfish SQL via dbExpress for ADO.NET. In addition, the Professional edition includes a database-neutral implementation of the ASP.NET Provider Model with support for Blackfish SQL and InterBase.

The Professional edition is attractive to Independent Software Vendors (ISVs), professional developers without a need for remote database access, and any developer wanting to develop general Windows applications and utilities.

    Enterprise

The Enterprise edition of Delphi Prism is designed for developers who want remote access to dbExpress databases, specifically Blackfish SQL and InterBase. In addition, the Enterprise edition enables the development of clients to connect to multi-tier servers built with DataSnap in Delphi 2009.

Delphi Prism is also available as part of CodeGear RAD Studio 2009 Professional, Enterprise and Architect editions.

    Localized Versions

Delphi Prism is shipped in four localized versions: English, French, German, and Japanese. Developers can choose any of the four localized versions to install.

    Main Features of Delphi Prism

    Support for the CLR on Multiple Platforms

One of the main features of Delphi Prism is its support for the CLR where ever it resides, particularly Mono for Linux and Mono for the Mac. Delphi Prism’s compiler is a managed code application and can run on Mono for both Mac OS X and Linux. In addition, the compiler produces completely standard Intermediate Language (IL)-based assemblies, meaning that those assemblies can run on the Common Language Runtime (CLR) on any operating system.

Delphi Prism provides project templates for starting Mono projects on Windows, Mac OS X, and Linux.

Hide image
NewProjectsMono

Figure 1 -- The New Project dialog showing templates for developing Mono applications.

More information about running Delphi Prism applications on the Mono platform can be found in the CodeGear Developer Network Article entitled “Using Mono and Delphi Prism”.

Delphi Prism ships with the Mono for Windows 2.0.1 platform, installing it if the user desires.

    Heterogeneous Database Access

Delphi Prism includes the powerful dbExpress IV framework, adapted to work with ADO.NET. This means that .NET developers are not limited to a specific backend database, but instead, can use a single framework to communicate with multiple databases. This version dbExpress includes support for InterBase and Blackfish SQL, with more databases to come in future feature updates.

Hide image
ServerExplorer

Figure 2 -- Visual Studio's Server Explorer including support for InterBase and Blackfish™ SQL

    Database-neutral ASP.NET Development

Delphi Prism also includes a dbExpress-based implementation of the ASP.NET Provider model. Therefore, Delphi Prism developers can not only access data in a neutral way with dbExpress, but they can also use a dbExpress-based database for their roles, profiles, and membership requirements in ASP.NET.

    Multi-tier Client Development with DataSnap

Delphi Prism also includes an ADO.NET driver for DataSnap. DataSnap is Embarcadero’s powerful, dbExpress-based multi-tier development framework. With Delphi 2009, developers can build middle-tier application servers that provide “gatekeeper” access to any backend database. These servers can provide both direct connections, access to data, and general method functionality via server methods.

Server Methods are special methods provided by a class on the application server. By using the dbExpress typing system, developers can easily expose server methods to DataSnap Clients. Delphi Prism provides the ability to import a DataSnap server into ADO.NET. Server Methods that return Datasets are viewed as tables, and server methods are viewed as Stored Procedures. Thus, developers can, in effect, write stored procedures in Delphi code and consume them in Delphi Prism.

The Delphi Prism roadmap calls for the ability to build DataSnap servers in Delphi Prism.

    Language Features

The Delphi Prism language is a powerful, full-featured language for use with the .NET 3.5 Framework. It supports all language idioms required by .NET, including features like LINQ, anonymous methods and delegates, generics, etc. Delphi Prism has strong roots in the world of Object Pascal, and thus the syntax will be very familiar to any Delphi developer. If required, existing Delphi code can be easily migrated from Delphi for Win32.

The Delphi Prism language has all the modern language features that .NET developers expect, and more. Some specific language features that illustrate the power of Delphi Prism are discussed below:

    Generics

Generics allow the developer to write code that refers to a type without having to specify the specific type of that type. Often called Parameterized Types, generics provide developers with the ability to write general, or “generic’ classes that operate on a non-specific type. The class use case for generics is a list, where the type of the items contained within the list need not be specified when the list is written.

The members of a generic class that reference the generic type will have their actual type filled in at runtime by the Just-In-Time compiler. The Microsoft .NET Framework comes with several built-in generic classes, e.g. the List<T> type, which is a dynamic list structure containing references to any number of type T. T can be any type at all, and Tlist<T> will be a type-safe list of whatever type the developer desires.

A generic class looks like this:

type
  MyList<T> = class(System.Object, System.Collections.Generics.IEnumerable<T>)
    where T is class;
  private
    fData: array of T;
    fCount: Integer;
  public
   ...

To use this class, the generic type has to be defined in the type signature:

var
  Data: MyList<String>;
begin
  Data := new MyList<String>;
  Data.Add('Test');

Generics can also constrain the type passed as a parameterized type. Using constraints can ensure that the generic type passed as certain functionality, implements a specific interface, is a class or record, or has a parameter-less constructor.

type
  MyClass<T> = class(System.Object)
    where T has constructor, T is record;

    method Test<Y>(Left: T; Right: Y);
      where Y is class, Y is IEnumerable;
  end;

    Class Contracts

Class Invariants

Class invariants are restrictions placed on a class declaration that will ensure that a given variable meets a given state. For example, the following class declaration requires that the SomeInteger variable always be greater than ten. If code assigns a value less than ten to the SomeInteger variable, and Assertion will be raised.

type
  TClassWithInvariant = class
  public
    SomeInteger: Integer;
  public invariants
    SomeInteger < 10;
  public
    procedure SetSomeIntegerGreaterThanTen;
  end;

Require/Ensure

Class definitions can add require sections before the method body, and an ensure section at the end of a method body. These sections define pre- and post-conditions that must be met for the code to execute normally. These sections are Boolean statements that will be checked to be true before and after execution.

Class Contracts are normally used to check for the validity of input parameters, results, or for the state of the object required by the method. If a Class Contract is “broken”, an assertion is raised.

method MyObject.DivideBy(aValue: Integer);
require
  aValue <> 0;
begin
  MyValue := MyValue/aValue;
end;

method MyObject.Add(aItem: ListItem);
require
  assigned(aItem);
begin
  InternalList.Add(aItem);
ensure
  Count = old Count +1;
End;

method MyObject.DoWork(aValue);
require
  Assigned(fMyWorker);
  fMyValue > 0;
  aValue > 0;
begin
  //... do the work here
ensure
  Assigned(fMyResult);
  fMyResult.Value >= 5;
end;

Custom messages can be added to any require or ensure declaration by adding a colon (:) and then the string text for the message:

method MyObject.Add(aItem: ListItem);
require
  assigned(aItem) : 'List Item for MyObject cannot be nil';
begin
  InternalList.Add(aItem);
ensure
  Count = old Count +1 : 'MyObject: Count logic error';
End;

The 'old' scope prefix can be used in the 'ensure' section for local variables and parameters to refer to the original values before the execution.

The compiler will add code to save these to local variables before executing the method body; 'old' is supported for strings and value types.

Both Method Contracts and Class Invariants allow developers to explicitly and clearly declare the requirements for code, ensuring that code is of higher quality and performs as expected and designed.

    LINQ

LINQ – Language Integrated Query – is a new, powerful language idiom that allows developers to perform SQL-like queries on any iterated data structure directly in code. As a simple example, the following code and be used to select customers based on their age:

method MainForm.button10_Click(sender: System.Object; e: System.EventArgs);
var
  YoungCustomers: sequence of TCustomer;
begin
  YoungCustomers := from Customer in ListOfCustomers;
  if radioButton1.Checked then
  begin
    YoungCustomers := from Customer in YoungCustomers where Customer.Age < 30;
  end else
  begin
    YoungCustomers := from Customer in YoungCustomers where Customer.Age > 30;
  end;

  if checkBox2.Checked then
  begin
    YoungCustomers := from Customer in YoungCustomers order by Customer.Age;
  end;

  textBox4.Clear;
  for each Customer: TCustomer in YoungCustomers do
  begin
    TextBox4.Text := TextBox4.Text + String.Format('{0} {1} is {2} years old'#13#10, Customer.FirstName, Customer.LastName, Customer.Age);
  end;
end;

Note the assignments to the YoungCustomers variable that use the new LINQ syntax for selecting customers easily out of the customer Sequence.

LINQ can also be used to query against Datasets and any other data structure that supports an enumerator.

    Property Notifications

Property Notifications are a language feature that provides notifications to properties when the value of the property is changed. When notify is used on properties, the class will implicitly implement the System.ComponentModel.INotifyPropertyChanged and System.ComponentModel.INotifyPropertyChanging interface and invoke the event defined in that interface when the property itself is modified.

By default, it will pass the name of the property as defined in the class, however, notify supports a string parameter to change the name of the property passed to the event.

A Property Notification is declared as follows:

type
  ValueClass = class
  public
    property Value: Integer; notify;
    property Name: string; notify 'ValueName';
  end;

The Property Notification is then implemented as follows:

var
  v: ValueClass;
begin
  v.PropertyChanged +=
    method (sender: Object; args: PropertyChangedEventArgs)
    begin
      MessageBox.Show(String.Format('Property changed: {0}', args.PropertyName));
  end;
end;

    Parallel Programming

    Parallel Loops

If the Microsoft PFX Framework is installed as part of the .NET environment, a parallel loop will spread execution over multiple cores and threads.

for parallel i: Integer := 0 to 10 do ... // works

for parallel i: Integer := 1 to 49 step 7 do ... //works

    Futures

Futures are a new language concept designed to facilitate Parallel Computing and developing applications that scale well on multi-core and multi-CPU systems. A future is a strongly typed variable that represents a value that might or might not have been calculated yet, but is guaranteed to be made available when needed.

Consider the following snippet of pseudo code that calculates the Sum of values in a binary tree:

method ThreeNode.Sum: Int32;
begin
  var l: Int32 := Left.Sum;
  var r: Int32 := Right.Sum;
  result r+l;
end;

This code first calculates the Sum of the left part of the subtree, then that of the right one. Finally, the two values are combined. Calculating the value of both "l" and "r" might take a relatively long time, yet the value of "l" is not actually needed until the very last line of the method. This is an ideal candidate for a future:

method ThreeNode.Sum: Int32;
begin
  var l: future Int32 := async Left.Sum;
  var r: Int32 := Right.Sum;
  result r+l;
end;

Instead of calculating the value of "l" in place as before, "l" is now defined as a future Int32, declaring that the variable does not actually hold the value of Left.Sum, but just the promise that, at some point in the future, it will. This first line of code will execute in virtually no time, and the method can move on to calculating "r", which is unchanged and will happen in line, as before.

    Async Methods

Methods marked with the Async keyword are executed in a separate thread. Implementation depends on whether the PFX framework is present. If so, Async statements are run via the PFX framework as a task; otherwise, they are added to the .NET thread pool.

To define async statements, the async keyword can be added before the statement, for example:

async for i := 0 to 10 do begin

...
end;

or more generally for any statement block:

async begin

...
end;

If an async method returns a value, that value becomes a future.

    Other Language Features

Delphi Prism includes all the expected language structures (objects, arrays, records, sets, enumerated types, case statements, for loops, etc.) and many additional language features such as Extension Methods, Anonymous methods and delegates, attributes, class references, interfaces, Lambda expressions, and operator overloading.

A complete examination of the Delphi Prism language can be found on the online wiki.

    Integrated Development Environment

Delphi Prism integrates with Visual Studio Shell as an IDE. As a result, Delphi Prism developers have all the power and features of that platform. If Delphi Prism is integrated into a Visual Studio installation, then Delphi Prism project groups can include code from C#, VB.NET or other languages, and projects from those languages can include Delphi Prism code as well. Delphi Prism developers can utilize all the power of the Visual Studio IDE including Intellisense, Error Info, Code Snippets, Parameter Info, debugging and more. Delphi Prism is a fully integrated language plug-in and a full-fledged member of the .NET language eco-system.

    Designers

Delphi Prism developers can utilize all the design-time support for Winforms, ASP.NET, and WPF development. When integrated with Visual Studio itself, Silverlight design-time support can be installed.

    Third-Party Components

Delphi Prism developers can install and use the vast array of third-party components for WinForms, ASP.NET, WPF, and Silverlight. Components from vendors like Developer Express, Infragistics, TMS Software, and other commercial vendors are all useable in Delphi Prism. Open source and freeware components written in other .NET development languages can be used. The full array of .NET components is available to Delphi Prism developers.

    Visual Studio Eco-system

Delphi Prism developers can install and use most of the wide variety of Visual Studio plugins and add-ins. For example, all MSBuild actions are usable by Delphi Prism. In addition, Visual Studio plugins that don’t require specific language functionality are all available to Delphi Prism developers. Delphi Prism includes a full implementation of the .NET CodeDOM. Libraries like NUnit, NHibernate, and other popular .NET projects are all usable by Delphi Prism developers

Hide image
Intellisense

Figure 3 -- Delphi Prism includes full IntelliSense support for Delphi Prism developers.

In addition, Delphi Prism integrates the dbExpress database framework in Server Explorer, allowing developers to access dbExpress drivers via ADO.NET. Delphi Prism ships with dbExpress drivers for InterBase and Blackfish SQL, with additional drivers to be added in future updates.

    Documentation

Documentation for Delphi Prism is wiki-based. In addition, a snapshot of the wiki is shipped with Delphi Prism, so developers can have a copy of the wiki on their own systems. In addition, developers can at any time grab their own snapshot of the current state of the wiki for themselves.

Because the documentation is wiki-based, the documentation can be frequently updated and continually enhanced, both by Embarcadero employees and community members. Articles can be added and enhanced, and examples can be included. Overall, this makes for a dynamic documentation experience, with the help being continuously improved and frequently updated.

    Included and Recommended Third-party Tools

    Included Tools

Delphi Prism ships with a number of third-party tools and products.

    InterBase Developer Edition

Delphi Prism ships with a Developer Edition of InterBase, Embarcadero’s native, cross platform Relational Database Management System (RDBMS). InterBase Developer Edition allows developers five connections to the server hosted on their local machine for the purpose of developing applications that use InterBase. Once the application is developed, developers can purchase deployment licensing from Embarcadero.

More complete information about InterBase can be found on the CodeGear website.

    Blackfish™ SQL

Blackfish SQL is a high-performance, small-footprint, SQL-92 compliant transactional database. Blackfish SQL is a fully-managed RDBMS that runs on both .NET and Java. Running either in-process or out-of-process, and with a small footprint of just over one megabyte, Blackfish SQL is easily deployed and embedded, yet retains the full power needed by all types of database applications, from enterprise applications to embedded ISV applications.

Delphi Prism includes a special edition of Blackfish SQL – Blackfish SQL RAD Studio Edition. The RAD Studio edition is freely deployable with any application. Professional edition users can deploy applications built with Blackfish™ SQL with the limitation of local only connection to 1 user/5 connections and databases up to 512 megabytes in size. Enterprise and Architect developers can deploy applications with as many as 4 users/20 connections and 2 gigabyte databases. If developers require deployment beyond those limitations, additional unrestricted deployment licenses can be purchased from Embarcadero.

More information about Blackfish SQL can be found on the Embarcadero website.

    Mono for Windows

Delphi Prism by default will install the Mono for Windows 2.0.1 framework. Developers can create new projects to run against this framework. More information about the Mono framework can be found at the Mono Project.

    InstallAware Express

Developers frequently need to create full-featured and powerful installations for their products. Delphi Prism includes the Express edition of InstallAware, enabling developers to build professional, MSI-based installations. More information about InstallAware and its capabilities can be found at the InstallAware website

    Recommended Tools

Delphi Prism includes a number of recommended tools for download. They are summarized on the wiki’s Recommended Downloads page.

Three recommended download tools include:

    DPack IDE Expert

DPack Collection of tools for Visual Studio is a free download that includes a number of experts, Wizards, and plugins for Visual Studio that enhances the Delphi Prism experience and that makes it easier for Delphi developers used to the Galileo IDE (i.e., the IDE from Delphi 2009) to adapt to using Visual Studio. Features include numbered bookmarks, automatic solution backup, a Code Browser, and a keyboard binding that matches the standard keyboard layout for Delphi’s Galileo IDE.

More information can be found on the DPack homepage.

    RemObjects Internet Pack for .NET

The RemObjects Internet Pack is a lightweight and easy to use TCP/IP framework built on top of the .NET Socket library.

More information can be found on the website for the Internet Pack.

    Developer Express “Sixty” DXCore Components

Developer Express provides a collection of 60 free and fully functional components for .NET developers. They include components for WinForms, ASP.NET, and WPF development.

Two other tools that will be of interest to Delphi Prism developers who are past users of Delphi for Win32 are:

    The ShineOn Project

ShineOn is a Delphi Prism implementation of the Delphi for Win32 RTL. Delphi developers can use it to aid in the process of moving existing Delphi code into Delphi Prism.

More information about the ShineOn project can be found on the Delphi Prism Wiki.

    The Oxidizer Code Converter

Oxidizer is a free tool that, when used in combination with ShineOn, helps to port Delphi (Win32 and .NET) projects to the Delphi Prism language. Oxidizer is a command line tool that will process *.pas source files from Delphi and make many necessary changes to adapt the code to the Delphi Prism language.

More information about the Oxidizer Code Converter can be found on the Delphi Prism Wiki.

    Additional Resources

As noted above, the complete documentation for Delphi Prism can be found at: http://prismwiki.codegear.com.

The wiki includes a “Crash Course” on learning Delphi Prism.

The CodeGear Developer Network also includes a Delphi Prism area that provides links, articles, videos and more about Delphi Prism.

Server Response from: ETNASC01