<?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>DanielWaechter.com &#187; Game development</title>
	<atom:link href="http://blog.danielwaechter.com/tag/game-development/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.danielwaechter.com</link>
	<description>just another geek blog</description>
	<lastBuildDate>Fri, 11 Jul 2008 01:33:08 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>The Long Road Back to C++</title>
		<link>http://blog.danielwaechter.com/programming/the-long-road-back-to-cpp/</link>
		<comments>http://blog.danielwaechter.com/programming/the-long-road-back-to-cpp/#comments</comments>
		<pubDate>Thu, 10 Jul 2008 01:30:34 +0000</pubDate>
		<dc:creator>Daniel Waechter</dc:creator>
				<category><![CDATA[C]]></category>
		<category><![CDATA[C++]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Game development]]></category>
		<category><![CDATA[Rant]]></category>
		<category><![CDATA[Web development]]></category>

		<guid isPermaLink="false">http://blog.danielwaechter.com/?p=13</guid>
		<description><![CDATA[]]></description>
			<content:encoded><![CDATA[<h3>Where I&#8217;m Coming From</h3>
<p>I used to be very much a &#8220;C&#8221; guy.  After learning BASIC and Pascal in my early teens, I cut my chops on C and &#8211; despite a few struggles &#8211; fell in love with it.  The language felt right; it was close to the metal, but far enough away that programming it it could be pleasant.  It helped me truly build a model of computation in my head which I think has served me well.</p>
<p>After getting into the web industry, however, I began to leave C behind.  I coded in it less and less, since the industry outside of J2EE pretty much runs on dynamic languages (at that time, Perl &#8211; now PHP, ASP, Python, etc.).  These languages always felt a little messy to me; I didn&#8217;t know what was really going on at the metal any more, like it felt like I did with C.  Automatic memory management felt like a black box, and it always seemed I couldn&#8217;t optimize my data structures except at the algorithm level.  And even then, who knew what the GC was doing in the background.</p>
<p>Over time, however, I came to embrace them &#8211; even to the point of spending a good deal of my free time playing in Lisp, Scheme, and SmallTalk.  With processing power and memory becoming cheaper and cheaper, it was less necessary to worry about the overhead in dynamic languages, at least for my purposes.  They tend to run plenty fast enough for web applications (where most performance problems are I/O- or DB-bound), and if they don&#8217;t then there&#8217;s always caching or throwing more hardware at the problem.  If you know what you&#8217;re doing, the medium lends itself to the dynamic language programming style very well.  It&#8217;s a common joke that PHP&#8217;s memory leaks don&#8217;t matter if a page request only lasts a second, and it&#8217;s basically true; who cares about optimizing a process that works to your needs?  Reach the equilibrium between programmer time and project requirements, then move on to the next thing.</p>
<p>My old self would scoff at that attitude.  It seems lazy, and it is.  It still makes me uncomfortable.  But it&#8217;s the way the web industry is built; the seat-of-the-pants, fly-by-night, hack-it-till-you-make-it attitude.</p>
<h3>Where I&#8217;d Like To Go</h3>
<p>However, I&#8217;ve got a bit of a problem.  A long-time goal of mine has been to get into the PC game industry, ever since I wrote my first &#8220;Hello, World&#8221; in BASIC when I was 12.  A kid getting into programming to write games is almost cliche, but it&#8217;s true; there are few teenagers that dream about writing database software or eCommerce sites.  When we grow up our tastes often change, but sometimes they don&#8217;t.  Case in point:  after a decade in the web industry, I <i>still</i> want to work on real, wide-release, 3d games for a living.</p>
<p>There&#8217;s a small problem with moving to the game industry after the web industry, however.  The programming culture is almost entirely different.  The dynamic languages that I&#8217;ve mostly been immersed in at work &#8211; except for C# &#8211; are relegated to scripting in the game industry.  Real developer positions, for the foreseeable future, have one almost ubiquitous language: C++.</p>
<p>That&#8217;s changing, somewhat, of course.  Some development houses I understand are moving to C#, especially Xbox developers.  Microsoft is pushing <a href="http://en.wikipedia.org/wiki/Microsoft_XNA">XNA</a>, which runs on .NET.  Then there are other enterprising folks who <a href="http://en.wikipedia.org/wiki/Game_Oriented_Assembly_Lisp">refuse to conform</a>.  But for most places, C++ still seems to be the language of choice for PC games.</p>
<p>So, basically, I made a choice.  A while ago, I started sharpening my C++ skills again.</p>
<h3>The Long Road Ahead</h3>
<p>Now, in the hierarchy of languages that I enjoy coding in, C++ ranks somewhere above <a href="http://en.wikipedia.org/wiki/COBOL">COBOL</a> but below <a href="http://en.wikipedia.org/wiki/Logo_(programming_language)">Logo</a>; it is a complicated beast of a thing, with so many gotchas and corner cases that I&#8217;m sure it would make a Pharisee sweat.  I actually derive real pleasure from the rantings of <a href="http://yosefk.com/">Yossi Kreinin</a> in his <a href="http://yosefk.com/c++fqa/">C++ FQA Lite</a>; even when I think he&#8217;s being somewhat unfair to the <a href="http://www.parashift.com/c++-faq-lite/">C++ FAQ</a> authors, and even when I disagree with him on substantive issues, he still usually has interesting criticisms.</p>
<p>So, if I am so critical of C++, why am I studying it?  Very simply &#8211; because C++ is still the industry language for game development.  This is true just as much for historical reasons as it is for practical ones; arguably, there are better languages than C++ at the same level, without turning to dynamic or managed languages.  But industry standard is industry standard, and until that tide turns, those of us who&#8217;d like to work with that industry have to tag along.</p>
<p>Now, I consider myself fairly proficient with C++ for someone who hasn&#8217;t shipped anything in it (it&#8217;s not exactly number one in my current field).  I have most of the important bits of the language in my head, and I&#8217;m aware of things like <a href="http://en.wikipedia.org/wiki/Resource_acquisition_is_initialization">RAII</a> and how to implement patterns, etc.  I&#8217;ve read Scott Meyer&#8217;s <a href="http://www.amazon.com/gp/redirect.html?ie=UTF8&#038;location=http%3A%2F%2Fwww.amazon.com%2FEffective-Specific-Addison-Wesley-Professional-Computing%2Fdp%2F0201924889&#038;tag=garthnaksjour-20&#038;linkCode=ur2&#038;camp=1789&#038;creative=9325">two</a><img src="http://www.assoc-amazon.com/e/ir?t=garthnaksjour-20&amp;l=ur2&amp;o=1" width="1" height="1" alt="" style="border:none !important; margin:0px !important;" /> <a href="http://www.amazon.com/gp/redirect.html?ie=UTF8&#038;location=http%3A%2F%2Fwww.amazon.com%2FMore-Effective-Addison-Wesley-Professional-Computing%2Fdp%2F020163371X&#038;tag=garthnaksjour-20&#038;linkCode=ur2&#038;camp=1789&#038;creative=9325">books</a><img src="http://www.assoc-amazon.com/e/ir?t=garthnaksjour-20&amp;l=ur2&amp;o=1" width="1" height="1" alt="" style="border:none !important; margin:0px !important;" /> (though I haven&#8217;t fully internalized it all), and I&#8217;ve even <em>built stuff</em> in the language.</p>
<p>That said, it easily takes me up to two to ten times longer to implement <em>and debug</em> C++ code than in a dynamic language like Ruby or Lisp, depending on the complexity.  Part of that is, of course, the language (and implementations) &#8211; no lexical closures (<a href="#C++0x">yet</a>), no first-class functions (<a href="#Cpp0x">yet</a>) (function pointers don&#8217;t count), no <a href="http://en.wikipedia.org/wiki/Multiple_dispatch">multiple dispatch</a> (if you&#8217;ve never used it, it is <strong>unbelievably useful</strong>), gratuitous overloading of C keywords (like &#8220;static&#8221;), no standard ABI, private variables stored in header files (I understand why, and it can be avoided with <a href="http://en.wikipedia.org/wiki/Pimpl">pimpl</a>, but it still bothers me), cryptic error messages (especially for templates, but other times as well), slow compilation&#8230;I can go on.  One of the more irritating things is the default copy-constructors, and these days I just throw <a href="http://www.boost.org/doc/libs/1_35_0/boost/noncopyable.hpp">boost::noncopyable</a> onto my classes unless I know consumers will need it (which is less often than you may think).</p>
<p><a name="Cpp0x" href="http://en.wikipedia.org/wiki/C%2B%2B0x">C++0x</a> has some improvements.  For example, I can&#8217;t wait for <a href="http://herbsutter.wordpress.com/2008/06/20/type-inference-vs-staticdynamic-typing/">type inference</a>; if the compiler can figure out what type I want, then why should I spell it out every time (though there are some limitations<sup><a href="#tlrbtc_fn1" name="tlrbtc_fn1_ref">1</a></sup>)?  Even better, we&#8217;re going to have <a href="http://herbsutter.wordpress.com/2008/03/29/trip-report-februarymarch-2008-iso-c-standards-meeting/">real lambdas and closures</a>!  But who knows how long it&#8217;ll take to implement &#8211; we&#8217;re <a href="http://en.wikipedia.org/wiki/C99#Support_by_major_compilers">still</a> <a href="http://gcc.gnu.org/c99status.html">waiting</a> for C99.  Hopefully we&#8217;ll at least get early uptake of the most important features.  <a href="http://en.wikipedia.org/wiki/Technical_Report_1">TR1</a> is already <a href="http://blogs.msdn.com/vcblog/archive/2008/01/08/q-a-on-our-tr1-implementation.aspx">available for VC9</a>.</p>
<h3>Qi&#x0101;n L&#464; Zh&#x012B; H&aacute;ng, Sh&#464; Y&uacute; Z&uacute; Xi&agrave;<sup><a href="#tlrbtc_fn2" name="tlrbtc_fn2_ref">2</a></sup></h3>
<p>I still have a ways to go.  I&#8217;m in the playing around with various projects in C++, trying to be idiomatic rather than cute or clever.  At the same time, I&#8217;m going through Sutter&#8217;s <a href="http://www.amazon.com/gp/redirect.html?ie=UTF8&#038;location=http%3A%2F%2Fwww.amazon.com%2FExceptional-Engineering-Programming-Solutions-Depth%2Fdp%2F0201615622&#038;tag=garthnaksjour-20&#038;linkCode=ur2&#038;camp=1789&#038;creative=9325">Exceptional C++</a><img src="http://www.assoc-amazon.com/e/ir?t=garthnaksjour-20&amp;l=ur2&amp;o=1" width="1" height="1" alt="" style="border:none !important; margin:0px !important;" /> and <a href="http://www.amazon.com/gp/redirect.html?ie=UTF8&#038;location=http%3A%2F%2Fwww.amazon.com%2FCoding-Standards-Guidelines-Practices-Depth%2Fdp%2F0321113586&#038;tag=garthnaksjour-20&#038;linkCode=ur2&#038;camp=1789&#038;creative=9325">C++ Coding Standards</a><img src="http://www.assoc-amazon.com/e/ir?t=garthnaksjour-20&amp;l=ur2&amp;o=1" width="1" height="1" alt="" style="border:none !important; margin:0px !important;" />, internalizing good habits.  It&#8217;s a little tough returning to the world of static typing, (semi-)manual memory management, and complex builds after such a long hiatus, but it&#8217;s worth the rewards.  A longtime dream realized&mdash;becoming a real game developer.</p>
<p>I welcome the challenge.</p>
<div class="footnotes">
<p><sup><a name="tlrbtc_fn1" href="#tlrbtc_fn1_ref">1</a></sup>For example, if you create a <code>vector&lt;int&gt; v</code>, you might want to retrieve a <code>::const_iterator</code> from <code>v.begin()</code>.  Unfortunately, <code>auto i = v.begin()</code> will only return the most obvious type, which in this case is a plain <code>::iterator</code>, and there doesn&#8217;t seem to be a way to specify an alternate.  You&#8217;ll still have to specify <code>vector&lt;int&gt;::const_iterator ci = v.begin()</code>.  Oh well.</p>
<p><sup><a name="tlrbtc_fn2" href="#tlrbtc_fn2_ref">2</a></sup>&#8220;A journey of a thousand <i>li</i> starts with a single step.&#8221; -<a href="http://en.wikipedia.org/wiki/Laozi">Laozi</a></p>
</div>
]]></content:encoded>
			<wfw:commentRss>http://blog.danielwaechter.com/programming/the-long-road-back-to-cpp/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
	</channel>
</rss>

<!-- Performance optimized by W3 Total Cache. Learn more: http://www.w3-edge.com/wordpress-plugins/

Minified using disk
Page Caching using disk (enhanced)
Database Caching using disk

Served from: blog.danielwaechter.com @ 2010-09-08 14:20:14 -->