<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Jamie&#039;s Blog &#187; .NET General</title>
	<atom:link href="http://jamiei.com/blog/topic/development/win-dev/dotnet-general/feed/" rel="self" type="application/rss+xml" />
	<link>http://jamiei.com/blog</link>
	<description>Delphi Programming, Web Development, General Technology and, of course, Midget Gems</description>
	<lastBuildDate>Sun, 05 Sep 2010 21:27:50 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=abc</generator>
<cloud domain='jamiei.com' port='80' path='/blog/?rsscloud=notify' registerProcedure='' protocol='http-post' />
		<item>
		<title>New Language Features in Delphi Prism</title>
		<link>http://jamiei.com/blog/2009/01/new-language-features-in-delphi-prism/</link>
		<comments>http://jamiei.com/blog/2009/01/new-language-features-in-delphi-prism/#comments</comments>
		<pubDate>Sun, 11 Jan 2009 17:47:11 +0000</pubDate>
		<dc:creator>jamiei</dc:creator>
				<category><![CDATA[.NET General]]></category>
		<category><![CDATA[Delphi]]></category>
		<category><![CDATA[Delphi Prism]]></category>
		<category><![CDATA[codegear]]></category>
		<category><![CDATA[delphi prism]]></category>
		<category><![CDATA[features]]></category>
		<category><![CDATA[language]]></category>
		<category><![CDATA[linq]]></category>

		<guid isPermaLink="false">http://jamiei.com/blog/?p=64</guid>
		<description><![CDATA[Continuing my look at Delphi Prism, in my previous post I took a (very short) look at some of the compatibility changes required to port my Delphi.NET  Twitter Library to Delphi Prism, I mentioned that I now needed to learn about some of the new language features provided by Prism. Ever since the release of [...]]]></description>
			<content:encoded><![CDATA[<p>Continuing my look at <a href="http://www.codegear.com/products/delphi/prism">Delphi Prism</a>, in my previous post I took a (very short) look at some of the compatibility changes required to <a href="http://jamiei.com/blog/2008/12/migrating-a-project-to-delphi-prism-from-delphinet/">port my Delphi.NET</a>  Twitter Library to Delphi Prism, I mentioned that I now needed to learn about some of the new language features provided by Prism.</p>
<p>Ever since the release of Delphi.NET there has been much confusion surrounding why you would choose the Delphi language for .NET Development. When Delphi.NET was released there was concern that it was not a first class member of the .NET framework and always seemed to lag 12-18 months behind the lightning fast pace of development of the .NET Framework. With Prism Delphi offerings for .NET are based upon the <a href="http://www.remobjects.com">RemObjects</a> Oxygene compiler which isn&#8217;t required to maintain a loose language compatibility with the Win 32 Delphi compiler and therefore is able to progress at a much faster pace.  </p>
<p>Still, despite this: A recent <a href="http://stackoverflow.com/questions/242584/will-you-use-delphi-prism">Delphi Prism related thread</a> at <a href="http://stackoverflow.com/questions/tagged/delphi">StackOverflow</a> showed that there still seems to be a general feeling that Delphi is a second class citizen in the .NET Development World. Some even seemed to suggest that the language features in Prism make it unrecognisable as Delphi. To try to dispense with this idea: I thought that I would show off some of <em>my own</em> favourite new language features in Delphi Prism and ones which for me make it a natural fit for .NET.  </p>
<p>Please note: This is <strong>not</strong> intended to be a comprehensive guide to the new language features. For that you&#8217;ll need to refer to the <a href="http://prismwiki.codegear.com/en/Main_Page">Delphi Prism Wiki</a> page on <a href="http://prismwiki.codegear.com/en/Delphi_Prism_Syntax_compared_with_Win32_Delphi">Compatibility with Win 32 Delphi</a>.</p>
<p>My favourite new language features which Prism brings to the table for Delphi Developers is <a href="http://msdn.microsoft.com/en-gb/library/bb308959.aspx">LINQ</a>. <a href="http://www.monien.net/blog/">Olaf Monien</a>, who I also follow on Twitter (<a href="http://twitter.com/omonien">@omonien</a>), posted a beautifully simple<a href="http://www.monien.net/blog/index.php/2008/12/delphi-can-do-linq/"> example of using LINQ with Delphi Prism</a> on his own blog and then showed how Delphi Prism can also do <a href="http://www.monien.net/blog/index.php/2008/12/delphi-can-even-linq-to-sql/">LINQ to SQL</a>. I have replicated his basic example below because it also demonstrates another great language feature.</p>
<pre class="brush: delphi;">// Type Declaration
  MusicAlbum = record
  public
    Name: string;
    Artist: string;
    AlbumYear: integer;
  end;</pre>
<pre class="brush: delphi;">var
  MyAlbum: MusicAlbum;
  MyAlbums : List&lt;MusicAlbum&gt;;
begin
// Create our Album List
MyAlbums := new List&lt;MusicAlbum&gt;; 

// Setup a our records
MyAlbum := new MusicAlbum;
MyAlbum.Artist := 'Kanye West';
MyAlbum.Name := '808s and Heartbreak';
MyAlbum.AlbumYear := 2008;
MyAlbums.Add(MyAlbum);  

// Execute our LINQ Query
var AlbumsLastYear := from Album in MyAlbums where Album.AlbumYear.Equals(2008); 

// Add the result to our listbox
for Album in AlbumsLastYear do
begin
  lbFoundAlbums.Items.Add(Album.Artist + ' - ' + Album.Name + ' (' + Album.AlbumYear + ')');
end;

end;</pre>
<p> <br />
This code clipping also demonstrates <a href="http://prismwiki.codegear.com/en/Type_Inference">Type Inference</a> which allows a variable type to be inferred from the context of it&#8217;s usage. For example, consider writing the following: <strong><em>var</em></strong><em> MyGreatList := </em><span class="hl kwa"><strong><em>new</em></strong></span><em> List&lt;</em><span class="hl kwb"><em>String</em></span><em>&gt;; </em>or even something as simple as <strong><em>var</em></strong><em> s := &#8216;string&#8217;;</em>. Type Inference is a useful addition which I can see myself making extensive use of. My only concern about Type Inference is how it affect&#8217;s the readability of the code as I am used to reviewing the var section of a method for a guide to what types are used within a method.</p>
<p>LINQ can also be used with XML. The below example takes our previous sample and reads the data from an XML file instead: </p>
<pre class="brush: delphi;">
&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;
&lt;albums&gt;
		&lt;album&gt;
			&lt;artist&gt;Kanye West&lt;/artist&gt;
			&lt;title&gt;808s and Heartbreak&lt;/title&gt;
			&lt;albumyear&gt;2008&lt;/albumyear&gt;
		&lt;/album&gt;
		&lt;album&gt;
			&lt;artist&gt;Kanye West&lt;/artist&gt;
			&lt;title&gt;Graduation&lt;/title&gt;
			&lt;albumyear&gt;2007&lt;/albumyear&gt;
		&lt;/album&gt;
		&lt;album&gt;
			&lt;artist&gt;Nas&lt;/artist&gt;
			&lt;title&gt;Unartistd&lt;/title&gt;
			&lt;albumyear&gt;2008&lt;/albumyear&gt;
		&lt;/album&gt;
		&lt;album&gt;
			&lt;artist&gt;Notorious OST&lt;/artist&gt;
			&lt;title&gt;The Notorious B.I.G.&lt;/title&gt;
			&lt;albumyear&gt;2009&lt;/albumyear&gt;
		&lt;/album&gt;
&lt;/albums&gt;
</pre>
<pre class="brush: delphi;">

var
  AlbumData: XDocument;
begin
  // Load our XML Document with a System.Xml.Linq.XDocument
  AlbumData := XDocument.Load('../../albums.xml');

  // Query for albums in the year 2008
  var AlbumsLastYear := from Album in AlbumData.Descendants('album') where Album.Element('albumyear').Value = '2008' select Album;

  for Album in AlbumsLastYear do
  begin
    var s := String.Format('{0} - {1} ({2})', Album.Element('artist').Value, Album.Element('title').Value , Album.Element('albumyear').Value);
    lbFoundAlbums.Items.Add(s);
  end;
</pre>
<p> </p>
<p>Another new language feature that I like in principle but will completely admit to not fully understanding yet is <a href="http://prismwiki.codegear.com/en/Anonymous_Methods_and_Delegates">Anonymous Methods and Delegates</a> which make executing code with different threads much easier. Sadly in my brief testing of Anonymous methods I discovered that they are only available in projects which link to the .NET Framework 3.0 and above (and, in my case, only WPF projects). In order to execute our ListBox adding code from the first code sample as an Anonymous Delegate you can do the following:</p>
<pre class="brush: delphi;">
// Add the result to our listbox
for Album in AlbumsLastYear do
begin
  Dispatcher.Invoke(DispatcherPriority.ApplicationIdle, method(MyAlbum : MusicAlbum);
      begin
      lbFoundAlbums.Items.Add(MyAlbum.Artist + ' - ' + MyAlbum.Name + ' (' + MyAlbum.AlbumYear + ')');
      end, Album);
end;
</pre>
<p>This means that the compiler declares a delegate with a signature matching our anonymous method and we have now easily executed this code within a seperate thread with a minimum of code.</p>
<p>There are several new language features which I personally have no use for but which facilitate the use of the Microsoft Parallels framework such as <a href="http://prismwiki.codegear.com/en/Futures">Futures</a> and <a href="http://prismwiki.codegear.com/en/Sequences">Parallel sequences</a>. Delphi Prism also supports Generics and as well as most of the standard Delphi Win32 syntax.<br />
 <br />
There are also lots of small additions that aren&#8217;t .NET features per-se but demonstrate the usefulness of freeing the Prism compiler and allowing more rapid progression such as <a href="http://prismwiki.codegear.com/en/Boolean_Double_Comparison">Double Boolean Expressions</a>. I&#8217;m sure we&#8217;ve all written a statement like this before:<strong> if</strong> (cost > 400) <strong>and</strong> (cost < 600) <strong>then</strong>. In Delphi Prism this can also be written as: <strong>if</strong> 400 < cost < 600 <strong>then</strong>. </p>
<p>As I quickly discovered whilst going through the Delphi Prism Wiki: the language changes to Delphi Prism were easier to adapt to and to learn than I had originally imagined. The New language features gained mostly did not affect my coding style too much <strong>so any developers who were concerned that Delphi Prism is nothing like Delphi have nothing</strong> to worry about. Many of the new features are useful for compatibility with the .NET Framework and will be a natural fit for existing Delphi or .NET Developers</p>
]]></content:encoded>
			<wfw:commentRss>http://jamiei.com/blog/2009/01/new-language-features-in-delphi-prism/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Migrating a Project to Delphi Prism from Delphi.NET</title>
		<link>http://jamiei.com/blog/2008/12/migrating-a-project-to-delphi-prism-from-delphinet/</link>
		<comments>http://jamiei.com/blog/2008/12/migrating-a-project-to-delphi-prism-from-delphinet/#comments</comments>
		<pubDate>Sun, 21 Dec 2008 16:25:04 +0000</pubDate>
		<dc:creator>jamiei</dc:creator>
				<category><![CDATA[.NET General]]></category>
		<category><![CDATA[Delphi]]></category>
		<category><![CDATA[Delphi Prism]]></category>
		<category><![CDATA[Development]]></category>
		<category><![CDATA[Windows Development]]></category>
		<category><![CDATA[codegear]]></category>
		<category><![CDATA[delphi prism]]></category>
		<category><![CDATA[project conversion]]></category>
		<category><![CDATA[tips]]></category>

		<guid isPermaLink="false">http://jamiei.com/blog/?p=59</guid>
		<description><![CDATA[As we know, now that the future of Delphi.NET is Delphi Prism (based on the RemObjects Oxygene compiler) we have to migrate our Delphi.NET projects to be compatible with the Prism compiler. The Easiest way to get started is to look at the free Oxidizer tool provided on the RemObjects Wiki. The tool helps with [...]]]></description>
			<content:encoded><![CDATA[<p>As we know, now that the future of Delphi.NET is <a href="http://www.codegear.com/products/delphi/prism">Delphi Prism</a> (based on the <a href="http://www.remobjects.com">RemObjects Oxygene</a> compiler) we have to migrate our Delphi.NET projects to be compatible with the Prism compiler.<a href="http://www.codegear.com/products/delphi/prism"><img class="alignright" title="Codegear Delphi Prism Logo " src="http://www.codegear.com/article/38820/images/38820/prism.png" alt="" width="112" height="75" /></a></p>
<p>The Easiest way to get started is to look at the free <a href="http://prismwiki.codegear.com/en/Oxidizer">Oxidizer tool</a> provided on the <a href="http://prismwiki.codegear.com/en/Main_Page">RemObjects Wiki</a>. The tool helps with the conversion of Delphi Win32 projects to Delphi Prism (but I&#8217;m uncertain about how it performs on Delphi.NET to Delphi Prism). The Wiki is also an excellent place to get started, particularly the pages on <a href="http://prismwiki.codegear.com/en/Win32_Delphi_vs._Delphi_Prism">Delphi Win32 vs Delphi Prism</a> which list the major incompatibilities between the two languages. </p>
<p> </p>
<p>Whilst converting my Delphi.NET Library for accessing Twitter, I encountered a few basic hints and tips which I felt I should share here:</p>
<ul>
<li>You need to specify the <strong>namespace</strong> keyword at the top of your unit file instead of the <strong>unit</strong> keyword. The first time I tried to compile after doing this Prism still complained about not having a namespace keyword present, this was fixed by closing the solution and re-opening.</li>
<li>Delphi Prism automatically makes classes that are not explicitly marked otherwise as <strong>strict private</strong>. This meant that I had to go through my library and mark all classes that I wanted to make public. eg. <em>TMyClass = <strong>public </strong>class(System.Object);</em></li>
<li>The <strong>overload</strong> keyword isn&#8217;t neccesary as overloading is now implicit. This isn&#8217;t a problem at all and isn&#8217;t dificult to fix as it simply meant doing a Search and Replace for the overload keyword and removing it.</li>
<li><strong>TObject </strong>no long exists and instead needs to be replaced with <strong>System.Object</strong> which has much the same properties. </li>
<li>I encountered a few problems with the use of <strong>for .. in</strong> loops. It would seem that Delphi Prism loop variables are local to the loop and therefore should be declared at the beginning of the loop (see the <a href="http://prismwiki.codegear.com/en/For_(keyword)">for</a> wiki page for more info). In reality this meant changing: <strong><em>for </em></strong><em>strItem </em><strong><em>in</em></strong><em> list </em><strong><em>do </em><span style="font-weight: normal;">to<em> </em><strong><em>for </em></strong><em>strItem: string </em></span><em>in</em><span style="font-weight: normal;"><em> list </em><strong><em>do</em></strong> and then removing the </span>strItem: string; <span style="font-weight: normal;">declaration in the method var section.</span></strong></li>
<li>The <strong>TObject.Create([...]);</strong> constructor still exists however it is now <a href="http://prismwiki.codegear.com/en/New_(keyword)">recommended</a> that you switch to the <strong>new Object([..]) </strong>keyword for new projects. This may come as a shock to traditional Delphi&#8217;ers who have been <strong>.Create()</strong>&#8216;ing since the dawn of Borland but this is the construction method that sems to fit in with the .NET framework better. There is also a compatibility flag in the Project properties which allows the compiler to work some magic to allow .Create to continue to function.</li>
</ul>
<p>These are not the only changes that you will probably need to make but I found them to be a good starting point. You should definitely consult the <a href="http://prismwiki.codegear.com/en/Main_Page">Prism Wiki</a> for help in which I was able to find answers very quickly (no wading boots required!).</p>
<p>Lastly: My project could do with a lot of refactoring in order to take advatages of the unique language features of Prism. This will take considerably more time as it means learning the new language features first!</p>
]]></content:encoded>
			<wfw:commentRss>http://jamiei.com/blog/2008/12/migrating-a-project-to-delphi-prism-from-delphinet/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>A New Beginning for Delphi</title>
		<link>http://jamiei.com/blog/2008/11/a-new-beginning-for-delphi/</link>
		<comments>http://jamiei.com/blog/2008/11/a-new-beginning-for-delphi/#comments</comments>
		<pubDate>Sat, 15 Nov 2008 19:46:08 +0000</pubDate>
		<dc:creator>jamiei</dc:creator>
				<category><![CDATA[.NET General]]></category>
		<category><![CDATA[Delphi]]></category>
		<category><![CDATA[Development]]></category>
		<category><![CDATA[codegear]]></category>
		<category><![CDATA[.net]]></category>
		<category><![CDATA[delphi prism]]></category>
		<category><![CDATA[marketing]]></category>

		<guid isPermaLink="false">http://jamiei.com/wordpress/?p=40</guid>
		<description><![CDATA[Delphi programming is currently being rejuvenated on so many different levels. I was pleased to see that in the November 2008 TIOBE Index of Programming Languages Delphi shot up to 8th place (only .020% behind c#). I believe that this is partially on the excellent efforts of my good friend Jim McKeeth whose community herding has helped [...]]]></description>
			<content:encoded><![CDATA[<p>Delphi programming is currently being rejuvenated on so many different levels. I was pleased to see that in the <a href="http://www.tiobe.com/index.php/content/paperinfo/tpci/index.html">November 2008</a> TIOBE Index of Programming Languages Delphi shot up to 8th place (only .020% behind c#). I believe that this is partially on the excellent efforts of my good friend <a href="http://www.delphi.org">Jim McKeeth</a> whose community <a href="http://www.delphi.org/2008/10/delphi-language-of-the-year-2008/">herding</a> has helped out Delphi community to become more visible (&#8220;Delphi Programming&#8221; is simply not a phrase we were used to using!) and partially because of the excellent reviews and community <em>noise</em> that Delphi 2009 is receiving!</p>
<p><a href="http://www.codegear.com/products/delphi/prism">Delphi Prism</a> was announced finally at the Microsoft PDC where we discovered (or some of us) that Delphi Prism is the new Delphi .NET Development solution which drops the slightly crippled compatibility approach that Delphi used to employ and instead fits within the Visual Studio IDE. Delphi Prism now supports all the latest and greatest .NET technologies including WPF, LINQ and Various Language methods. They&#8217;ve achieved this by making use of the extremely cool <a href="http://www.remobjects.com">RemObjects</a> <a href="http://wiki.remobjects.com/wiki/Oxygene">Oxygene</a> Compiler which I would highly recommend that you investigate right away if you&#8217;re interested at all in .NET Development! I will be doing a post soon to discuss some of my favourite new Delphi Prism language features!</p>
<p> </p>
<p>This rejuvenation of Delphi is causing a product marketing effect and is slowly gathering momentum and I fully intend on doing whatever I can to generate enthusiasm for the Delphi Programming Community. This concept of User-led marketing has been widespread for many years as Apple fans will testify. As part of this I have a new project in mind for the Delphi community and will be explaining this in due course. I will certainly require Delphi enthusiasts to help with this venture, if you&#8217;re interested then please contact me.</p>
]]></content:encoded>
			<wfw:commentRss>http://jamiei.com/blog/2008/11/a-new-beginning-for-delphi/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
	</channel>
</rss>

<!-- Dynamic Page Served (once) in 0.550 seconds -->
