<?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>TURBU Tech &#187; Delphi</title>
	<atom:link href="http://tech.turbu-rpg.com/category/delphi/feed" rel="self" type="application/rss+xml" />
	<link>http://tech.turbu-rpg.com</link>
	<description>My thoughts on Delphi programming in general, and particularly on the technical aspects of developing the TURBU engine and editor.</description>
	<lastBuildDate>Wed, 01 Sep 2010 21:11:08 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>First look at Delphi XE</title>
		<link>http://tech.turbu-rpg.com/181/first-look-at-delphi-xe</link>
		<comments>http://tech.turbu-rpg.com/181/first-look-at-delphi-xe#comments</comments>
		<pubDate>Wed, 01 Sep 2010 05:41:01 +0000</pubDate>
		<dc:creator>Mason Wheeler</dc:creator>
				<category><![CDATA[Delphi]]></category>
		<category><![CDATA[Delphi XE]]></category>
		<category><![CDATA[Generics]]></category>
		<category><![CDATA[RTTI]]></category>

		<guid isPermaLink="false">http://tech.turbu-rpg.com/?p=181</guid>
		<description><![CDATA[This week&#8217;s just getting started, and it&#8217;s already had more than enough awesomeness to pack into a typical month.  The new version of Delphi came out yesterday.  Metroid: Other M and The Way of Kings, a new Brandon Sanderson book, were both released today.  (I have a feeling I&#8217;m going to be more distracted than [...]]]></description>
			<content:encoded><![CDATA[<p>This week&#8217;s just getting started, and it&#8217;s already had more than enough awesomeness to pack into a typical month.  The new version of Delphi came out yesterday.  <em>Metroid: Other M</em> and <em>The Way of Kings,</em> a new <a href="http://tvtropes.org/pmwiki/pmwiki.php/Main/BrandonSanderson">Brandon Sanderson</a> book, were both released today.  (I have a feeling I&#8217;m going to be more distracted than usual for a while&#8230;) But as awesome as Metroid games and anything by Sanderson tend to be, (if you&#8217;re into fantasy <em>at all</em>, check out <a href="http://www.amazon.com/Elantris-Brandon-Sanderson/dp/0765350378/">Elantris</a> and <a href="http://www.amazon.com/Mistborn-Trilogy-Boxed-Brandon-Sanderson/dp/076536543X">Mistborn</a> and prepare to be blown away,) this is a programming blog, and I&#8217;m supposed to be talking about Delphi.  So here&#8217;s the good, the bad, and the annoying about my first impressions with Delphi XE.</p>
<p><span id="more-181"></span>The first thing I knew about the release was when I received my SA email yesterday afternoon, as opposed to having to wait a few days or even weeks to get my upgrade as has happened in previous years.  Big improvement there, and I hope Embarcadero keeps it up for subsequent releases. <strong>Good.</strong></p>
<p>No OSX support, which we all thought was going to be in this release up until a few weeks ago. <strong>Bad.</strong> But it&#8217;s not there because the people at Embarcadero preferred to focus on quality and not release something that wasn&#8217;t ready. <strong>Good.</strong> No one wants to see (or pay for) another D8.</p>
<p>So I open it up and start browsing through some code.  My settings from D2010 didn&#8217;t get migrated forward. <strong>Annoying.</strong> There really should be some way to import them as part of the installation process.</p>
<p>ErrorInsight is the same old same old, with false positives all over the place because it can&#8217;t find basic standard library units. <strong>Annoying.</strong> But at least it doesn&#8217;t choke on methods of objects from a generic list anymore. <strong>Good.</strong></p>
<p>Speaking of Generics, huge improvement here.  I was able to go through my codebase and remove all the annoying workarounds for generics-related glitches, and it compiles and runs properly now! <strong>Good.</strong></p>
<p>When it&#8217;s time to debug, I immediately noticed a few improvements.  We finally, finally, after all these years, have debug DCPs available for the standard libraries.  (For those not familiar with them, DCPs are to Delphi packages as DCUs are to units.)  That means that people like me who build stuff with packages are able to trace into the RTL when debugging.  <strong>Good.</strong></p>
<p>Also, something that always drove me up the wall about the debugger has been fixed.  When you put the cursor in an expression and hit CTRL-F7, it pops up the Evaluate/Modify window and evaluates whatever you had the cursor on.  But if you moved the cursor and hit CTRL-F7 again without closing the Evaluate/Modify window, it would focus the Evaluate/Modify window, but it wouldn&#8217;t evaluate the new expression you had selected.  You&#8217;d have to close the window and hit CTRL-F7 again to get a new evaluation.  (Or copy/paste or type it in, of course.)  That always bugged me, but it&#8217;s been fixed in XE.  <strong>Good.</strong></p>
<p>And while we&#8217;re on the subject of Evaluate/Modify, you can now select more than whatever the limit used to be (80 characters?) and have your entire selection copied when you hit CTRL-F7. <strong>Good.</strong></p>
<p>But while poking around in there, I found a new way to crash the IDE.  Try to evaluate a call that will open a form, and it locks up Evaluate/Modify.  Then hit CTRL-F2 to kill the debugger, and it brings the whole program down. <strong>Bad.</strong> (Not sure if this was in earlier versions, though. I&#8217;ve never run across it before.)</p>
<p>Oh, there&#8217;s a new regular expression library in the RTL.  Some people will probably find this a good thing.  I personally see it as <strong>Annoying.</strong> Delphi code is supposed to be easy to read.  That&#8217;s an explicit design goal going all the way back to Wirth.  But PCREs are anything but, and having it right there in the standard library will just encourage people to use them in code that I might end up having to debug some day.</p>
<p>In addition to Generics bugs getting cleaned up, the Generics.Defaults and Generics.Collections units got a bit of polish.  There were some minor tweaks to speed up various low-level comparison functions in Generics.Defaults.  Over in Generics.Collections, all the collections have gained a ToArray method, TStack&lt;T&gt; and TQueue&lt;T&gt; gained a Capacity, and there&#8217;s a new TThreadedQueue&lt;T&gt; class that looks a lot like the <a href="http://17slon.com/blogs/gabr/2010/01/three-steps-to-blocking-collection-1.html">Blocking Collection</a> that Primoz Gabrijelcic set up for OmniThreadLibrary, only without all the Omni stuff.  These new features look <strong>Good.</strong></p>
<p>The Math unit has been given overloads for Single, Double and Extended precision versions of just about all its calculation routines, which is <strong>Good</strong> because there&#8217;s no more implicit conversions to introduce rounding errors.  However, I had this bite me when compiling some code at work.  Someone was passing an array of integers to Math.Sum, which worked before, but now the compiler gave an ambiguous overload error for that. <strong>Annoying,</strong> but not too hard to fix, since there&#8217;s a SumInt function right after Sum.  Not sure why the original author of this code didn&#8217;t use it in the first place.  Oh well&#8230;</p>
<p>In RTTI.pas, there&#8217;s a new class called TMethodImplementation.  You create it and give it data that describes the signature of a method, then pass it an anonymous method that takes an array of TValues and returns a TValue, and it creates a little thunk of machine code that builds a function with the correct signature that invokes your anonymous method.  Very cool, lots of potential&#8230; except that you can&#8217;t use it.  The constructor&#8217;s private, and there&#8217;s a public constructor that raises an exception, so you can&#8217;t get at it via TObject.Create.  It&#8217;s apparently for internal use only.  <strong>Annoying.</strong> I asked Allen Bauer about this, and he said that it&#8217;s because they weren&#8217;t sure they had the final form of the class worked out yet, and they didn&#8217;t want to make it publicly available yet in a form that they&#8217;d end up having to preserve and support forever afterwards.</p>
<p>There&#8217;s also a new class called TVirtualMethodInterceptor that <em>is </em>publicly available, and uses TMethodImplementation internally to allow you to replace virtual methods on a class.  I&#8217;m a bit curious as to what this is useful for, but apparently the team thought it was good for something, because a lot of work went into setting it up. <strong>Good?</strong></p>
<p>Oh, and apparently certain aspects of the compiler have slowed down.  Most things will compile about the same speed or even a little faster, but for really large projects (millions of lines) with complex interdependencies between units, you&#8217;ll notice some slowdown, and it&#8217;ll apparently get worse the larger your project is.  I timed it at work, on a project of about 3.5 million lines of code.  It builds in about 2 minutes on D2010, closer to 3 minutes on XE.  <strong>Bad,</strong> but still a heck of a lot better than the C family could do.  And apparently it has something to do with making Generics work right, so I can tolerate that.  Hopefully they&#8217;ll find some way to regain some of that lost speed in updates, though.</p>
<p>Oh, and there are little {$IFDEF POSIX} and {$IFDEF MACOS} tags scattered throughout the RTL and VCL, even more than there were in Delphi 2010.  This is <strong>Good</strong> if you&#8217;re looking forward to OSX or Linux cross-platform development in the next release(s).  I haven&#8217;t seen any 64-bit ifdefs, but that could be because it doesn&#8217;t require much change at the Pascal level, the way a completely different OS platform does. (UPDATE: According to PhiS, there&#8217;s a lot of {$IFDEF CPUX64} tags in System.pas.  I was poking around the libraries with BeyondCompare last night but I didn&#8217;t bother to look in there because I knew that, with all the cross-platform stuff and all the ASM they&#8217;ve got in System.pas, the diff view would be a big, confusing mess no matter what.)</p>
<p>Well, it&#8217;s getting late and I haven&#8217;t had time to dig through too much of the new stuff yet, (and with a new 1000-page novel and a new video game, it might be a while,) but overall this is looking like a pretty good release.  Not a huge leap forward like the last two were, but a lot of polish and incremental improvements.  I think this is going to be a pretty good release overall.</p>
]]></content:encoded>
			<wfw:commentRss>http://tech.turbu-rpg.com/181/first-look-at-delphi-xe/feed</wfw:commentRss>
		<slash:comments>18</slash:comments>
		</item>
		<item>
		<title>The insanities of roadmap publishing</title>
		<link>http://tech.turbu-rpg.com/176/the-insanities-of-roadmap-publishing</link>
		<comments>http://tech.turbu-rpg.com/176/the-insanities-of-roadmap-publishing#comments</comments>
		<pubDate>Wed, 25 Aug 2010 20:55:30 +0000</pubDate>
		<dc:creator>Mason Wheeler</dc:creator>
				<category><![CDATA[Delphi]]></category>
		<category><![CDATA[DelphiLive!]]></category>

		<guid isPermaLink="false">http://tech.turbu-rpg.com/?p=176</guid>
		<description><![CDATA[Last night at DelphiLive they had a &#8220;Meet the team&#8221; event in one of the halls, where most of the RAD Studio development team was present and the attendees could hang out and chat with them.  While I was there, I talked with Mike Rozlog a bit.  He&#8217;d seen some of the critical things I [...]]]></description>
			<content:encoded><![CDATA[<p>Last night at DelphiLive they had a &#8220;Meet the team&#8221; event in one of the halls, where most of the RAD Studio development team was present and the attendees could hang out and chat with them.  While I was there, I talked with Mike Rozlog a bit.  He&#8217;d seen some of the critical things I wrote on here and on the forums about the roadmap, and he explained to me a bit about how the process of making a roadmap works.  One thing to keep in mind is that he told me it&#8217;s like this everywhere  he&#8217;s worked.  What I&#8217;m about to describe is apparently not a symptom of  dysfunctional corporate culture at Embarcadero; more like dysfunctional corporate culture in general.<span id="more-176"></span>Apparently, due to really complicated business-related reasons that I didn&#8217;t understand well enough to explain here, producing an official roadmap for a commercial product almost invariably has to be signed off on by anyone and everyone with any degree of decision-making authority.  This might be a bit inaccurate, but the impression I got is that it&#8217;s kinda like getting Congress to pass a law, except that each individual Congressman has not only a vote, but veto power as well!</p>
<p>They&#8217;d have something almost ready, and then person A says &#8220;No, we can&#8217;t do this, we shouldn&#8217;t have X on there, it needs to be Y instead,&#8221; so they take X off and replace it with Y.  Then person B looks at it and says, &#8220;hey, what happened to X? That was <em>critical</em>!&#8221;  So Mike has to explain that it was removed because of person A, and get those two in a room together where they can discuss it and work out a compromise, and then they update the roadmap so it says XY.  And then of course, person C comes by and says, &#8220;hey, what&#8217;s with all this X stuff in there? I thought we took it out, because we won&#8217;t be able to get it implemented on this schedule!&#8221; And it&#8217;s back to square one.</p>
<p>Repeat a few dozen times, over a period of a few months, until finally they reach the Ultimate Compromise that everyone can bring themselves to agree upon, and then they finally publish the new version.  That&#8217;s the easy part.  Once everyone&#8217;s signed off on it, it takes about five minutes to get it posted to embarcadero.com.  He said that he&#8217;d have liked to publish the updated roadmap before the XE sneak previews started, but that just wouldn&#8217;t have worked on the timetable they had.  It was a real eye-opener, talking with him about the process.  It makes the roadmaps being the way they are a bit more understandable.</p>
<p>Mike also mentioned that a lot of people, including himself, don&#8217;t like the &#8220;PowerPoint slide&#8221; format that the last few roadmaps have been done in, and the next one will probably be done a different way.  Of course, working out what the new format will look like will be another long round of negotiations and compromises&#8230;</p>
<p>Again, apparently this is all completely normal for trying to publish a roadmap for a commercial product.  What do you guys think?  Has anyone out there been in a similar situation?  Are roadmaps always that messy, or has Mike just had a run of bad luck?</p>
]]></content:encoded>
			<wfw:commentRss>http://tech.turbu-rpg.com/176/the-insanities-of-roadmap-publishing/feed</wfw:commentRss>
		<slash:comments>11</slash:comments>
		</item>
		<item>
		<title>Delphi Live: RAD Studio XE launch</title>
		<link>http://tech.turbu-rpg.com/174/delphi-live-rad-studio-xe-launch</link>
		<comments>http://tech.turbu-rpg.com/174/delphi-live-rad-studio-xe-launch#comments</comments>
		<pubDate>Tue, 24 Aug 2010 19:16:39 +0000</pubDate>
		<dc:creator>Mason Wheeler</dc:creator>
				<category><![CDATA[Delphi]]></category>
		<category><![CDATA[DelphiLive!]]></category>

		<guid isPermaLink="false">http://tech.turbu-rpg.com/?p=174</guid>
		<description><![CDATA[I just attended the Delphi Live keynote address by several members of the Embarcadero team.  They used the term &#8220;RAD Studio XE launch&#8221; a few times, but it&#8217;s not available for sale just yet, and they didn&#8217;t announce a release date.  But the feeling was that it&#8217;ll be for sale very soon, within a week [...]]]></description>
			<content:encoded><![CDATA[<p>I just attended the Delphi Live keynote address by several members of the Embarcadero team.  They used the term &#8220;RAD Studio XE launch&#8221; a few times, but it&#8217;s not available for sale just yet, and they didn&#8217;t announce a release date.  But the feeling was that it&#8217;ll be for sale very soon, within a week or two.  I saw a few people filming it, including Jim McKeeth, who put videos of a few sessions from last year up on his blog, so we&#8217;ll probably end up seeing it on Delphi.org soon enough.  But I&#8217;ll recount a few of the highlights here.<span id="more-174"></span></p>
<p>David I showed a fortune from a fortune cookie he got at a Chinese retaurant just last week.  &#8220;You will do well in the field of computer technology.&#8221;  With the release of the new Delphi just days away, let&#8217;s hope it turns out to be true.</p>
<p>Michael Swindell, one of the top executives at Embarcadero, gave some very interesting numbers.  Out of an estimated 16 million total programmers worldwide, 1.7 million are using Delphi.  More than 10%!  So you&#8217;re not alone, even when all the C# and Java people try to make you feel like you are.  I found this particularly interesting because last year, when I was on the phone with Emb. tech support for an installation hiccup with D2010, I was chatting with the rep and I asked him if he knew how many people were actually using Delphi.  He basically said that that was a trade secret of Embarcadero&#8217;s and he could lose his job if he told me that.  Looks like perspectives have changed somewhat, and for the better IMO.</p>
<p>Michael also mentioned that even with the economic downturn, Delphi&#8217;s grown pretty significantly last year, including the biggest increase in upgrades from D7 ever.  He attributed this specifically to their strong commitment to quality, which was the main reason behind the much-maligned OSX compiler schedule slip.  I don&#8217;t remember if it was him or Allen Bauer, who spoke a little later, but one of them said specifically that they have a working OSX compiler and OSX-ready VCL, that they could have shipped, but it wasn&#8217;t good enough to meet their quality standards so they held it back.  They&#8217;re really trying to avoid another Kylix or Delphi 8 style disaster, and they seem pretty sincere about it.</p>
<p>Probably the most exciting thing that Michael Swindell said was that they&#8217;re starting to aggressively market to schools again, &#8220;from universities down to middle schools,&#8221; trying to get Delphi into classrooms and into students&#8217; hands, at the sort of prices that schools and students can afford, including some way (not many details on this) for students to use Delphi for free for educational purposes.  It&#8217;s good to hear some public recognition that new blood is very important to the heath of the Delphi community and that they&#8217;re working on targeting the low end of the market again.  Borland sent Delphi into a decline by being far too enterprise-oriented, and that attitude seems to have gotten inherited, and it&#8217;s good to see that they&#8217;re starting to really see past that now.</p>
<p>Tony de la Lama, the VP of R&amp;D, mentioned that they&#8217;re putting a lot of emphasis within the company on actually doing new development in Delphi.  Before, a lot of it was built on other products and with other languages, but they&#8217;re moving towards using Delphi internally a lot more.</p>
<p>One complaint that I&#8217;ve heard raised several times since the launch of Delphi 2010 was about how DataSnap servers were crippled, or at least less useful than they could be, because there&#8217;s no built-in support for encryption.  That&#8217;s being remedied in XE, with a couple different encryption modes out of the box and a way to add other filters if necessary.</p>
<p>Also, I got an answer to a question that a lot of people have been asking about the XE previews.  I don&#8217;t know if they&#8217;ve answered this one before, but if they have I haven&#8217;t seen it yet.  A big part of the new functionality in XE will be bundled third-party software.  I asked at the end which products would be with which editions, and the answer was basically that all the new products they&#8217;ve been demoing would be in the Professional edition, except for FinalBuilder, which would be in Enterprise and above.</p>
<p>There was more, but those are the points that really stuck out to me.  Delphi XE may not be everything that everyone wanted or expected, but it looks like a pretty solid release and the team definitely has their heads on straight.  I think they&#8217;re really taking things in the right direction, much more so than in past years, and I&#8217;m (cautiously) optimistic about the future.  They presented a lot of really good plans.  We&#8217;ll see how they work out.</p>
]]></content:encoded>
			<wfw:commentRss>http://tech.turbu-rpg.com/174/delphi-live-rad-studio-xe-launch/feed</wfw:commentRss>
		<slash:comments>15</slash:comments>
		</item>
		<item>
		<title>Code Review: a &#8220;pretty good practice&#8221;</title>
		<link>http://tech.turbu-rpg.com/170/code-review-a-pretty-good-practice</link>
		<comments>http://tech.turbu-rpg.com/170/code-review-a-pretty-good-practice#comments</comments>
		<pubDate>Thu, 19 Aug 2010 03:49:54 +0000</pubDate>
		<dc:creator>Mason Wheeler</dc:creator>
				<category><![CDATA[Delphi]]></category>

		<guid isPermaLink="false">http://tech.turbu-rpg.com/?p=170</guid>
		<description><![CDATA[What with recent events and all, it doesn&#8217;t look like Nick Hodges is going to get around to finishing up his Pretty Good Practices series anytime soon.  So I hope he doesn&#8217;t mind if I post one of my own. Code Review is a very useful principle for keeping bugs out of the codebase.  At [...]]]></description>
			<content:encoded><![CDATA[<p>What with recent events and all, it doesn&#8217;t look like Nick Hodges is going to get around to finishing up his Pretty Good Practices series anytime soon.  So I hope he doesn&#8217;t mind if I post one of my own.</p>
<p>Code Review is a very useful principle for keeping bugs out of the codebase.  At work we&#8217;ve got a rule which is (usually) followed pretty strictly: Any non-trivial change that might affect functionality needs to be reviewed by another developer before checkin.  Usually this is just a &#8220;rubber stamp&#8221; sort of thing.  You pull up a diff view against the source control version in Beyond Compare and show the other guy what you changed, he says &#8220;OK, looks good, go ahead and check it in,&#8221; and you go ahead and check it in.  But every once in a while they&#8217;ll catch something.<span id="more-170"></span></p>
<p>It can be just about anything, from debug code (commented out or left active) still in the code you wrote, to formatting problems that make it harder to read, to &#8220;I really think you could do this better if you were to change X and Y&#8221;, or even &#8220;that looks like it won&#8217;t work if the user does X.&#8221;  Occasionally the reviewer will even catch a syntax error that would have broken the build if you&#8217;d checked it in, either because you didn&#8217;t test it by compiling first or because you forgot to save your latest changes in the IDE.</p>
<p>It happens to everyone.  I&#8217;ve found all of these issues in my coworkers&#8217; code, and had them find all of them in mine, at one point or another.  And when these sorts of things do get caught before going into the official codebase, it improves the quality of your program.  This is basically a small-scale version of <a href="http://en.wikipedia.org/wiki/Linus's_Law">Linus&#8217;s Law</a>.</p>
<p>But a formal code review is not the only way to apply the principle.  You can catch a lot just by reviewing your own code, especially in a diff viewer like Beyond Compare.  Seeing what&#8217;s changed highlighted in red gives you a slightly different perspective than just looking at the ordinary code view, and sometimes it brings a mistake to your attention.  I usually check the diffs myself at work before asking a coworker for a review, and I always check diffs before checking any code in to the TURBU project repository.</p>
<p>Independent review can also be useful in actually finding the problem you&#8217;re trying to solve.  Maybe once or twice a month, I get a &#8220;hey Mason, can you come look at this code with me?  I need another pair of eyeballs&#8221; request from someone at work.  Sometimes I can help track it down, sometimes I can&#8217;t, and sometimes I just provide a useful suggestion.</p>
<p>I remember one time someone asked me to help track down a data corruption issue.  When I started looking at the code, it was a really ugly implementation of an array-based stack that someone else had written long ago, using pointers and GetMem/ReallocMem calls all over the place.  Looked like something straight out of my Data Structures class in college.  We&#8217;ve got a joke at work that <a href="http://www.pbm.com/~lindahl/real.programmers.html">a bad programmer can write C in any language</a>, and that&#8217;s exactly what this looked like: someone writing C in Delphi.</p>
<p>At least there was a well-defined interface encapsulating this whole mess, so I said &#8220;I don&#8217;t think I can trace this very well, but it&#8217;s probably an out-of-bounds issue.  Any good reason why you couldn&#8217;t rewrite this with Delphi&#8217;s dynamic arrays and let Bounds Checking find the error for you?&#8221;  He did, and sure enough the problem became obvious real quickly.  It was trying to do a Pop on an empty stack at one point, and the debugger pointed out exactly where once the compiler was able to apply error checking to the problem.</p>
<p>Reviewing your code, and having someone else review it if possible, is a good way to catch bugs that might end up slipping into the codebase unnoticed otherwise, and it can also be helpful a lot of times to track down tricky errors if someone else is watching the debugger with you.  If you don&#8217;t do it in your development work, try it and see if it makes a difference.  It&#8217;s sorta like a seatbelt.  Most of the time it won&#8217;t do much for you, but when it does it&#8217;s very helpful.</p>
]]></content:encoded>
			<wfw:commentRss>http://tech.turbu-rpg.com/170/code-review-a-pretty-good-practice/feed</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>New tools for Delphi XE</title>
		<link>http://tech.turbu-rpg.com/167/new-tools-for-delphi-xe</link>
		<comments>http://tech.turbu-rpg.com/167/new-tools-for-delphi-xe#comments</comments>
		<pubDate>Tue, 17 Aug 2010 18:39:33 +0000</pubDate>
		<dc:creator>Mason Wheeler</dc:creator>
				<category><![CDATA[Delphi]]></category>

		<guid isPermaLink="false">http://tech.turbu-rpg.com/?p=167</guid>
		<description><![CDATA[The second sneak preview is out now.  It&#8217;s quite a bit more interesting than the first one.  FinalBuilder being added to the package will make it a lot easier for me to get builds set up for the TURBU project.  Right now I have to do it all by hand.  So far I haven&#8217;t missed [...]]]></description>
			<content:encoded><![CDATA[<p>The <a href="http://www.embarcadero.com/rad-studio-xe-preview">second sneak preview</a> is out now.  It&#8217;s quite a bit more interesting than the first one.  FinalBuilder being added to the package will make it a lot easier for me to get builds set up for the TURBU project.  Right now I have to do it all by hand.  So far I haven&#8217;t missed a step and ended up releasing it, but if there&#8217;s a way to reduce the chance of that happening in the future I&#8217;d definitely appreciate it.  I just wonder if it&#8217;ll be in all editions or just the higher-level SKUs.</p>
<p>Then they mentioned AQTime, which looked interesting but IMO brings up more questions than it answers.  For example, &#8220;Since this is the standard edition, not all of the profilers are enabled.&#8221; (9:13)  But I don&#8217;t see any of the profilers on that list grayed out.  And again, will this be in all editions, or just the high-level ones?</p>
<p>Also, will it come with an extension to the Open Tools API to allow other profilers to be integrated?  AQTime has some great features, but its core feature, performance profiling, uses instrumenting that slows your app down horribly, which makes it unsuitable for a lot of uses.  I prefer Sampling Profiler, which gives a good picture of what you&#8217;re spending your time doing without instrumenting your program.  It doesn&#8217;t provide the perfect counting accuracy that instrumenting does, but most of the time you don&#8217;t actually need that anyway in order to track down performance problems.  If there was a way to integrate Sampling Profiler into Delphi, it would make a good compliment to AQTime&#8217;s other profilers.</p>
<p>As for CodeSite, I don&#8217;t have too much to say about that, because I don&#8217;t know enough about how it works to discuss it very well.  Logging&#8217;s definitely useful, but usually in different ways than what they were demonstrating on the video.  For example, if CodeSite can only output to that popup window, it&#8217;s worthless IMO.  But if it can write to a file, or better yet if it allows you to create and register custom outputs of some kind, that would be a big help.</p>
<p>The one thing I&#8217;m a bit worried about is price.  Delphi&#8217;s got three general problems, which need to be resolved independently.</p>
<ol>
<li>Missing features.  No 64-bit, no cross-platform, no data binding, no LINQ, etc.</li>
<li>Bugs and quality issues.  Glitchy generics, *Insight, the helpfiles, etc.</li>
<li>Price.  No explanation needed</li>
</ol>
<p>Delphi 2011&#8242;s main point was supposed to be addressing a missing feature.  That ended up not happening, as the team members have been explaining, because they don&#8217;t have enough time to get it working at a good quality level.  That&#8217;s definitely a praiseworthy attitude, but I&#8217;m a bit worried at seeing all these expensive third-party tools being suddenly announced as part of the product.  They don&#8217;t actually do anything to solve the three main problems facing Delphi, and I&#8217;m a bit worried that they&#8217;ll end up taking the price even higher.</p>
<p>They&#8217;ve mentioned their commitment to quality several times, and specifically that they&#8217;ve done a lot of work to fix the generics issues.  That&#8217;s great, and if they&#8217;ve allocated some resources to getting a Error Insight and Code Completion working properly that&#8217;ll be even better.  But even so, not having the main missing feature we were expecting would be delivered is going to do a lot to reduce the perceived quality of the release, even if the objective quality has gone up quite a bit since D2010.  Quality improvements are generally expected to be part of an update, not a new release.  (The &#8220;I paid good money for this with the expectation that the promised features would actually work&#8221; argument.)</p>
<p>I really hope I&#8217;m interpreting this wrong, but what it looks like to me is that in order to avoid the new version being perceived as &#8220;just a bugfix release&#8221; that isn&#8217;t worth the price, Embarcadero decided to bundle a bunch of expensive tools to make it appear to be more worth the cost.  If that&#8217;s what they&#8217;re doing, there are two ways to do it, and both will hurt them.  Either the price stays about the same as it was for D2010, but they&#8217;re paying a share of it to the owners of AQTime, FinalBuilder, etc, so they lose a lot of revenue, or they pass that cost along to us, the price goes up, (without delivering the anticipated new feature,) and a lot of people end up not wanting to buy it at that price, so they lose a lot of revenue.</p>
<p>What I would prefer, and what I would do if it was my product, is to negotiate some sort of deal with the creators of these other products where people who buy Delphi XE can pick them up at a discount, and then sell the actual Delphi license to us at a reduced price.  That would help improve sales, or at the very least help stem the loss of sales resulting from not having cross-platform available, and no one ends up paying for add-on products they don&#8217;t need.  (And not everyone will need them.  Where I work we&#8217;ve got a bunch of developers and one build machine.  If we all got a copy of FinalBuilder&#8230; what would we do with it?)</p>
<p>I really hope I&#8217;m wrong about this, but this is what it looks like Embarcadero is doing.  I just wish they wouldn&#8217;t, since I don&#8217;t think it will actually be good for Delphi users, or for Delphi itself.</p>
]]></content:encoded>
			<wfw:commentRss>http://tech.turbu-rpg.com/167/new-tools-for-delphi-xe/feed</wfw:commentRss>
		<slash:comments>9</slash:comments>
		</item>
		<item>
		<title>Why the new roadmap won&#8217;t impress anyone</title>
		<link>http://tech.turbu-rpg.com/164/why-the-new-roadmap-wont-impress-anyone</link>
		<comments>http://tech.turbu-rpg.com/164/why-the-new-roadmap-wont-impress-anyone#comments</comments>
		<pubDate>Wed, 11 Aug 2010 01:44:27 +0000</pubDate>
		<dc:creator>Mason Wheeler</dc:creator>
				<category><![CDATA[Delphi]]></category>

		<guid isPermaLink="false">http://tech.turbu-rpg.com/?p=164</guid>
		<description><![CDATA[Well, Embarcadero has started to release some previews for Delphi 2011 XE, and what&#8217;s been released so far doesn&#8217;t show any obvious indications that the cross-platform features everyone was expecting will actually be present in this release.  Some people on the forums immediately interpreted absence of evidence as evidence of absence and started a big [...]]]></description>
			<content:encoded><![CDATA[<p>Well, Embarcadero has started to release some previews for Delphi <span style="text-decoration: line-through;">2011</span> XE, and what&#8217;s been released so far doesn&#8217;t show any obvious indications that the cross-platform features everyone was expecting will actually be present in this release.  Some people on the forums <a href="https://forums.embarcadero.com/thread.jspa?threadID=41288">immediately interpreted absence of evidence as evidence of absence</a> and started a big to-do about it.</p>
<p><span id="more-164"></span>The interesting thing here is that people from Embarcadero are responding immediately.  And it&#8217;s interesting what they&#8217;re saying, and what can be read between the lines.  We won&#8217;t know anything for certain until an official announcement is made, but it&#8217;s sure starting to sound like the cross-platform features got delayed for whatever reason and are still in active development but won&#8217;t be in Delphi XE.<br />
Embarcadero&#8217;s Allen Bauer and John Kaster have both announced that they&#8217;re working on a new, updated roadmap that will be posted within a few days.  I haven&#8217;t seen it yet, but I already think it won&#8217;t really reassure or impress anybody.I can&#8217;t speak for everyone, or really for anyone but myself, but I tend to<br />
be pretty good at reading people and particularly at reading groups of people, and from what I&#8217;ve seen, this new roadmap will strike most people in the Delphi community as rather underwhelming no matter what&#8217;s in it, not because of what it contains, but because of what it lacks.</p>
<p>The roadmap that would get people excited&#8211;the one that Embarcadero is never going to release, of course, because of the everpresent, nebulous, but all-important &#8220;business reasons&#8221; that always get in the way of doing stuff like this right&#8211;would replace the weasel words in slide 3 of <a href="http://edn.embarcadero.com/article/39934">the current roadmap</a>.</p>
<p>If they were to lose the following:</p>
<blockquote><p>This information describes Embarcadero&#8217;s general product<br />
direction at this time, and should not be relied on in making a<br />
licensing decision.  The future development, release and timing<br />
of features and functionality remains at our sole discretion and<br />
may be changed at any time without notice.</p></blockquote>
<p>&#8230;and replace it with something like this:</p>
<blockquote><p>This information describes Embarcadero&#8217;s commitment to the<br />
Delphi community, the features that we *will* produce for the<br />
next releases, and a concrete schedule that we are 100%<br />
committed to meeting or surpassing.</p></blockquote>
<p>&#8230;can you imagine the reaction?!?  It would finally give us something we&#8217;ve been sorely missing for the better part of a decade: a company behind Delphi that we know &#8220;gets it.&#8221;</p>
<p>Remember what Windows development used to be like before Delphi?  Delphi was the great innovator in programming, back in the day.  It was light-years ahead of VB, or any flavor of C++ for that matter.  Then Delphi 8 came along, and the message it gave everyone is, &#8220;.NET is the future and we can&#8217;t get it right.&#8221;  From that point on, Borland was dropping the ball on every occasion possible.  You&#8217;d think <a href="http://en.wikipedia.org/wiki/Murphy%27s_Law">Murphy </a>himself was running the company, and overseeing the development tools division personally.</p>
<p>Quality plummeted.  Delphi 8 was a joke, and 2005 and 2006 were scarcely better.  D2007 was tolerable, but that&#8217;s the best I can say about it.  We&#8217;re still waiting on 64-bit, which Dephi The Great Innovator, had it existed at the time, would have had ready and working no later than 2004.  And Borland managed to pretty much eradicate the community&#8217;s trust.  Then they sold off the dev tools division to Embarcadero, and we thought, &#8220;finally!  Delphi in the hands of a company that really &#8216;gets it&#8217; again.&#8221;  But so far that&#8217;s only been half true.</p>
<p>The quality improvements have been immense.  For the first time since D7, Delphi 2009 gave us a solid IDE that was not downright <em>painful</em> to use.  (As long as you didn&#8217;t try to use Code Completion, or hit F1.)  Generics, anonymous methods, Unicode and extended RTTI have been major steps forward, but Delphi The Great Innovator is gone.</p>
<p>Borland fumbled and gave Microsoft 4 free years to work on Visual Studio and the .NET languages, and C# has gone from an utter joke, (&#8220;let&#8217;s take people from the Delphi team and have them rewrite Delphi in Java syntax, and leave out half the stuff that makes Delphi worth working with because we can&#8217;t implement them without stepping in Borland&#8217;s patents, but that&#8217;s all right because it&#8217;s Backed By Microsoft™ so everyone will use it anyway,&#8221;) to an industry-leading language.  Borland let that happen, Embarcadero inherited their mess, and we&#8217;re playing catch-up now.  And until we have working compilers for Windows, OSX and Linux, in 32-bit and 64-bit flavors, a helpfile that&#8217;s actually complete and doesn&#8217;t suck, *Insight that actually works and doesn&#8217;t suck, and some form of LINQ and some form of concurrency support at the language level, (that actually work and don&#8217;t suck,) we&#8217;re going to be stuck playing catch-up.</p>
<p>While the team under Embarcadero has made excellent progress in improving the quality of Delphi, they&#8217;ve done little to nothing to rebuild trust in the Delphi community.  The recent dual PR nightmares from firing Nick Hodges and the huge mess that the forum mods made of the whole Simon Kissel thing, it creates the sense that nothing has changed, that there&#8217;s still a bunch of PHBs undermining the team&#8217;s efforts.  And that brings me back to the roadmaps.  Apparently Borland had to talk in this sort of weasel words and say how they couldn&#8217;t really say anything until the product was ready to ship.  Had something to do with being a publicly traded company.  Well, that&#8217;s one anchor that Embarcadero doesn&#8217;t have around their necks.</p>
<p>Embarcadero is not a publicly traded corporation.  They aren&#8217;t beholden to a bunch of morons on Wall Street who only care about stock price and don&#8217;t know a thing about producing good development tools.  They aren&#8217;t bound by a lot of the laws and financial regulations that govern the behavior of publicly traded companies.  So why does it feel so much like they&#8217;re still doing business by Borland&#8217;s rules?</p>
<p>If Embarcadero wants to regain the trust of the Delphi community, it has to give us something to base that trust on.  A firm schedule with a  firm commitment behind it would do absolute wonders, and IMO the commitment would be even more important than the actual content of the roadmap.  Even if it said &#8220;x64 will be available in 2016,&#8221; if there was a firm date and we didn&#8217;t have to wonder if it would be here in 2012 or 2035 or <em>ever</em>, that would take a huge load off a lot of people&#8217;s shoulders.  (Including, I&#8217;d imagine, the shoulders of a lot of the engineers on the Delphi team!)</p>
<p>But of course, Embarcadero isn&#8217;t going to do that, are they?  They&#8217;re going to release another roadmap that says, right in the document itself, that we can&#8217;t actually trust what it says.  And then they&#8217;re going to wonder why the developers don&#8217;t seem to trust what they say&#8230;</p>
]]></content:encoded>
			<wfw:commentRss>http://tech.turbu-rpg.com/164/why-the-new-roadmap-wont-impress-anyone/feed</wfw:commentRss>
		<slash:comments>51</slash:comments>
		</item>
		<item>
		<title>Generics and the Covariance Problem</title>
		<link>http://tech.turbu-rpg.com/149/generics-and-the-covariance-problem</link>
		<comments>http://tech.turbu-rpg.com/149/generics-and-the-covariance-problem#comments</comments>
		<pubDate>Tue, 22 Jun 2010 20:52:37 +0000</pubDate>
		<dc:creator>Mason Wheeler</dc:creator>
				<category><![CDATA[Delphi]]></category>
		<category><![CDATA[Generics]]></category>
		<category><![CDATA[reference]]></category>

		<guid isPermaLink="false">http://tech.turbu-rpg.com/?p=149</guid>
		<description><![CDATA[Since some version of this question keeps showing up on StackOverflow, and the answer&#8217;s always basically the same, I figured I may as well write up a post on here that people can link to.  Here&#8217;s the question, in simplified form: &#8220;Why can&#8217;t I pass a TList&#60;TMyDerivedObject&#62; to a function that&#8217;s expecting a TList&#60;TMyBaseObject&#62;?  You [...]]]></description>
			<content:encoded><![CDATA[<p>Since some version of this question keeps showing up on StackOverflow, and the answer&#8217;s always basically the same, I figured I may as well write up a post on here that people can link to.  Here&#8217;s the question, in simplified form:</p>
<p>&#8220;Why can&#8217;t I pass a TList&lt;TMyDerivedObject&gt; to a function that&#8217;s expecting a TList&lt;TMyBaseObject&gt;?  You can pass a TMyDerivedObject to a parameter expecting TMyBaseObject, so why doesn&#8217;t it work for lists?&#8221;</p>
<p><span id="more-149"></span></p>
<p>It really looks like it ought to be that simple, but unfortunately it&#8217;s not.  Trying to do this gets into a tricky issue in type theory known as <em><a href="http://en.wikipedia.org/wiki/Covariance_and_contravariance_%28computer_science%29">covariance and contravariance</a>,</em> which is a formal way of describing the relationship between different types when one inherits from another.</p>
<p>It&#8217;s important to remember that object types don&#8217;t really exist at the binary level.  They&#8217;re an abstraction that makes it easier for us to work with them, but when you get down to it, all that&#8217;s there is a sequence of bytes.  As a strongly-typed language, it&#8217;s up to the Delphi compiler to make sure that, when you have a TMyDerivedObject, it doesn&#8217;t get replaced with a TMyIncompatibleObject that will cause things to crash or corrupt your data when you try to use it.  This is why you&#8217;re not allowed to pass descendant classes to a <strong>var</strong> parameter, for example:  because in the function using the <strong>var</strong> parameter, you&#8217;re allowed to replace the object with something else, and if the compiler can&#8217;t guarantee that the replacement will be of a compatible type, it prevents you from passing it in order to preserve type safety.</p>
<p>This is basically the same problem you get when dealing with generic lists.  Let&#8217;s say you have a TList&lt;TMyDerivedObject&gt; and you pass it to a function that expects a TList&lt;TMyBaseObject&gt;.  As long as all it does is reads the items in the list, you&#8217;re just fine.  But if this function calls .Add on the list and adds a TMyIncompatibleObject, (which also descends from TMyBaseObject, and so is perfectly legal in this context,) then you&#8217;ve violated type safety.  You have a list that&#8217;s supposed to only contain one type of object, and now there&#8217;s something incompatible inside.  And since this is done by calling a method on the list object and not by directly assigning one variable to another, the compiler can&#8217;t check to make sure you&#8217;re not doing something dangerous like this, so it forbids the entire concept in order to preserve type safety.</p>
<p>There&#8217;s a solution to this problem.  You can extend the language syntax a little so that the compiler does have a way to check this.  You have to mark the methods on the list so that the compiler knows that it&#8217;s safe for them to receive an object that descends from, or is an ancestor of, the specified generic type.  For example, you could mark TList&lt;T&gt;.Add with a hint that it&#8217;s OK to add descendants of the T type, but not ancestors.  Then the compiler uses this to determine more relaxed type safety rules that allow you to pass around different generic types without the danger of mixing incompatible types together.</p>
<p>The latest version of Prism supports this, but the Delphi team hasn&#8217;t implemented it yet.  I haven&#8217;t heard anything to indicate that they&#8217;re working on it for Delphi 2011 either.  Hopefully it they&#8217;ll find some way to implement it for Delphi 2012.</p>
]]></content:encoded>
			<wfw:commentRss>http://tech.turbu-rpg.com/149/generics-and-the-covariance-problem/feed</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
		<item>
		<title>Inheritance baggage</title>
		<link>http://tech.turbu-rpg.com/147/inheritance-baggage</link>
		<comments>http://tech.turbu-rpg.com/147/inheritance-baggage#comments</comments>
		<pubDate>Mon, 21 Jun 2010 15:03:25 +0000</pubDate>
		<dc:creator>Mason Wheeler</dc:creator>
				<category><![CDATA[Dark Corners]]></category>
		<category><![CDATA[Delphi]]></category>
		<category><![CDATA[Optimization]]></category>

		<guid isPermaLink="false">http://tech.turbu-rpg.com/?p=147</guid>
		<description><![CDATA[A couple posts ago, I mentioned that I&#8217;ve been working with code generation lately.  This is for a part of the TURBU project.  An RPG relies pretty heavily on scripting, and RPG Maker, the system I created TURBU to replace, has a fairly extensive, if limited, scripting system.  The limitations were one of the things [...]]]></description>
			<content:encoded><![CDATA[<p>A couple posts ago, I mentioned that I&#8217;ve been working with code generation lately.  This is for a part of the TURBU project.  An RPG relies pretty heavily on scripting, and RPG Maker, the system I created TURBU to replace, has a fairly extensive, if limited, scripting system.  The limitations were one of the things that made me say &#8220;I could do better than this,&#8221; in fact:  No functions, no local variables, callable procedures exist but parameters don&#8217;t, so any &#8220;passing&#8221; has to be done in global variables, only two data types: integer and boolean, no event handlers, minimal looping support, etc.</p>
<p><span id="more-147"></span></p>
<p>The upside of all this, though, is a very simple scripting system that doesn&#8217;t look much like a programming language, with a simple interface that almost anyone can pick up.  I wanted to keep that simplicity as much as possible, while adding the full flexibility and power of a real scripting language.  So I dreamed up EventBuilder, a set of objects which represent a high-level scripting interface and can also express themselves as <a href="http://www.remobjects.com/ps.aspx">PascalScript</a> code.</p>
<p>I needed some way to create EventBuilder objects that could form a hierarchical tree that can represent blocks of code.  They needed to be easily serializable to some human-readable format so people can copy and paste blocks of EventBuilder script in order to share scripts, ask for help with debugging, etc.  And it needed to be ready quickly, since I want to be able to present as much of this as possible at Delphi Live! in August.</p>
<p>So is there any pre-existing system that supports hierarchical trees of objects and easy serialization to a simple text-based format?  The answer should be obvious to any experienced Delphi user:  descend from TComponent and use its built-in serialization to &#8220;DFM format.&#8221;  I tried that and, once I&#8217;d figured out how to handle a few quirks related to object ownership, it worked great!  All the infrastructure was there for me, tested and tried and proven over the last 15 years, and I could focus on the actual Event Builder logic.  It&#8217;s taken me about a month to get the system to a workable state, and now it&#8217;s more or less all ready.</p>
<p>Then I tried running a very, very large RPG Maker project through my project importer, and it took a long time on converting the global script block.  That&#8217;s sort of to be expected, since there are almost 2000 event scripts in there, but even so it felt like it was taking far too long for the amount of work involved.  I looked at my code and couldn&#8217;t find any obvious issues, so I ran it through <a href="http://delphitools.info/samplingprofiler/">Sampling Profiler</a>.</p>
<p>It&#8217;s a good thing I did, too.  It found a very clear bottleneck in a place I&#8217;d have never thought to look.  Apparently I was spending 77% of my time in TComponent.Notification.  And why would I have never thought to look there?  Because I&#8217;ve never heard of it!  But apparently every time I added a component, it would recursively call this on the entire subtree, turning what ought to have been a O(n) conversion into O(n^2).</p>
<p>With a bit of research, it turns out that TComponent.Notification is for dealing with linked components.  For example, when you link a TDataset to a TDatasource, it needs a notification mechanism so it can clean up references if you free one of them.  Since EventBuilder doesn&#8217;t use linked components, I didn&#8217;t really need this functionality.  Good thing TComponent.Notification is virtual!  I overrode it with a blank method, and suddenly the conversion time dropped from about 12 seconds to about 3 seconds, and everything&#8217;s running smoothly again.</p>
<p>Moral of the story?  Be careful that you understand what you&#8217;re inheriting from, otherwise you might end up with <a href="http://www.snopes.com/humor/nonsense/kangaroo.asp">killer kangaroos</a> or other unwanted features.</p>
]]></content:encoded>
			<wfw:commentRss>http://tech.turbu-rpg.com/147/inheritance-baggage/feed</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>AnyDAC: First impressions</title>
		<link>http://tech.turbu-rpg.com/144/anydac-first-impressions</link>
		<comments>http://tech.turbu-rpg.com/144/anydac-first-impressions#comments</comments>
		<pubDate>Fri, 04 Jun 2010 21:55:40 +0000</pubDate>
		<dc:creator>Mason Wheeler</dc:creator>
				<category><![CDATA[AnyDAC]]></category>
		<category><![CDATA[Delphi]]></category>

		<guid isPermaLink="false">http://tech.turbu-rpg.com/?p=144</guid>
		<description><![CDATA[Over the last few days, when I&#8217;ve had some free time available, I&#8217;ve been working with AnyDAC&#8217;s TADMemTable, which Dimitry Arafiev, the author, pitched to me as a replacement for and an improvement upon TClientDataset. I&#8217;d like to report on how smoothly everything went and how well it works, and spend some time on my [...]]]></description>
			<content:encoded><![CDATA[<p>Over the last few days, when I&#8217;ve had some free time available, I&#8217;ve been working with AnyDAC&#8217;s TADMemTable, which Dimitry Arafiev, the author, pitched to me as a replacement for and an improvement upon TClientDataset.  I&#8217;d like to report on how smoothly everything went and how well it works, and spend some time on my experience with the dataset and the new features it brings to the table.</p>
<p>Unfortunately, I don&#8217;t always get what I&#8217;d like.  I can&#8217;t really talk about stuff like that because I haven&#8217;t reached that point yet, due to various bugs and other implementation hurdles.</p>
<p><span id="more-144"></span>The installation and setup phase went quite well, actually.  The package was a 19 MB installer including full source code, DPKs and other requisite files for building the AnyDAC packages under anything from Delphi 5/C++ Builder 5 to RAD Studio 2010 (or FPC 2.2.x), a nice big helpfile and a fairly comprehensive Samples folder.  The download was nice and fast, and the only real annoyance was the installer getting a few paths wrong.  The helpfile is quite well-written in good, understandible English, which is good to see; that&#8217;s not always the case when working with libraries written by people from non-English-speaking countries.</p>
<p>I loaded up the TURBU project, backed up everything to source control, and went into dm_database.pas, where I keep my client datasets.  Time for the trial by fire:  Open the form designer, switch to text view, Select All, SyncEdit, replace all &#8220;TClientDataset&#8221; with &#8220;TADMemTable&#8221;, switch back to form view.  IMO, if something is presented as a replacement for something else, you ought to be able to swap it out and have it &#8220;just work.&#8221;  In practice, it&#8217;s rarely that simple.</p>
<p>TADMemDataset has the same support for filtering as TClientDatset, and it has a CloneCursor function, which is good because I use it pretty extensively.  What it doesn&#8217;t have, though, is the same public interface as TClientDataset.  For example, TClientDataset has a property called LogChanges, where if you turn it on it will save all edits to an intermediary datastore instead of the main one until you call MergeChangeLog or CancelUpdates.  Among other things, this makes implementing an editor dialog with Apply and Cancel buttons very simple.  TADMemDataset supports the same functionality, but the property that controls it is called CachedUpdates, not LogChanges, and to merge the change log you call CommitUpdates.</p>
<p>I got a bit of a rude surprise when I tried to convert one of my ClientDatasets to a TADMemTable: it didn&#8217;t like one of the fields.  The field was a TSingleField, and the internal storage table doesn&#8217;t know what a Single is, so it converts it to a Double, which causes errors when trying to open the dataset.  When I reported this to Dimitry, he replied that &#8220;ftSingle is not supported for a while.&#8221;</p>
<p>Also, using custom filtering with the OnFilterRecord event handler seems to break CloneCursor.  It looks like an order-of-operations issue inside TADDataset.InternalOpen: X needs to happen before Y, which needs to happen before Z, which is the way it&#8217;s currently set up, except that Z and Y both need to happen before X if you&#8217;re cloning a dataset with an OnFilterRecord event handler.  Apparently this is because X is doing too many different things, and needs to be reworked a bit.</p>
<p>I&#8217;ve reported all these issues to Dimitry and he says he&#8217;ll get a fixed version to me as soon as possible.  What I&#8217;ve seen so far of the dataset&#8217;s API looks interesting, but it&#8217;s kind of difficult to test for the moment, until the rough edges are polished.   I&#8217;ll post another update once I&#8217;m able to.</p>
<p>One other strange thing: In order to use the dataset, it requires  access to some interface that has to be initialized by dropping a certain component onto your project that seems to have no other  purpose except to make this interface available.  (Sorta like the XP  Manifest component that does nothing except link a resource into your  EXE.)  I&#8217;m not quite sure why TADMemTable can&#8217;t manage its own  dependencies, but that&#8217;s kind of disappointing.  Hopefully that will get fixed in an update.</p>
]]></content:encoded>
			<wfw:commentRss>http://tech.turbu-rpg.com/144/anydac-first-impressions/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>ClassType field should not be &#8220;magic&#8221;</title>
		<link>http://tech.turbu-rpg.com/137/classtype-field-should-not-be-magic</link>
		<comments>http://tech.turbu-rpg.com/137/classtype-field-should-not-be-magic#comments</comments>
		<pubDate>Sun, 30 May 2010 03:02:34 +0000</pubDate>
		<dc:creator>Mason Wheeler</dc:creator>
				<category><![CDATA[Delphi]]></category>

		<guid isPermaLink="false">http://tech.turbu-rpg.com/?p=137</guid>
		<description><![CDATA[I&#8217;ve been doing some work with code generation recently. It&#8217;s kind of messy. You need to build a tree in memory of objects that represent various types of syntax for the language you&#8217;re generating code for. You have to think inside-out from the way you normally write code, since you&#8217;re creating it in logical tree [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve been doing some work with code generation recently.  It&#8217;s kind of messy.  You need to build a tree in memory of objects that represent various types of syntax for the language you&#8217;re generating code for.  You have to think inside-out from the way you normally write code, since you&#8217;re creating it in logical tree form, not in line form.</p>
<p>You have a base class that represents any code-generation object, and a bunch of classes that descend from it.  In order to manage things properly, you&#8217;re likely to have TList&lt;TCodegenObject&gt; and TStack&lt;TCodegenObject&gt; collections (or, worse still, non-generic TObjectList and TObjectStack containers) all over the place.  But TCodegenObject, like TObject, is an abstract base class that you only instantiate descendants of.<br />
<span id="more-137"></span><br />
This can make debugging messy, especially if you break on an exception and Evaluate/Modify can&#8217;t read the locals anymore.  You try to look inside your collections to see what&#8217;s going on, but all you see are TCodegenObject instances, not the actual object instances you&#8217;re working with.  Sometimes that information is crucial to figuring out what&#8217;s going on, and you have to resort to ugly debugger hackery to track it down.</p>
<p>After this had happened to me a few too many times, it occurred to me that there&#8217;s something slightly ridiculous in Delphi&#8217;s object model.  The first 4 bytes of the instance contain a reference to the object&#8217;s VMT, which defines the object&#8217;s class type.  It&#8217;s a hidden area of memory, managed through &#8220;magic&#8221; and ugly pointer casting.  For example, the TObject.ClassType function, which returns a TClass variable, which is defined as a pointer to a class&#8217;s VMT, (which defines the class type,) is implemented as:</p>
<pre>
<div class="codesnip-container" >
<div class="delphi codesnip" style="font-family:monospace;"><span class="kw1">function</span> <span class="kw4">TObject</span><span class="sy1">.</span><span class="me1">ClassType</span><span class="sy1">:</span> <span class="kw4">TClass</span><span class="sy1">;</span>
<span class="kw1">begin</span>
&nbsp; <span class="kw4">Pointer</span><span class="br0">&#40;</span>Result<span class="br0">&#41;</span> <span class="sy1">:</span><span class="sy3">=</span> <span class="kw4">PPointer</span><span class="br0">&#40;</span><span class="kw2">Self</span><span class="br0">&#41;</span><span class="sy2">^</span><span class="sy1">;</span>
<span class="kw1">end</span><span class="sy1">;</span></div>
</div>
</pre>
<p>Now maybe, for some strange reason, this made sense back in 1995 when Delphi&#8217;s object model was first being set up.  But today there are two problems with it.  1, it&#8217;s ugly, and 2, it leads to unnecessary frustration by hiding useful information, especially since the Delphi debugger has a built-in evaluator that converts TClass references to class names.</p>
<p>You can probably see what I&#8217;m getting at.  I&#8217;d like to see, in the next Delphi version if possible, that &#8220;magic&#8221; field replaced with a real field, like so:</p>
<pre>
<div class="codesnip-container" >
<div class="delphi codesnip" style="font-family:monospace;"><span class="kw4">TObject</span> <span class="sy3">=</span> <span class="kw1">class</span>
&nbsp; <span class="kw1">private</span>
&nbsp; &nbsp; FClassType<span class="sy1">:</span> <span class="kw4">TClass</span><span class="sy1">;</span>
&nbsp; <span class="kw1">public</span>
&nbsp; &nbsp; <span class="co1">//stuff that's already there</span>
&nbsp; &nbsp; <span class="co1">//minus the ClassType method</span>
&nbsp; &nbsp; <span class="kw1">property</span> ClassType<span class="sy1">:</span> <span class="kw4">TClass</span> <span class="kw3">read</span> FClassType<span class="sy1">;</span>
&nbsp; <span class="kw1">end</span><span class="sy1">;</span></div>
</div>
</pre>
<p>This remains syntactically equivalent to the existing implementation and would not break any existing code, and it has the added benefit of making polymorphism-related code easier to debug, since the FClassType field would be available in the debugger.  I&#8217;ve thought about this and I can&#8217;t see any downsides.  Can anyone see a potential problem with it?</p>
<p>I&#8217;ve <a href="http://qc.embarcadero.com/wc/qcmain.aspx?d=84995 ">submitted this to QC</a>.  Please vote it up if you like the idea.</p>
<p><strong>EDIT:</strong><br />
I&#8217;m adding this because a few of the comments seem to be misunderstanding what I&#8217;m talking about.  They think I want to add a new field to TObject, and they (correctly) think that adding one would increase overhead, which would be a bad thing.</p>
<p>Thing is, I&#8217;m not talking about adding any new overhead to TObject.  That field is already there.  It&#8217;s been there since Delphi 1.  The first 4 bytes of every TObject instance is a field that contains a pointer to the object&#8217;s VMT, or in other words, a TClass.  For whatever reason, the language architects decided not to expose it as a visible field of type TClass.  What I&#8217;m suggesting is simply taking that hidden field and exposing it, not adding anything new that wasn&#8217;t already there all along.</p>
]]></content:encoded>
			<wfw:commentRss>http://tech.turbu-rpg.com/137/classtype-field-should-not-be-magic/feed</wfw:commentRss>
		<slash:comments>15</slash:comments>
		</item>
	</channel>
</rss>
