<?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</title>
	<atom:link href="http://tech.turbu-rpg.com/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>Fri, 27 Jan 2012 19:53:58 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>An email from Stardock</title>
		<link>http://tech.turbu-rpg.com/395/an-email-from-stardock</link>
		<comments>http://tech.turbu-rpg.com/395/an-email-from-stardock#comments</comments>
		<pubDate>Fri, 27 Jan 2012 19:53:58 +0000</pubDate>
		<dc:creator>Mason Wheeler</dc:creator>
				<category><![CDATA[Personal]]></category>
		<category><![CDATA[Thoughts]]></category>

		<guid isPermaLink="false">http://tech.turbu-rpg.com/?p=395</guid>
		<description><![CDATA[As you may know if you&#8217;ve been reading for a while, I&#8217;m a gamer.  Have been pretty much my whole life.  In fact, it was the prospect of creating my own video games that first got me into programming. A while back, I purchased Elemental, the latest game by Stardock, a company with a reputation [...]]]></description>
			<content:encoded><![CDATA[<p>As you may know if you&#8217;ve been reading for a while, I&#8217;m a gamer.  Have been pretty much my whole life.  In fact, it was the prospect of creating my own video games that first got me into programming.</p>
<p>A while back, I purchased Elemental, the latest game by Stardock, a company with a reputation for making high-quality games and for being a lot more ethical than many gaming companies.  Their <a href="http://tvtropes.org/pmwiki/pmwiki.php/Main/SinsOfASolarEmpire">Sins of a Solar Empire</a> was the best-selling game of 2008, for example, even though they refused to put any DRM on their software.  (So much for piracy destroying sales!)  They&#8217;re also the guys who created Impulse, a Steam competitor that ended up getting bought by GameStop last year.</p>
<p>Elemental, unfortunately, was not a high-quality game.  The basic concept was decent&#8211;not exceptional, but not *bad* either&#8211;but the game itself was a slow, crashy, bug-ridden mess.  Several patches over the course of several months eventually got it to a mostly-decent state, but in no way did it live up to expectations.</p>
<p>They just did something that does a lot to redeem them in my eyes.  I woke up this morning with the following letter in my email:<span id="more-395"></span></p>
<blockquote><p>Dear Stardock Customer,</p>
<p>If you&#8217;re receiving this email it means you purchased Elemental: War of Magic before November 1, 2010.</p>
<p>Elemental: War of Magic was a game we had very high hopes for. Unfortunately, it was a disappointment both to us, as well as to many of our customers. Stardock&#8217;s success in its nineteen years of existence has been because people know when they buy something with our name on it, it&#8217;ll be excellent. With Elemental: War of Magic, we failed that expectation.</p>
<p>For the past year, Stardock has been working on something new &#8212; Elemental: Fallen Enchantress. We went back to the drawing board to create not an expansion, but rather a new game in the Elemental universe.</p>
<p>Fallen Enchantress is currently in beta. The beta has already been added to your Stardock account and the final version will automatically be added free of charge on the day of release.</p>
<p>To access the beta, visit: [download link].</p>
<p>We hope you find Elemental: Fallen Enchantress to be a game that lives up to the expectations you had for War of Magic. We thank you for your support and we look forward to your feedback.</p>
<p>Sincerely,<br />
Brad Wardell &#8211; President &amp; CEO<br />
Stardock Entertainment</p></blockquote>
<p>I really appreciate that.  They didn&#8217;t have any obligation to do that, but it&#8217;s the right thing to do.  When your customers pay for something and then obviously do not get their money&#8217;s worth, you acknowledge it and find a way to make up for it.  If only more game companies (or software companies in general) out there had leaders with Brad Wardell&#8217;s conscience and sense of responsibility&#8230;</p>
<p>http://tvtropes.org/pmwiki/pmwiki.php/Main/SinsOfASolarEmpire</p>
]]></content:encoded>
			<wfw:commentRss>http://tech.turbu-rpg.com/395/an-email-from-stardock/feed</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>The worst thing about SOPA</title>
		<link>http://tech.turbu-rpg.com/393/the-worst-thing-about-sopa</link>
		<comments>http://tech.turbu-rpg.com/393/the-worst-thing-about-sopa#comments</comments>
		<pubDate>Wed, 18 Jan 2012 15:29:54 +0000</pubDate>
		<dc:creator>Mason Wheeler</dc:creator>
				<category><![CDATA[politics]]></category>
		<category><![CDATA[Thoughts]]></category>

		<guid isPermaLink="false">http://tech.turbu-rpg.com/?p=393</guid>
		<description><![CDATA[Have you heard of the Golden Mean Fallacy?  I would link to the Wikipedia page, but they&#8217;re blacked out today, so here&#8217;s an excerpt from its description: &#8230;a logical fallacy which asserts that given two positions there exists a compromise between them which must be correct.  [It] implies that the positions being considered represent extremes [...]]]></description>
			<content:encoded><![CDATA[<p>Have you heard of the Golden Mean Fallacy?  I would link to the Wikipedia page, but they&#8217;re blacked out today, so here&#8217;s an excerpt from its description:</p>
<blockquote><p>&#8230;a logical fallacy which asserts that given two positions there exists a compromise between them which must be correct.  [It] implies that the positions being considered represent extremes of a continuum of opinions, and that such extremes are always wrong, and the middle ground is always correct. This is not always the case. Sometimes only X or Y is acceptable, with no middle ground possible. <strong>Additionally, the middle ground fallacy allows any position to be invalidated, even those that have been reached by previous applications of the same method; all one must do is present yet another, radically opposed position, and the middle-ground compromise will be forced closer to that position.</strong></p></blockquote>
<p>I added emphasis to a very important part of the explanation.  All you have to do to make something bad look good is come up with something even worse to compare it to.  And given the human capacity for imagination, that&#8217;s not such a difficult task.<span id="more-393"></span></p>
<p>You&#8217;ve probably heard of SOPA and Protect-IP by now.  Pretty much everyone who looks at these bills, outside of the entertainment industry, agrees on a few simple points:</p>
<ol>
<li>These bills would give private corporations the power to censor the Internet</li>
<li>These bills are unconstitutional, as they violate the 1st amendment</li>
<li>These bills are evil and need to be stopped</li>
</ol>
<p>Well, there&#8217;s some good news, and some bad news.  The good news is that as more and more people are finding out about them, they&#8217;re talking to their congressional representatives, and it looks like support for these bills is falling.  It&#8217;s looking likely that they won&#8217;t pass.</p>
<p>The bad news is the Golden Mean Fallacy.  Take a look at <a href="http://americancensorship.org/">Stop American Censorship</a>, one of the sites that&#8217;s working to coordinate the opposition to this legislation.  Check out the quotes down at the bottom, from experts on the subject.  I was a bit horrified to see multiple people saying, in effect, &#8220;the DMCA is OK, but <em>this</em> goes too far!&#8221;</p>
<p>That&#8217;s the Golden Mean Fallacy talking.  If we accept the Digital Millennium Copyright Act as legitimate, we&#8217;ve already lost.  It&#8217;s every bit as unconstitutional and every bit as evil as SOPA, and to be honest I&#8217;m  shocked that it&#8217;s apparently never been subject to judicial review on 5th or 14th amendment grounds.  You probably know of the 5th amendment as the one that says you can &#8220;take the 5th&#8221; in court, meaning that you have the right to not incriminate yourself.  But it also guarantees that you cannot &#8220;be deprived of life, liberty, or property, without due process of law.&#8221;  The 14th amendment reiterates the whole &#8220;due process of law&#8221; thing, applying it to the states as well as the federal government.</p>
<p>In layman&#8217;s terms, we have a guarantee, repeated twice, in the Bill of Rights that nobody can be punished for a crime without due process of law, which means (among other things) that they have the right to a fair trial.  This is just as important as a foundation for our freedoms as the First Amendment, and the DMCA tramples all over it.</p>
<p>How does a copyright act trample on the right to due process?  I know it sounds strange at first, but the DMCA is a strange law.  It allows copyright owners to send takedown notices to allegedly-infringing Internet sites, claiming that they are hosting infringing material.  Under the law, this material must be removed right away, unless the owner believes that no infringement is taking place and is willing to start a fight over it.</p>
<p>This may not sound too unreasonable, until you realize that <em>it puts the burden of proof on the accused</em>.  It throws one of our most sacred legal traditions, the presumption of innocence (aka &#8220;innocent until proven guilty&#8221;) out the window.  Now you&#8217;re guilty, by default and without a trial, until proven innocent!  You need look no further than <a href="http://www.chillingeffects.org">chillingeffects.org</a> to see the damage that this is doing, by allowing copyright holders to make false or exaggerated copyright claims and get away with it.  The presumption of innocence and the right to due process exists for a reason!</p>
<p>But the DMCA does even worse than that: it also allows the use of DRM technology.  Have you ever had a problem activating a program that you legitimately bought?  Something goes wrong and you can&#8217;t use it even though you&#8217;ve paid for it and done everything right?  Then you can see the problem here.  It&#8217;s like the takedowns, but even worse, as you have no way to fight it.  The DRM software is unaccountable.  If it has a bug, (and all software has bugs,) you&#8217;re not innocent until proven guilty.  You&#8217;re not even guilty until proven innocent.  You&#8217;re simply <strong>guilty</strong>, and screw the proof!  It doesn&#8217;t matter if you actually broke the law or not, the copyright owner&#8217;s interpretation of the law is enforced upon you and there&#8217;s nothing you can do about it.</p>
<p>So the worst thing about SOPA is not SOPA at all.  It&#8217;s the opportunity it provides for the Golden Mean Fallacy to legitimize another piece of equally-evil legislation.  Until the DMCA is repealed, and not only repealed but <em>reversed</em>, giving DRM technology the legal status it truly deserves, which is that of malware with no legitimate use, problems like SOPA will continue popping up again and again, because it&#8217;s built on the foundation of rights abuses codified by the DMCA.</p>
<p>Wikipedia is blacked out today, replacing its articles with a page urging people to contact their Congressmen in opposition to SOPA.  That&#8217;s a good gesture, but ultimately meaningless.  SOPA is getting enough opposition now that it&#8217;s not going to pass.  We&#8217;ve already won this battle.  What people need to contact their congressmen about is rooting out the source of this abuse.  &#8220;Repeal and reverse the DMCA,&#8221; not &#8220;stop SOPA,&#8221; needs to be the soundbite on people&#8217;s minds if we&#8217;re to truly protect our freedom in the Internet Age.</p>
]]></content:encoded>
			<wfw:commentRss>http://tech.turbu-rpg.com/393/the-worst-thing-about-sopa/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Job opportunities at WideOrbit</title>
		<link>http://tech.turbu-rpg.com/387/job-opportunities-at-wideorbit</link>
		<comments>http://tech.turbu-rpg.com/387/job-opportunities-at-wideorbit#comments</comments>
		<pubDate>Thu, 12 Jan 2012 14:13:55 +0000</pubDate>
		<dc:creator>Mason Wheeler</dc:creator>
				<category><![CDATA[Delphi]]></category>
		<category><![CDATA[employment]]></category>
		<category><![CDATA[Personal]]></category>

		<guid isPermaLink="false">http://tech.turbu-rpg.com/?p=387</guid>
		<description><![CDATA[Just thought I&#8217;d throw this one out there.  My employer, WideOrbit, is currently hiring.  We&#8217;ve got multiple development positions open for both Delphi and C#/Silverlight skillsets.  (SQL experience, especially with MS SQL Server, really helps too.)  At WideOrbit we build industry-leading software for managing broadcast media.  If you live in the USA, there&#8217;s a pretty [...]]]></description>
			<content:encoded><![CDATA[<p>Just thought I&#8217;d throw this one out there.  My employer, WideOrbit, is currently hiring.  We&#8217;ve got multiple development positions open for both Delphi and C#/Silverlight skillsets.  (SQL experience, especially with MS SQL Server, really helps too.)  At WideOrbit we build industry-leading software for managing broadcast media.  If you live in the USA, there&#8217;s a pretty good chance your favorite station is running on WideOrbit software, and we built it in Delphi.  (Mostly.)</p>
<p>Our development office is in Lynnwood, Washington, (about half an hour from Seattle,) and on-site work is preferred, though some exceptions do (infrequently) get made on a case-by-case basis.  It&#8217;s a good location, right across the street from a major mall (plenty of places to go for lunch!), with good pay and working conditions.  The office has a friendly, engineer-centric culture, and it really helps that the manager is a former coder and the boss still is one.  No pointy hair here!</p>
<p>Only those who know what they&#8217;re doing need apply.  The developers take an active part in the interview process, and we&#8217;ve got really high standards.  We understand that the only way to develop good software is with good developers, and we try hard to make sure that that&#8217;s all we get.  But if you&#8217;re good and you can demonstrate that you know what you&#8217;re doing, you&#8217;re likely to get an offer.</p>
<p>If anyone&#8217;s interested, send me a resume at <a href="mailto:mwheeler@wideorbit.com ">mwheeler@wideorbit.com </a>and I&#8217;ll see about getting you an interview.</p>
]]></content:encoded>
			<wfw:commentRss>http://tech.turbu-rpg.com/387/job-opportunities-at-wideorbit/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>RTTI Script basic examples</title>
		<link>http://tech.turbu-rpg.com/385/rtti-script-basic-examples</link>
		<comments>http://tech.turbu-rpg.com/385/rtti-script-basic-examples#comments</comments>
		<pubDate>Sun, 13 Nov 2011 21:56:57 +0000</pubDate>
		<dc:creator>Mason Wheeler</dc:creator>
				<category><![CDATA[Delphi]]></category>

		<guid isPermaLink="false">http://tech.turbu-rpg.com/?p=385</guid>
		<description><![CDATA[After a few requests for examples and an assertion in the comments that noting actually compiles or runs, I&#8217;ve updated the repository a little. I&#8217;ve fixed a few bugs in the parser, and updated the executor to support the Environment object.  I added an Examples folder with two simple Hello World projects.  They both display [...]]]></description>
			<content:encoded><![CDATA[<p>After a few requests for examples and an assertion in the comments that noting actually compiles or runs, I&#8217;ve updated <a href="http://code.google.com/p/rtti-script/source/checkout">the repository</a> a little.<span id="more-385"></span></p>
<p>I&#8217;ve fixed a few bugs in the parser, and updated the executor to support the Environment object.  I added an Examples folder with two simple Hello World projects.  They both display a message box with a simple greeting.  The message box, of course, is not built in to the scripting system, so it has to be imported from the Delphi project.  These two sample programs demonstrate the two ways to do this: through external unit registration and with an Environment object.</p>
<p>The rsCompiler unit provides a class called TrsTypeImporter that&#8217;s used to import new types, variables, constants and routines (hmm&#8230; maybe I should change the name to just TrsImporter?) to make the compiler aware of them.  To register a new external unit, call RegisterStandardUnit on the compiler.  It takes two parameters: a unit name and an anonymous reference to a procedure that takes a TrsTypeImporter as an argument.  The first time a unit with that name is used in the script, the compiler will call the method reference, providing an importer to register things with the compiler.  A unit named &#8220;system&#8221; is always used, so if you want to import things that will always be available to the script, call RegisterStandardUnit and use &#8220;system&#8221; as the unit name.</p>
<p>Any units registered with the compiler also have to be registered with the script executor by a similar process.  The interface for the executor&#8217;s RegisterStandardUnit system is not stable yet, but it currently allows you to register your standalone routines in the callback.  I&#8217;ll add support for registering classes and external variables soon.</p>
<p>The second, simpler way to do imports is through the Environment object.  The second sample program shows how this works.  You declare a class and register it with the compiler, and every public method and property on it will be available to the script engine as if they were global routines and variables declared in the &#8220;system&#8221; import.  Then you register an instance of the class with the script executor before loading the program.  (It&#8217;s important to note that the Environment has to be registered with the compiler <strong>before</strong> compiling, and with the script executor <strong>before</strong> loading the program.)</p>
<p>It&#8217;s possible to use both systems together, of course.  If you want to break up your external routines into groups, you could declare and register multiple external units, but still have a group of globally-available methods in an Environment object.</p>
<p>Hopefully these examples will show people how to get started.  I&#8217;ll add some more examples as needed and when I get some more features ready.</p>
]]></content:encoded>
			<wfw:commentRss>http://tech.turbu-rpg.com/385/rtti-script-basic-examples/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>RTTI Script alpha release</title>
		<link>http://tech.turbu-rpg.com/382/rtti-script-alpha-release</link>
		<comments>http://tech.turbu-rpg.com/382/rtti-script-alpha-release#comments</comments>
		<pubDate>Fri, 11 Nov 2011 16:06:57 +0000</pubDate>
		<dc:creator>Mason Wheeler</dc:creator>
				<category><![CDATA[Delphi]]></category>
		<category><![CDATA[RTTI]]></category>
		<category><![CDATA[Scripting]]></category>

		<guid isPermaLink="false">http://tech.turbu-rpg.com/?p=382</guid>
		<description><![CDATA[Way back at the start of this year, I wrote about how I&#8217;d been working on a new Object Pascal-based script engine built around Delphi&#8217;s extended RTTI system.  And then it got real quiet, because more immediate concerns took priority for me.  But I&#8217;ve gotten to the point in my game engine development where I [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://tech.turbu-rpg.com/284/dynamic-class-creation-moving-beyond-the-theoretical">Way back at the start of this year</a>, I wrote about how I&#8217;d been working on a new Object Pascal-based script engine built around Delphi&#8217;s extended RTTI system.  And then it got real quiet, because more immediate concerns took priority for me.  But I&#8217;ve gotten to the point in my game engine development where I really need to put in the scripting system, so I spent the last couple weeks finishing up the implementation and tuning the performance a little, and now I&#8217;ve got an alpha version ready.  If anyone would like to try it out, they can find it <a href="http://code.google.com/p/rtti-script/source/checkout">on Google Code</a>.</p>
<p><span id="more-382"></span>Note: <strong>This is an alpha version</strong>.  There are probably plenty of bugs in it.  There are still features I haven&#8217;t gotten around to implementing.  The sight of the code would probably send Barry Kelly fleeing from the room, screaming in horror.  So use at your own risk, and I take no responsibility if this causes your system to crash, your data to come out all wrong, or <a href="http://www.catb.org/~esr/jargon/html/N/nasal-demons.html">demons to fly out your nose</a>.  Specifically, the <strong>program</strong> keyword is not implemented yet, (only units,) <strong>var</strong> parameters don&#8217;t work yet, and a handful of features aren&#8217;t implemented in the script executor.</p>
<p>Having said that, here&#8217;s a few cool features I&#8217;ve come up with:</p>
<ul>
<li><strong>Class creation:</strong>  Defining a new class inside the script code is not supported yet, but the basic framework is there, and script units implement new classes with their routines as methods, accessible to the script executor through the RTTI system.  I&#8217;ll add class creation pretty soon.</li>
<li><strong>Automatic registration:</strong> Ever try to register a class with the script engine in PascalScript?  It&#8217;s a painful process involving generating a registration unit that basically redeclares your entire class, and then has to be kept in sync or things break.  (And if you get the dependency order wrong, it fails silently,  leading to weird errors further down the line.)  I figured that was way too complicated, so for RTTIScript, all you have to do is register a class reference, and it uses the RTTI system to figure out the internal members and dependencies for you.</li>
<li><strong>Execution environment:</strong> You&#8217;ll often have a bunch of little standalone routines and global variables that you want to import into a script to have available at all times, to provide an interface between the script and your program.  So I introduced the concept of the &#8220;environment:&#8221; You create a class and register it with the compiler, and it treats all the class&#8217;s public methods and properties as globals for the script.  (This also means that you can use property getters and setters to have the script&#8217;s interaction with its &#8220;global variables&#8221; invoke side effects.)</li>
<li><strong>Script saving:</strong> I know <a href="http://delphitools.info/2010/10/26/why-no-bytecode-format/">Eric Grange thinks that a fast compiler is good enough</a> and a bytecode version of a script is not necessary, but I don&#8217;t agree.  By his own tests, even a very fast script compiler can take 2 seconds to compile a 100,000 line script.  I&#8217;ve actually got an example of one that big in a project that the author wants to convert over once the TURBU project is ready.  Adding a two-second lag into the loading process and making the player wait while a level loads, which should feel instantaneous, is unacceptable.  I don&#8217;t have script saving implemented yet, but it&#8217;s definitely on the to-do list.</li>
</ul>
<p>Anyway, the alpha version is available for any <del>guinea pigs</del> curious developers out there who&#8217;d like to take a look at it.  It requires Delphi XE, it&#8217;s pretty fast, and when I get the rest of the features set up it&#8217;s going to be awesome!  Feel free to check it out, and to <a href="http://code.google.com/p/rtti-script/issues/list">submit a bug report</a> if you find some errors. (Which I&#8217;m sure plenty of people will.)</p>
]]></content:encoded>
			<wfw:commentRss>http://tech.turbu-rpg.com/382/rtti-script-alpha-release/feed</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>A handle leak in TWinControl?</title>
		<link>http://tech.turbu-rpg.com/375/a-handle-leak-in-twincontrol</link>
		<comments>http://tech.turbu-rpg.com/375/a-handle-leak-in-twincontrol#comments</comments>
		<pubDate>Wed, 26 Oct 2011 03:07:41 +0000</pubDate>
		<dc:creator>Mason Wheeler</dc:creator>
				<category><![CDATA[Delphi]]></category>
		<category><![CDATA[Delphi XE]]></category>
		<category><![CDATA[Memory Management]]></category>

		<guid isPermaLink="false">http://tech.turbu-rpg.com/?p=375</guid>
		<description><![CDATA[For the TURBU engine, I&#8217;ve got a custom control that allows me to embed an OpenGL rendering context on a form.  I was working on some new features, and I downloaded gDEBugger, an OpenGL debugging tool, to help out.  One of the things it told me is that my rendering contexts were leaking. They shouldn&#8217;t [...]]]></description>
			<content:encoded><![CDATA[<p>For the TURBU engine, I&#8217;ve got a custom control that allows me to embed an OpenGL rendering context on a form.  I was working on some new features, and I downloaded gDEBugger, an OpenGL debugging tool, to help out.  One of the things it told me is that my rendering contexts were leaking.<span id="more-375"></span></p>
<p>They shouldn&#8217;t be.  I create the renderer in CreateWnd and I destroy it in DestroyWnd, which should get called as part of the component destruction process.  But as it turns out, DestroyWnd is not actually called anywhere!</p>
<p>By tracing through the VCL code, it looks like DestroyWnd is supposed to get called from a call stack that looks something like this:</p>
<p>TMyControl.DestroyWnd //virtual<br />
TWinControl.DestroyHandle<br />
TWinControl.RemoveControl<br />
TControl.SetParent(nil)<br />
TControl.Destroy</p>
<p>But earlier in the form destruction process, TWinControl.Remove gets called.  It does not call RemoveControl on the control being removed, and at the end of the routine, it says:</p>
<p>AControl.FParent := nil;</p>
<p>By directly setting the field to nil instead of calling SetParent(nil), it makes it so that when SetParent(nil) is called, the entire body of code gets short-circuited, so that RemoveControl is never called.  In fact, it&#8217;s not just my control.  I put a breakpoint on the first line of TWinControl.DestroyHandle, ran the program, and closed it, which generates and then frees almost 30 TWinControl descendants.  <em>The breakpoint was never hit.</em></p>
<p>I&#8217;m seeing this in Delphi XE.  I haven&#8217;t tested it in any other version, but from what I can see, it appears that any VCL control created in XE will never call DestroyHandle during component destruction, leading to all window handles (and other resources, such as my rendering contexts) being leaked.</p>
<p>Can anyone confirm this, or say if it affects other versions?  I didn&#8217;t see this in QC, so <a href="http://qc.embarcadero.com/wc/qcmain.aspx?d=100455">I wrote up a bug report.</a>  Please vote for it, especially if you work on a program with lots of complex forms and have users who would be, shall we say, unamused to suddenly hit an &#8220;out of resources&#8221; error for no good reason&#8230;</p>
]]></content:encoded>
			<wfw:commentRss>http://tech.turbu-rpg.com/375/a-handle-leak-in-twincontrol/feed</wfw:commentRss>
		<slash:comments>8</slash:comments>
		</item>
		<item>
		<title>Wish list: Slicing syntax</title>
		<link>http://tech.turbu-rpg.com/370/wish-list-slicing-syntax</link>
		<comments>http://tech.turbu-rpg.com/370/wish-list-slicing-syntax#comments</comments>
		<pubDate>Fri, 16 Sep 2011 17:47:41 +0000</pubDate>
		<dc:creator>Mason Wheeler</dc:creator>
				<category><![CDATA[Delphi]]></category>
		<category><![CDATA[Wish List]]></category>

		<guid isPermaLink="false">http://tech.turbu-rpg.com/?p=370</guid>
		<description><![CDATA[I&#8217;ve been doing a lot of string processing work lately.  Delphi has a lot of strengths, but unfortunately string manipulation really isn&#8217;t one of them.  It gets really messy really quickly if you&#8217;re trying to do anything complicated.  Extracting substrings out of strings quickly degenerates into a mess of difficult-to-read Copy calls.  It would sure [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve been doing a lot of string processing work lately.  Delphi has a lot of strengths, but unfortunately string manipulation really isn&#8217;t one of them.  It gets really messy really quickly if you&#8217;re trying to do anything complicated.  Extracting substrings out of strings quickly degenerates into a mess of difficult-to-read Copy calls.  It would sure be nice if there was a better way.<span id="more-370"></span></p>
<p>There is a better way, by the way.  Python has it; it&#8217;s called &#8220;slicing.&#8221;  You know how in Delphi, you can use array[subscript] notation to get a single item out of an array?  Well in Python you can use an extended version of that to get a subrange (a slice) out of an array.  For example:</p>
<div class="codesnip-container" >
<div class="python codesnip" style="font-family:monospace;">mystring = <span class="st0">&quot;Python string slicing&quot;</span><br />
mystring<span class="br0">&#91;</span><span class="nu0">7</span>:<span class="nu0">13</span><span class="br0">&#93;</span></div>
</div>
<p>returns &#8220;string&#8221;.  (In Python, strings start at index 0.)  Also, you don&#8217;t need a value on both sides of the colon.  If you don&#8217;t provide one, it translates to the beginning/end of the array, as appropriate.  So &#8220;mystring[:6]&#8221; returns &#8220;Python&#8221; and &#8220;mystring[14:]&#8221; returns &#8220;slicing&#8221;.</p>
<p>Now, using a colon here isn&#8217;t very Pascal-ish.  Colons are for variable declarations.  But we do have a range operator that&#8217; s used with arrays: the double dot.  Wouldn&#8217;t it be nice to be able to do stuff like this in Delphi?</p>
<div class="codesnip-container" >
<div class="delphi codesnip" style="font-family:monospace;">name <span class="sy1">:</span><span class="sy3">=</span> <span class="st0">&#8216;Mason Wheeler&#8217;</span><span class="sy1">;</span><br />
firstname <span class="sy1">:</span><span class="sy3">=</span> name<span class="br0">&#91;</span><span class="sy1">..</span>5<span class="br0">&#93;</span><span class="sy1">;</span><br />
lastname <span class="sy1">:</span><span class="sy3">=</span> name<span class="br0">&#91;</span>6<span class="sy1">..</span><span class="br0">&#93;</span><span class="sy1">;</span></div>
</div>
<p>The compiler could translate this syntax to calls to Copy easily enough.  Also, they could improve on the concept a little.  If you feed Python a negative number in a slicing expression, it will error out.  But if Delphi could automatically translate myArray[..-5] into myArray[..high(myArray) - 5], grabbing everything except the last  X number of elements would be that much easier.</p>
<p>Any thoughts?</p>
]]></content:encoded>
			<wfw:commentRss>http://tech.turbu-rpg.com/370/wish-list-slicing-syntax/feed</wfw:commentRss>
		<slash:comments>15</slash:comments>
		</item>
		<item>
		<title>DelphiLive keynote overview</title>
		<link>http://tech.turbu-rpg.com/365/delphilive-keynote-overview</link>
		<comments>http://tech.turbu-rpg.com/365/delphilive-keynote-overview#comments</comments>
		<pubDate>Tue, 13 Sep 2011 20:25:30 +0000</pubDate>
		<dc:creator>Mason Wheeler</dc:creator>
				<category><![CDATA[Delphi]]></category>
		<category><![CDATA[Delphi XE2]]></category>
		<category><![CDATA[DelphiLive!]]></category>

		<guid isPermaLink="false">http://tech.turbu-rpg.com/?p=365</guid>
		<description><![CDATA[I just got out of the DelphiLive keynote, presented by Michael Swindell and various other members.  As you can imagine, it was mostly about XE2 and demoing the new technologies, with a lot of talk about FireMonkey and using it for cross-platform development.  Here&#8217;s what really caught my notice: Michael Swindell opened it up.  He [...]]]></description>
			<content:encoded><![CDATA[<p>I just got out of the DelphiLive keynote, presented by Michael Swindell and various other members.  As you can imagine, it was mostly about XE2 and demoing the new technologies, with a lot of talk about FireMonkey and using it for cross-platform development.  Here&#8217;s what really caught my notice:<span id="more-365"></span></p>
<p>Michael Swindell opened it up.  He was talking about the recent advances in UX (user experience) technology throughout the computer industry, and he explained how FireMonkey is designed to provide a modern interface and user experience.  He had a very interesting story about a dentist visit a few years back.  He went in one day and found that the dentist&#8217;s office was modernizing a lot.  All the medical records were being computerized, moving out of the file cabinets.  He was really impressed when they showed him the new system, especially as the software came from a Delphi shop.  When he went in to talk with the dentist, all his patient records were up there on a big screen, and he was really proud of what they&#8217;d done with Delphi.  Then the dentist tried to show him a new feature and, as Michael put it, &#8220;all the pride turned to shame.&#8221;</p>
<p>He had to grab a mouse and try to use it with one hand, clicking around through the interface, all while trying to hold a miniature camera inside Michael&#8217;s mouth with the other, and it was a big, clumsy mess.  It would have been a lot easier for him if he&#8217;d had a touch-based system on a tablet, or example.</p>
<p>He mentioned that a lot of new interface and display technology is starting to show up on the market.  Samsung, for example, has just started to mass-produce transparent LCD screens.  (He mentioned the movies <em>Avatar</em> and <em>Minority Report</em> as examples of transparent LCD screens in use, which kinda bugged me.  I wish people would stop talking about &#8220;<em>Minority Report</em> interfaces&#8221; as if they were something realistic, because they&#8217;re anything but.  Sure, they look cool in movies, but there&#8217;s a good reason why all successful human interface devices have always required little wrist movement, minimal elbow movement and zero shoulder movement to operate.  Trying to run a real-life &#8220;<em>Minority Report</em> interface&#8221; would wear your arms out very quickly.)</p>
<p>He also mentioned GPUs.  He said that all computers from desktops to smartphones have had GPUs as standard features for the last decade, and they&#8217;ve got more processing power than your CPU, but they generally sit idle.  He said that finding ways to use the power of the GPU is a major focus for Embarcadero.  All the FireMonkey visuals are drawn with the GPU, and they&#8217;re looking into ways to do general-purpose computing on the GPU with Delphi, for a later version.  <a href="http://en.wikipedia.org/wiki/CUDA">CUDA</a> was mentioned a few times as an example of the sort of things that can be done with a GPU, which I find interesting.  CUDA and OpenCL, CUDA&#8217;s non-NVIDIA competitor, both use script languages that look like someone took C and beat it with an ugly stick.  If they could come up with a Pascal-based GPGPU script language, that would be awesome!</p>
<p>After Michael, John Thomas spoke for a while, talking about FireMonkey.  He called FireMonkey &#8220;a full application stack&#8221; that makes it very easy to simply recompile and run on a new platform.  But unlike other cross-platform solutions, FireMonkey a full native code framework; no VMs to slow down execution and limit what you can do with the system.  He also mentioned that all FireMonkey controls are drawn with vector graphics, leveraging the GPU, so everything scales properly. (Even at high DPI! Finally!)  He also mentioned that FireMonkey &#8220;is not a game engine,&#8221; despite all the heavy graphical focus, but it&#8217;s a general-purpose application development framework.  I found that interesting because of what happened next.</p>
<p>Next came a bunch of FireMonkey demos by Anders Ohlsson.  He showed various instances of graphics and 3D objects rotating and moving around on-screen.  One very noticeable issue with the demos was that when he made the window larger, everything got slower.  He mentioned that this was because the animation was linked to the Application.OnIdle event.  I found this a bit funny because &#8220;FireMonkey is not a game engine,&#8221; but if it was, they would have a <em>game timer</em> available, which you can hook into Application.OnIdle to decouple animation from the system &#8220;heartbeat&#8221; and provide a constant rate of speed even with varying levels of processing power.  (I talked to him afterwards and explained the basic principle, and he came back about half an hour later to show me everything running nice and smooth and at a consistent rate on his demos, so that&#8217;s cool.  Maybe someone will make a game timer component for FireMonkey.)</p>
<p>He also showed off an impressive collection of GPU-based shaders that can be applied to FireMonkey objects in real time.  There are shaders that can add color effects, distortions, or transitions from one image to another, and they can be &#8220;stacked&#8221; to apply multiple shaders to the same object or scene.</p>
<p>I went to look at the shader language code that implements the shaders, though, and I was very disappointed to see that they were not implemented with readability in mind.  There are 3 versions of each shader, one for DirectX, one for OpenGL, and one for OpenGL ES (for mobile devices).  The DirectX ones are implemented as byte arrays of compiled shader code, and the GL ones are in ARB (low-level &#8220;shader assembly code&#8221;).  The GLES shaders are in GLSL (a higher-level &#8220;GL Shader Language&#8221;,) but written in a highly unreadable style.  I asked in Q&amp;A if they had deliberately obfuscated the shaders, which makes them hard to read and study and would certainly make it harder for third parties to create new shader effects.  Michael Swindell assured me that that was certainly not the objective, and said he&#8217;d look into it and try to ensure that the shaders were easier to work with in the future.</p>
<p>They talked about a few other things related to mobile development, but it was really the FireMonkey stuff that stood out and caught everyone&#8217;s attention.  As Nick Hodges said yesterday when a bunch of us were talking, FireMonkey is conceptually the correct solution for Delphi cross-platform development, and a lot better than the QT-based idea they were working on last year.  Time will tell how well they&#8217;ll do with maturing it and promoting it, but for the moment I&#8217;m cautiously optimistic for the future of Delphi and the FireMonkey framework.</p>
]]></content:encoded>
			<wfw:commentRss>http://tech.turbu-rpg.com/365/delphilive-keynote-overview/feed</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>XE2: TValue is much faster now</title>
		<link>http://tech.turbu-rpg.com/363/xe2-tvalue-is-much-faster-now</link>
		<comments>http://tech.turbu-rpg.com/363/xe2-tvalue-is-much-faster-now#comments</comments>
		<pubDate>Wed, 07 Sep 2011 17:35:58 +0000</pubDate>
		<dc:creator>Mason Wheeler</dc:creator>
				<category><![CDATA[Delphi]]></category>
		<category><![CDATA[Delphi XE2]]></category>
		<category><![CDATA[RTTI]]></category>

		<guid isPermaLink="false">http://tech.turbu-rpg.com/?p=363</guid>
		<description><![CDATA[About a year and a half ago, I reported on how slow the original implementation of TValue in Delphi 2010 was, touching off a storm of comments and various other blog posts as other Delphi community members conducted similar experiments.  One thing that came out of it was a suggestion by Robert Love on how [...]]]></description>
			<content:encoded><![CDATA[<p>About a year and a half ago, <a href="http://tech.turbu-rpg.com/100/tvalue-is-very-slow">I reported on how slow the original implementation of TValue in Delphi 2010 was</a>, touching off a storm of comments and various other blog posts as other Delphi community members conducted similar experiments.  One thing that came out of it was a suggestion by Robert Love on how to improve performance by adding code to optimize for the most common cases.<span id="more-363"></span></p>
<p>I expanded on his idea and sent a suggested implementation to Barry Kelly.  Unfortunately, it didn&#8217;t make it into XE, but it&#8217;s in XE2 now.  It&#8217;s not exactly the code I suggested&#8211;a few things have changed in the way TValue works internally since D2010, and there&#8217;s at least one bugfix that I can see&#8211;but the basic idea is there.  When storing values into a TValue and retrieving them again, there&#8217;s special code to set and retrieve the most common types directly, without having to go into the generic RTTI-based (much slower) conversion routines.</p>
<p>I reran the timing test under XE2, and the results were much better this time:</p>
<p>Variants: 2140<br />
TValues: 2895</p>
<p>Still about 30% slower than Variants, but at least it&#8217;s not 2000% slower anymore.  Thanks, Barry, and thanks to Robert too for the original suggestion!</p>
]]></content:encoded>
			<wfw:commentRss>http://tech.turbu-rpg.com/363/xe2-tvalue-is-much-faster-now/feed</wfw:commentRss>
		<slash:comments>9</slash:comments>
		</item>
		<item>
		<title>XE2: New Delphi, same old broken installer</title>
		<link>http://tech.turbu-rpg.com/360/xe2-new-delphi-same-old-broken-installer</link>
		<comments>http://tech.turbu-rpg.com/360/xe2-new-delphi-same-old-broken-installer#comments</comments>
		<pubDate>Thu, 01 Sep 2011 18:06:16 +0000</pubDate>
		<dc:creator>Mason Wheeler</dc:creator>
				<category><![CDATA[Delphi]]></category>
		<category><![CDATA[Delphi XE2]]></category>
		<category><![CDATA[Installation]]></category>

		<guid isPermaLink="false">http://tech.turbu-rpg.com/?p=360</guid>
		<description><![CDATA[Since D2009 at least, I&#8217;ve never managed to get a new Delphi release to install correctly on the first try.  Each time, it&#8217;s been the same basic problem.  Each time, I&#8217;ve contacted Embarcadero about it and asked them to fix it.  Unfortunately, they still haven&#8217;t. I got my SA notification and went to install Delphi [...]]]></description>
			<content:encoded><![CDATA[<p>Since D2009 at least, I&#8217;ve never managed to get a new Delphi release to install correctly on the first try.  Each time, it&#8217;s been the same basic problem.  Each time, I&#8217;ve contacted Embarcadero about it and asked them to fix it.  Unfortunately, they still haven&#8217;t.<span id="more-360"></span></p>
<p>I got my SA notification and went to install Delphi XE2 today.  I&#8217;m a SA holder for Delphi Professional, which is what I got a serial number for, which I entered when the installer prompted me for it.  But that&#8217;s not what it installed.  See, if you&#8217;ve had a previous installation of a different SKU level, (a demo, for example, which always seems to be Architect level,) it will disregard the serial number you enter (even though it makes sure that you enter a valid serial!) and install the feature set for what the leftover license file specified.</p>
<p>I&#8217;ve seen a lot of bugs in a lot of software in my day, but there have been very few that <em>mystify</em> me as much as this one.  I don&#8217;t understand how it is possible to screw this up.  Taking input directly from the user and acting on it is the most basic principle of software design there is!  It&#8217;s the first thing any of us learn, usually even before &#8220;simpler&#8221; programs such as Hello World.  You prompt the user for input, and you act on it.  But somehow, the Delphi installer prompts the user for input, and then&#8230; disregards it and acts on something completely different if it&#8217;s available?  What is this I don&#8217;t even</p>
<p>How?!?  This is not an easy mistake to make; you really have to go out of your way to screw something this simple up!  (To add insult to injury, the License Manager tool conveniently provided by Embarcadero, presumably for managing your licenses, can find the invalid licenses, and there&#8217;s a Delete menu item, but it&#8217;s always grayed out.  I&#8217;ve never figured out anything that will actually enable the Delete option.)</p>
<p>It gets worse.  The installer doesn&#8217;t really understand the implications of choosing not to install things.  For example, I chose not to install the iOS development stuff because I have no use for it.  It still spent several minutes downloading the package, which is quite large and whatever server it&#8217;s downloading from doesn&#8217;t have the world&#8217;s greatest bandwidth.</p>
<p>And it will still display and require you to agree to EULAs for bundled third-party components you tell it not to install.  I can&#8217;t help but wonder about the legal ramifications to that&#8230;</p>
<p>Dear Embarcadero,</p>
<p>Your installer sucks.  Please fix it.  It&#8217;s the first impression a new customer gets of the quality of your engineering, even before using the new product, and it makes Delphi look bad.</p>
<p>Sincerely,</p>
<p>Everyone who has to put up with it</p>
]]></content:encoded>
			<wfw:commentRss>http://tech.turbu-rpg.com/360/xe2-new-delphi-same-old-broken-installer/feed</wfw:commentRss>
		<slash:comments>8</slash:comments>
		</item>
	</channel>
</rss>

