<?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/"
	xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
	>

<channel>
	<title>Ben Garney</title>
	<atom:link href="http://blog.bengarney.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.bengarney.com</link>
	<description>Mobile &#38; Web Game Technology</description>
	<lastBuildDate>Mon, 20 May 2013 03:29:33 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
<cloud domain='blog.bengarney.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://s2.wp.com/i/buttonw-com.png</url>
		<title>Ben Garney</title>
		<link>http://blog.bengarney.com</link>
	</image>
	<atom:link rel="search" type="application/opensearchdescription+xml" href="http://blog.bengarney.com/osd.xml" title="Ben Garney" />
	<atom:link rel='hub' href='http://blog.bengarney.com/?pushpress=hub'/>
		<item>
		<title>The Draw-Render-Update Conspiracy</title>
		<link>http://blog.bengarney.com/2013/05/19/the-draw-render-update-conspiracy/</link>
		<comments>http://blog.bengarney.com/2013/05/19/the-draw-render-update-conspiracy/#comments</comments>
		<pubDate>Sun, 19 May 2013 22:38:14 +0000</pubDate>
		<dc:creator>Ben Garney</dc:creator>
				<category><![CDATA[Opinion]]></category>

		<guid isPermaLink="false">http://blog.bengarney.com/?p=1354</guid>
		<description><![CDATA[I love clear terminology. It&#8217;s the engineer in me. This post is about some self-perpetuating terminology that confused me as a new developer. The confusion centers around functions named draw() or renderFoo(). As a new developer, you get excited &#8211; &#8220;Ah hah!&#8221; you think to yourself, &#8220;I am about to see something cool go down here.&#8221; So you pop [&#8230;]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=blog.bengarney.com&#038;blog=106034&#038;post=1354&#038;subd=bengarney&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
				<content:encoded><![CDATA[<p><strong>I love clear terminology.</strong> It&#8217;s the engineer in me. This post is about some self-perpetuating terminology that confused me as a new developer.</p>
<p><strong>The confusion centers around functions named <em>draw()</em> or <em>renderFoo()</em></strong><em><strong>.</strong> </em>As a new developer, you get excited &#8211; &#8220;Ah hah!&#8221; you think to yourself, &#8220;I am about to see something cool go down here.&#8221; So you pop open the function, and it&#8217;s setting the x coordinate or changing a color on some other data structure. &#8220;WTF! There&#8217;s no drawing or rendering happening here!&#8221; you say, disgusted and confused. Or worse, you assume that changing those values has any immediate effect beyond altering a few bytes in memory &#8211; and ascribe magical behavior to that section of the code, corrupting your ability to understand and debug.</p>
<p>The reality, of course, is that the actual drawing &#8211; in terms of commands to change pixels on the screen &#8211; is happening elsewhere, deep in the bowels of some fanatically optimized inner loop (you hope). <strong>The <em>draw()</em> function is just updating some data that is used elsewhere. </strong>It&#8217;s not drawing anything, any more than telling your painter what color you want your bathroom is painting. That&#8217;s why I try to name them things like <em>update()</em>.</p>
<p><strong>But naming functions update() where the conspiracy gets ahold of me.</strong> I&#8217;ve already been disappointed by functions named <em>draw</em> and <em>render, </em>that don&#8217;t do either, for years. I&#8217;ve become cynical. &#8220;Well, everyone knows you don&#8217;t ACTUALLY render anything in your <em>render</em> function. It&#8217;s just a state update. It&#8217;s this code&#8217;s perspective on what rendering means.&#8221; And due to this etymological relativism, I write functions called <em>renderToast</em> that don&#8217;t really have anything to do with displaying charred bread products.</p>
<p><strong>What&#8217;s the moral of this story?</strong> The trivial one is &#8220;name stuff accurately.&#8221; But the rot has already set in, and language is situational and metaphoric. So the real takeaway is for those who aren&#8217;t on the &#8220;inside&#8221; of the conspiracy, a warning &#8211; things aren&#8217;t always what they seem. Don&#8217;t trust that <em>draw</em> function until you really know what it is doing. <strong>Always read the whole codebase!</strong></p>
<p>(And &#8211; OK, maybe it&#8217;s more of a <a title="stand alone complex" href="http://en.wikipedia.org/wiki/Philosophy_of_Ghost_in_the_Shell#Stand_Alone_Complex">stand alone complex</a> than a conspiracy, if we want to be really specific.)</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/bengarney.wordpress.com/1354/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/bengarney.wordpress.com/1354/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=blog.bengarney.com&#038;blog=106034&#038;post=1354&#038;subd=bengarney&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://blog.bengarney.com/2013/05/19/the-draw-render-update-conspiracy/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/08cfb70f32d12a81926575e0a3fc2d4e?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">bengarney</media:title>
		</media:content>
	</item>
		<item>
		<title>Flatten Your Conditionals!</title>
		<link>http://blog.bengarney.com/2013/05/11/flatten-your-conditionals/</link>
		<comments>http://blog.bengarney.com/2013/05/11/flatten-your-conditionals/#comments</comments>
		<pubDate>Sun, 12 May 2013 03:28:09 +0000</pubDate>
		<dc:creator>Ben Garney</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[How To]]></category>
		<category><![CDATA[Opinion]]></category>

		<guid isPermaLink="false">http://blog.bengarney.com/?p=1344</guid>
		<description><![CDATA[Deep nesting is a pet peeve of mine. I&#8217;m going to show you what deeply nested code is and discuss some strategies for keeping things tidy. It&#8217;s my opinion that deep nesting is a sign of sloppy code. You know, code like this (with my condolences to the author): This code is hard to understand. [&#8230;]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=blog.bengarney.com&#038;blog=106034&#038;post=1344&#038;subd=bengarney&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
				<content:encoded><![CDATA[<p><strong>Deep nesting is a pet peeve of mine. </strong>I&#8217;m going to show you what deeply nested code is and discuss some strategies for keeping things tidy. It&#8217;s my opinion that deep nesting is a sign of sloppy code.</p>
<p>You know, code like this (with my condolences to the author):</p>
<pre class="brush: objc; title: ; notranslate">
    if (productId != nil) {

        NSLog(@&quot;EBPurchase requestProduct: %@&quot;, productId);

        if ([SKPaymentQueue canMakePayments]) {
            // Yes, In-App Purchase is enabled on this device.
            // Proceed to fetch available In-App Purchase items.

            // Initiate a product request of the Product ID.
            SKProductsRequest *prodRequest = [[SKProductsRequest alloc] initWithProductIdentifiers:[NSSet setWithObject:productId]];
            prodRequest.delegate = self;
            [prodRequest start];
            [prodRequest release];

            return YES;

        } else {
            // Notify user that In-App Purchase is Disabled.

            NSLog(@&quot;EBPurchase requestProduct: IAP Disabled&quot;);

            return NO;
        }

    } else {

        NSLog(@&quot;EBPurchase requestProduct: productId = NIL&quot;);

        return NO;
    }
</pre>
<p><strong>This code is hard to understand.</strong> It&#8217;s hard to understand because error handling is distant from the error checks (for instance, the check for nil is at the beginning but the error and return are at the end!). It&#8217;s hard to understand because the important parts are deeply indented, giving you less headroom. If you want to add additional checks, it&#8217;s hard to know where to add them &#8211; and you have to touch lots of unrelated lines to change indent level. And there are many exit points scattered throughout. GROSS.</p>
<p>Whenever I see code like this I cringe. When I get the chance, <strong>I like to untangle it </strong>(or even catch it in code review)<strong>.</strong> It&#8217;s soothing, simple work. To be sure, the functionality of the code is fine &#8211; it&#8217;s purely how it is written that annoys me.</p>
<p>There&#8217;s a key thing to be aware of in the structure of this code &#8211; it has a bunch of early outs related to error handling. This is a common pattern so it&#8217;s worth walking through the cleanup process. Let&#8217;s pull the first block out:</p>
<pre class="brush: objc; title: ; notranslate">
    if(productId == nil)
    {
        NSLog(@&quot;EBPurchase requestProduct: productId = NIL&quot;);
        return NO;
    }

    NSLog(@&quot;EBPurchase requestProduct: %@&quot;, productId);

    if ([SKPaymentQueue canMakePayments] == YES)
    {
        // Initiate a product request of the Product ID.
        SKProductsRequest *prodRequest = [[SKProductsRequest alloc] initWithProductIdentifiers:[NSSet setWithObject:productId]];
        prodRequest.delegate = self;
        [prodRequest start];
        [prodRequest release];

        return YES;
    }
    else
    {
        // Notify user that In-App Purchase is Disabled.
        NSLog(@&quot;EBPurchase requestProduct: IAP Disabled&quot;);
        return NO;
    }

    // Never get here.
    return NO;
</pre>
<p>It&#8217;s a LOT better, but now we have a return that can never be run. Some error handling code is still far from the error detecting code. So still a little messy. Let&#8217;s do the same cleanup again on the second block:</p>
<pre class="brush: objc; title: ; notranslate">
    if(productId == nil)
    {
        NSLog(@&quot;EBPurchase requestProduct: productId = NIL&quot;);
        return NO;
    }

    NSLog(@&quot;EBPurchase requestProduct: %@&quot;, productId);

    if ([SKPaymentQueue canMakePayments] == NO)
    {
        // Notify user that In-App Purchase is Disabled.
        NSLog(@&quot;EBPurchase requestProduct: IAP Disabled&quot;);
        return NO;
    }

    // Initiate a product request of the Product ID.
    SKProductsRequest *prodRequest = [[SKProductsRequest alloc] initWithProductIdentifiers:[NSSet setWithObject:productId]];
    prodRequest.delegate = self;
    [prodRequest start];
    [prodRequest release];

    return YES;
</pre>
<p>See how much cleaner that is? Beyond saving indents, it also exposes the structure of the algorithm a great deal more clearly &#8211; check it out:</p>
<ol>
<li>Check for nil productId; bail if absent.</li>
<li>Log productId if it is present.</li>
<li>Check if we can make payments/IAP is active; bail if not.</li>
<li>Submit the product info request.</li>
<li>Return success!</li>
</ol>
<p>The code and its &#8220;flowchart&#8221; now match up nicely, and if you modify one, it&#8217;s easy to identify the change in the other. This might seem like a little thing, but I find it shows that the purpose + structure of the function is well set up. And <strong>if you can&#8217;t write the function without violating this rule, it&#8217;s often a very solid clue</strong> you need to introduce some more abstraction &#8211; tactics such as breaking stuff up into helper methods, reorganizing your data structures a little bit, centralizing lookups/checks, and so on.</p>
<p><strong>Something to keep in mind next time you find yourself hitting tab more than a couple times &#8211; flatten your conditionals!</strong></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/bengarney.wordpress.com/1344/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/bengarney.wordpress.com/1344/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=blog.bengarney.com&#038;blog=106034&#038;post=1344&#038;subd=bengarney&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://blog.bengarney.com/2013/05/11/flatten-your-conditionals/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/08cfb70f32d12a81926575e0a3fc2d4e?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">bengarney</media:title>
		</media:content>
	</item>
		<item>
		<title>Ludum Dare 26 &amp; Loom</title>
		<link>http://blog.bengarney.com/2013/04/26/ludum-dare-26-loom/</link>
		<comments>http://blog.bengarney.com/2013/04/26/ludum-dare-26-loom/#comments</comments>
		<pubDate>Fri, 26 Apr 2013 19:17:14 +0000</pubDate>
		<dc:creator>Ben Garney</dc:creator>
				<category><![CDATA[Opinion]]></category>

		<guid isPermaLink="false">http://blog.bengarney.com/?p=1303</guid>
		<description><![CDATA[Are you a fan of Ludum Dare? I&#8217;ve loved watching it for a long time. The huge community of excited developers is fantastic to watch, and some great games come out every time. More than that, LD is a great opportunity. In fact, such a good opportunity that we&#8217;re giving LD participants a huge deal [&#8230;]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=blog.bengarney.com&#038;blog=106034&#038;post=1303&#038;subd=bengarney&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
				<content:encoded><![CDATA[<p>Are you a fan of <a href="http://www.ludumdare.com/compo/">Ludum Dare</a>? I&#8217;ve loved watching it for a long time. The huge community of excited developers is fantastic to watch, and some great games come out every time. More than that, LD is a great <strong>opportunity</strong>. In fact, such a good opportunity that we&#8217;re giving LD participants a huge deal on Loom (but more on that later).</p>
<p>The incredible opportunity in an event like LD is that it gets you to <strong>finish something</strong>. It&#8217;s so common for projects to run on and on and on and on&#8230; Professionally, you could work in AAA games for a decade and only ship a few games. Imagine being a professional painter and only making 10 paintings in your whole career.</p>
<p>There are big lessons you <strong>only</strong> learn when you finish. Like &#8211; was the feature you spent 80% of your time working on what made the game fun, or was it the feature you added at the last minute on a lark that made the whole game work? Is your gameplay immediately understandable? How much is your fun driven by content vs. gameplay? What dumb things kept people from enjoying your game (like missing DLLs, unclear instructions, installer issues, and so on)? What REALLY goes into the last 20% it takes to ship?</p>
<p>You also get the big endorphin rush of <strong>release</strong><strong>! </strong>It feels GOOD to ship. Even if you decide the project was a failure, completing it is good. You can put it on the shelf and refer to it later. And it&#8217;s motivating to know you&#8217;ve gotten something DONE and don&#8217;t have to think about it any longer.</p>
<p>It&#8217;s easy to get stuck in the <strong>doldrums of project creation</strong>. You end up going around and around creating new things on new tech. It&#8217;s shiny and in some ways fun, but you never experience the growth and maturation that comes from shipping and sharing your creation with the world. Shipping &#8211; even something small &#8211; gets you out of that rut.</p>
<p>Take some time and <a href="http://www.ludumdare.com/compo/">participate in Ludum Dare 26</a>. Creating and finishing a small game project is one of <strong>the best investments</strong> you can make in yourself &#8211; not just as a game developer but as a professional. It&#8217;s easy to overlook how valuable this can be.</p>
<p>And of course &#8211; Loom is a great fit for making small games fast. Through LD26, use the code <strong>GO_LD26 </strong>to get 50% off all <a href="https://theengine.co/subscribe">Loom subscriptions</a>. <a href="https://theengine.co/subscribe"><strong>Get Loom and go make something cool!</strong></a></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/bengarney.wordpress.com/1303/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/bengarney.wordpress.com/1303/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=blog.bengarney.com&#038;blog=106034&#038;post=1303&#038;subd=bengarney&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://blog.bengarney.com/2013/04/26/ludum-dare-26-loom/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/08cfb70f32d12a81926575e0a3fc2d4e?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">bengarney</media:title>
		</media:content>
	</item>
		<item>
		<title>Loom is Launched!</title>
		<link>http://blog.bengarney.com/2013/02/28/loom-is-launched/</link>
		<comments>http://blog.bengarney.com/2013/02/28/loom-is-launched/#comments</comments>
		<pubDate>Fri, 01 Mar 2013 07:58:59 +0000</pubDate>
		<dc:creator>Ben Garney</dc:creator>
				<category><![CDATA[Opinion]]></category>
		<category><![CDATA[loom]]></category>

		<guid isPermaLink="false">http://blog.bengarney.com/?p=1201</guid>
		<description><![CDATA[Howdy! You may have wondered what I&#8217;ve been up to since PushButton Labs and PushButton Engine. Nate Beck, Josh Engebretson, and I are proud to share our latest creation, the Loom Game Engine, with the world. It&#8217;s a native mobile game engine with live reloading of code and assets, a great command line workflow, and [&#8230;]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=blog.bengarney.com&#038;blog=106034&#038;post=1201&#038;subd=bengarney&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
				<content:encoded><![CDATA[<p style="text-align:center;"><a href="http://bengarney.files.wordpress.com/2013/02/screen-shot-2013-02-28-at-11-59-20-pm.png"><img class="aligncenter size-medium wp-image-1300" alt="Screen Shot 2013-02-28 at 11.59.20 PM" src="http://bengarney.files.wordpress.com/2013/02/screen-shot-2013-02-28-at-11-59-20-pm.png?w=300&#038;h=217" width="300" height="217" /></a></p>
<p>Howdy!</p>
<p>You may have wondered what I&#8217;ve been up to since PushButton Labs and PushButton Engine. Nate Beck, Josh Engebretson, and I are proud to share our latest creation, the <a href="http://theengine.co/" target="_blank">Loom Game Engine</a>, with the world. It&#8217;s a native mobile game engine with live reloading of code and assets, a great command line workflow, and a powerful AS3-like scripting language.</p>
<p>Check out this sweet video demoing Loom:</p>
<span class='embed-youtube' style='text-align:center; display: block;'><iframe class='youtube-player' type='text/html' width='420' height='315' src='http://www.youtube.com/embed/iXPaYv_WcU8?version=3&#038;rel=1&#038;fs=1&#038;showsearch=0&#038;showinfo=1&#038;iv_load_policy=1&#038;wmode=transparent' frameborder='0'></iframe></span>
<p>We&#8217;re <strong>giving away Loom Indie Licenses (normally $500) for FREE</strong> until Mar 29, the last day of GDC. We&#8217;ve already given away almost $2,000,000 in licenses. <a href="http://theengine.co/go/free" target="_blank">Get yours now!</a></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/bengarney.wordpress.com/1201/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/bengarney.wordpress.com/1201/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=blog.bengarney.com&#038;blog=106034&#038;post=1201&#038;subd=bengarney&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://blog.bengarney.com/2013/02/28/loom-is-launched/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/08cfb70f32d12a81926575e0a3fc2d4e?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">bengarney</media:title>
		</media:content>

		<media:content url="http://bengarney.files.wordpress.com/2013/02/screen-shot-2013-02-28-at-11-59-20-pm.png?w=300" medium="image">
			<media:title type="html">Screen Shot 2013-02-28 at 11.59.20 PM</media:title>
		</media:content>
	</item>
		<item>
		<title>TCP is the worst abstraction.</title>
		<link>http://blog.bengarney.com/2012/12/08/tcp-is-the-worst-abstraction/</link>
		<comments>http://blog.bengarney.com/2012/12/08/tcp-is-the-worst-abstraction/#comments</comments>
		<pubDate>Sat, 08 Dec 2012 19:09:37 +0000</pubDate>
		<dc:creator>Ben Garney</dc:creator>
				<category><![CDATA[Opinion]]></category>

		<guid isPermaLink="false">http://blog.bengarney.com/?p=1138</guid>
		<description><![CDATA[TCP is the worst abstraction. You are hopefully familiar with Leaky Abstractions as described by Joel Spolsky. The idea is that when you add layers to hide messy details, you can mostly avoid having to know what exactly is going on &#8211; until something breaks. Think of it as putting a smooth plastic coating on your car. [&#8230;]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=blog.bengarney.com&#038;blog=106034&#038;post=1138&#038;subd=bengarney&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
				<content:encoded><![CDATA[<p>TCP is the <strong>worst</strong> abstraction.</p>
<p>You are hopefully familiar with <strong><a href="http://www.joelonsoftware.com/articles/LeakyAbstractions.html">Leaky Abstractions</a></strong> as described by Joel Spolsky. The idea is that when you add layers to hide messy details, you can mostly avoid having to know what exactly is going on &#8211; until something breaks. Think of it as putting a smooth plastic coating on your car. Everything is really simple and zero-maintenance until your engine breaks and now you&#8217;re peeling plastic back trying to figure out which part is on fire&#8230;</p>
<p>TCP makes some big promises. &#8220;Your data will magically arrive in order and on time!&#8221; &#8220;Don&#8217;t worry about it, I&#8217;ll retry for you.&#8221; &#8220;Sure &#8211; I can send any amount of data!&#8221; &#8220;Hahah, packet sizes? I&#8217;m sure we don&#8217;t have to worry about those.&#8221;</p>
<p>Let&#8217;s talk about <strong>springing leaks</strong>. Just like when your upstairs neighbor&#8217;s toilet springs a leak and you have to deal with the concrete realities that a high flow water source above your bedroom ceiling introduces, springing leaks means you can&#8217;t use your abstraction anymore &#8211; you now have to work with the underlying system, often at one remove (or more!) because you&#8217;re working through the abstraction you chose to shield you from this in the first place!</p>
<p><strong>TCP is leaky as a sieve.</strong> TCP says &#8220;I&#8217;ll just act like a stream and send bytes to someone on the internet!&#8221; But here are just a few areas where TCP breaks:</p>
<ul>
<li>If you send too much data at once (the OS buffer fills and the write fails; you then have to resend).</li>
<li>If you send too little data at a time (the OS will sometimes fix this for you, see <a href="http://en.wikipedia.org/wiki/Nagle's_algorithm">Nagle&#8217;s Algorithm</a>, which can be good or bad depending on when that data needs to go over the wire).</li>
<li>If you try to read too much data at once (again, the OS receive buffer has limited size &#8211; so you have to be able to read your data in chunks that fit inside that limit).</li>
<li>If you transfer data at the wrong rate (the <a href="http://web.eecs.utk.edu/~dunigan/tcptour/javis/tcp_slidwin.html">TCP flow control</a> rules can be a problem).</li>
<li>If you try to read too little data at a time (then OS call overhead dominates your transfer speeds).</li>
<li>If you want to assume data has arrived (it may not have, you have to peek and see how much data there is and only read if there is enough, which necessitates careful design of your protocol to accomodate this).</li>
<li>If you want to initialize a connection in a deterministic fashion. (You have to do a bunch of careful checks of domain/IP/etc. to make sure it will even go through and once the connection is initialized you have to figure out if it&#8217;s alive or not. It can also take quite a while to establish a connection and get data flowing, see efforts like <a href="http://en.wikipedia.org/wiki/SPDY">SPDY</a>)</li>
<li>If you are on a lossy network (it will incur arbitrary overhead resending lost data).</li>
<li>If you want to manage latency (you have to take care to send data in correct packet boundaries).</li>
<li>If you want to connect through a firewall (good luck with that one).</li>
<li>If you want to use nonblocking IO. (You have to do a bunch of platform specific crud and even then not all actions are nonblocking; you have to live in a separate thread and block there.)</li>
<li>If you want to run a popular service. (There are a lot of ways the OS can be tricked by outside parties into mismanaging its resources leading to starvation/denial of service attacks.)</li>
</ul>
<p>IMHO, TCP is an abstraction in name only. If you want to get any kind of decent results from it, you have to<strong> fully understand the entire stack</strong>. So now not only do you have to know everything about TCP, you have to know everything (or at least most of it) about IP, about how the OS runs its networking stack, about what tricks routers and the internet will play on you, about how your protocol&#8217;s data is set up, and so on.</p>
<p>I came to networking in a roundabout way. I did a couple of small TCP projects in my teens, but I spent most of my formative programming years (18-23 or so) working with Torque, which uses the <a href="http://en.wikipedia.org/wiki/User_Datagram_Protocol">User Datagram Protocol</a> (UDP). Here&#8217;s what UDP code looks like:</p>
<pre>// Send a packet.<br />sendto(mysocket, data, dataLen, 0, &amp;destAddress, sizeof(destAddress));<br />// Receive a packet.<br />recvfrom(mysocket, data, dataLen, 0, &amp;fromAddress, sizeof(fromAddress)); </pre>
<p>It&#8217;s very very simple and it maps almost directly to<strong> what the Internet actually gives you</strong>, which is the ability to send and receive routed packets from peers. These packets aren&#8217;t guaranteed to arrive in order nor are they guaranteed to arrive at all. In general they won&#8217;t be corrupted but it would behoove you to check that, too.</p>
<p>This is primitive, like banging two rocks together! Why do this to yourself? Well &#8211; it depends. If you just need to create some basic networking behavior and don&#8217;t care if it&#8217;s subpar, TCP works well enough, and if you have to, you can get it to sing for certain situations. And sometimes TCP is required because of firewalls or other technical issues. But <strong>if you want to build something that is native for the network, and really works well, go with UDP</strong>. UDP is a flat abstraction. You have to take responsibility for the network&#8217;s behavior and handle packet loss and misdelivery. But by doing so you can skip leaky abstractions and take full advantage of what the network can do for you.</p>
<p>Sometimes<strong> it&#8217;s better to solve hard problems up front</strong>, rather than ignoring them and hoping they go away</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/bengarney.wordpress.com/1138/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/bengarney.wordpress.com/1138/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=blog.bengarney.com&#038;blog=106034&#038;post=1138&#038;subd=bengarney&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://blog.bengarney.com/2012/12/08/tcp-is-the-worst-abstraction/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/08cfb70f32d12a81926575e0a3fc2d4e?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">bengarney</media:title>
		</media:content>
	</item>
		<item>
		<title>Some Thoughts on Build Servers</title>
		<link>http://blog.bengarney.com/2012/09/01/some-thoughts-on-build-servers/</link>
		<comments>http://blog.bengarney.com/2012/09/01/some-thoughts-on-build-servers/#comments</comments>
		<pubDate>Sun, 02 Sep 2012 00:49:54 +0000</pubDate>
		<dc:creator>Ben Garney</dc:creator>
				<category><![CDATA[Opinion]]></category>

		<guid isPermaLink="false">http://blog.bengarney.com/?p=1114</guid>
		<description><![CDATA[Continuing from last week&#8217;s thoughts about build systems, let&#8217;s talk about build servers. Say you&#8217;ve gotten a build system, like CMake, up and running in your project. Now the developers on your project are doing consistent builds across all your different platforms, and people are hopefully not missing important build steps anymore. However, there can [&#8230;]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=blog.bengarney.com&#038;blog=106034&#038;post=1114&#038;subd=bengarney&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
				<content:encoded><![CDATA[<p><img src="http://bengarney.files.wordpress.com/2012/09/screen-shot-2012-09-01-at-5-48-26-pm.png?w=660" alt="" title=""   class="alignright size-full wp-image-1131" />Continuing from <a href="http://blog.bengarney.com/2012/08/26/some-thoughts-on-build-systems/">last week&#8217;s thoughts about build systems</a>, let&#8217;s talk about <b>build servers</b>.</p>
<p>Say you&#8217;ve gotten a build system, like CMake, up and running in your project. <b>Now the developers on your project are doing consistent builds across all your different platforms</b>, and people are hopefully not missing important build steps anymore. However, there can still be differences between systems, and it&#8217;s hard for any one developer to try building on all platforms. Additionally, they could have some left over crud from old builds that throws things off.</p>
<p><b>The next step in sanity for your project workflow is to set up a build server.</b> This is a box (or boxes) that sits there and pulls down clean copies of your codebase and does full builds, from scratch, all the time. It is kept in a pristine condition so that you don&#8217;t e.g. introduce a new dependency in your production binaries by updating Visual Studio. To do these builds, it runs some continuous integration package that lets developers trigger builds, check up on their status, and view build logs to find out why things broke. CI packages can also do fancier tricks like run unit tests, upload builds to QA or even the public, tag releases, and so on. (We&#8217;ll get into advantageous use of these in a later post.)</p>
<p>There are a lot of great build server options out there, and <b>I&#8217;ve worked with or evaluated many of them</b>. Let&#8217;s walk through them in order:</p>
<p><b>Tinderbox</b> Mozilla&#8217;s <a href="https://developer.mozilla.org/en-US/docs/Tinderbox">Tinderbox</a> was one of the first public continuous integration packages. Much like <a href="http://www.bugzilla.org/">Bugzilla</a>, it was the first place many people looked &#8211; and most people moved on to look at something better suited to their needs right away. This is not necessarily a knock on Bugzilla or Tinderbox, as they and their derivatives have continued to serve Mozilla just fine over the years.</p>
<p><b>PMEase QuickBuild</b> <a href="http://www.pmease.com/">QuickBuild</a> was my first experience running a build server. We used QuickBuild 1.0 for C++ Torque builds on multiple platforms, which was weird and new &#8211; at the time, most build server packages &#8211; including this one &#8211; were very Java oriented. Luckily, we could call out to MSVC and XCode from Ant! PMEase has kept with it, and now they&#8217;re at version 4.0. I found them to have very responsive support, and QB itself was nice to configure and work with. It&#8217;s more expensive than some of the other options ($3k/site), but if you have the budget it&#8217;s worth a look.</p>
<p><b>Bamboo</b> From Atlassian, I had high hopes for <a href="http://www.atlassian.com/software/bamboo/overview">Bamboo</a>, as JIRA is a powerful and reliable tool. However, when I last evaluated it (in late 2010 or so), I found its paradigm hard to understand. I just couldn&#8217;t figure out how I was supposed to use it &#8211; it had a lot of proprietary terminology that confused me. Additionally, it did not have good support for building all topic branches, which was a big part of the workflow I wanted my team to use. Looking it over again, I&#8217;m not sure it has improved on either front. However, I hold Atlassian in fairly high regard, so I am hopeful that someone else has figured it out and can enlighten me. <img src='http://s0.wp.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p><b>Jenkins/Hudson</b> After a sale to Oracle, <a href="http://jenkins-ci.org/">Jenkins</a> was forked from Hudson to continue open source development. It runs on a wide variety of platforms, and it&#8217;s easy to set up. It has a large set of plugins of varying levels of maturity, and it&#8217;s not that hard to write your own. However, key plugins (for instance, the Git plugin) can have frustrating gaps and holes, and because it&#8217;s community driven, bugs can linger for a long time. The REST API is also weak in places, making it hard to extend with custom tools/scripts. My experience is that Jenkins is a solid choice for simpler projects but if you want to push your build server it can fall apart on you. We used it for several smaller projects, where it worked great, then we took it into a project with a large, 50+ member team of artists and developers. In that scenario, we ended up having to extend it heavily with custom scripts, mostly to add functionality it should have had to begin with.</p>
<p><b>JetBrains TeamCity</b> <a href="http://www.jetbrains.com/teamcity/">TeamCity</a> is free for lighter use, although heavier usage requires purchasing licenses from JetBrains. TeamCity has very solid Git/JIRA integration, and a well thought out UI. Setup isn&#8217;t hard and it has good support for adding distributed build agents. We&#8217;ve been very happy with it for our C++ and Ruby projects. It has good support for building topic branches, too.</p>
<p><b>In the end, what is crucial for continuous integration software?</b> It should be reliable, and especially robust in the face of broken builds. It should be easy for the team to understand and use, especially when they are debugging build issues. It should be able to scale to build across all your platforms, quickly &#8211; it shouldn&#8217;t take more than 10 minutes or so for a full build across all platforms to complete.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/bengarney.wordpress.com/1114/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/bengarney.wordpress.com/1114/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=blog.bengarney.com&#038;blog=106034&#038;post=1114&#038;subd=bengarney&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://blog.bengarney.com/2012/09/01/some-thoughts-on-build-servers/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/08cfb70f32d12a81926575e0a3fc2d4e?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">bengarney</media:title>
		</media:content>

		<media:content url="http://bengarney.files.wordpress.com/2012/09/screen-shot-2012-09-01-at-5-48-26-pm.png" medium="image" />
	</item>
		<item>
		<title>Some Thoughts on Build Systems</title>
		<link>http://blog.bengarney.com/2012/08/26/some-thoughts-on-build-systems/</link>
		<comments>http://blog.bengarney.com/2012/08/26/some-thoughts-on-build-systems/#comments</comments>
		<pubDate>Sun, 26 Aug 2012 23:40:11 +0000</pubDate>
		<dc:creator>Ben Garney</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[Opinion]]></category>

		<guid isPermaLink="false">http://blog.bengarney.com/?p=1101</guid>
		<description><![CDATA[Note: You might also want to read Some Thoughts on Build Servers, which discusses software packages for running automated builds on a shared server. The hardest part of software development is often the road from code in a repo to an artifact in the user&#8217;s hands. There are a million ways you can ruin yourself [&#8230;]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=blog.bengarney.com&#038;blog=106034&#038;post=1101&#038;subd=bengarney&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
				<content:encoded><![CDATA[<p><i>Note: You might also want to read <a href="http://blog.bengarney.com/2012/09/01/some-thoughts-on-build-servers/">Some Thoughts on Build Servers</a>, which discusses software packages for running automated builds on a shared server.</i></p>
<p><img class=" wp-image alignright" src="http://bengarney.files.wordpress.com/2012/08/smokestacks.jpg?w=345&#038;h=246" alt="Smokestacks" width="345" height="246" />The<strong> hardest part of software development</strong> is often the road from code in a repo to an artifact in the user&#8217;s hands.</p>
<p>There are a million ways you can<strong> ruin</strong> yourself along that long and winding path. You miss a DLL or dependency. You mark a flag wrong and it won&#8217;t run on a non-developer system. A setting gets changed on the system doing the compile and builds mysteriously fail. On multiple platforms (and who isn&#8217;t on at least a couple?), you forget to test on all 5 of your platforms and find out the build is broken &#8211; obviously or subtly &#8211; on one of them.</p>
<p>One building bock that helps cut down on this pain is a <strong>build tool</strong> &#8211; a tool to manage what files are built in what order and with what settings. If you can fire off your build from a single command line command, it dramatically reduces the risk of breakage due to outside factors &#8211; and helps a lot with setting up build boxes. At this point I&#8217;ve worked with nearly every option: make, msbuild, xcodebuild, rake, Maven, Ant, CMake, premake, qmake, and even a couple of home brew systems. Here are my thoughts on each of them:</p>
<p><strong>GNU Make. </strong>The granddaddy of all build tools. Cryptic syntax, most widely used on POSIX-compatible environments like Mac or Linux. It can do anything you want it to, if you&#8217;re willing to dive deep enough into it. Provides very little hand holding. Tools like automake and autoconf expand capabilities quite a bit, but they are anything but intuitive, and if your goal isn&#8217;t a UNIX command line tool, they may be frustrating to work with. Makefiles are generally shippable if you are willing to put enough smarts in them (since they are fundamentally built on top of the shell). Make files are easy to generate, and many tools exist to programmatically do so (more on those later).</p>
<p><strong>MSBuild.</strong> The successor to nmake (with a brief detour to devenv.exe), it owes a lot of its legacy to make. However, it&#8217;s fully integrated with Visual Studio, so if you have a Visual Studio project, it&#8217;s easy to drive. In general, vcprojs are pretty easy to programmatically generate, and also easy ship to other Windows developers, which is a big bonus. No viability for sharing cross platform, except possibly in the context of Mono development.</p>
<p><strong>XCodeBuild.</strong> The command line tool for compiling XCode projects. It works just like XCode does, minus the goofy UI. Great for doing OSX/iOS builds, nothing doing for any other platforms. XCode project files are relatively easy to ship to people, although there can sometimes be little subtleties that screw you up. Once nice thing about XCode&#8217;s build model is that it&#8217;s fairly easy to call your own scripts at various points in the build process. The downside is that xcodeproj&#8217;s are finicky and hard to generate.</p>
<p><strong>Rake.</strong> Ruby is pretty sweet, and Rake builds on it in the Ruby way &#8211; that is, with a domain specific language tailored to the task at hand. The downside is that the docs are inscrutable &#8211; you pretty much need to be prepared to look at a lot of examples and dive the code to understand it well. But it responds well to hacking and generally gets the job done. Since Rake just sequences commands it works great for non-Ruby projects &#8211; it&#8217;s basically a much better Make.</p>
<p><strong>Maven. </strong>I have seen Maven used very well in real Java projects, and abused heavily in non-Java scenarios. If you grok the Maven way and are prepared to conform to its view of the world, you can get good results. But in general I think it is much more trouble than it&#8217;s worth in anything but enterprise Java contexts.</p>
<p><strong>Ant. </strong>I&#8217;ve used Ant several times on non-Java projects, to good results. Ant is powerful and has some nice capabilities for filtering/selecting actions. However, it also has an obtuse XML syntax that becomes cumbersome in complex build scenarios, and it can be finicky to set up all your Ant tasks properly.</p>
<p><strong>CMake.</strong> CMake is ugly, but it&#8217;s an effective kind of ugly. The CMake language is gross and its codebase is complex, with important features often being driven by subtle combinations of settings. But the docs are pretty decent, the community is large, and it has good update velocity. It also generates pretty good project files for most IDEs. And it is pretty easy to hook arbitrary commands into key points in the build process, which is a big win. CMake is bad if you want to do a lot of file processing or complex logic, but good for making and running project files that work across many platforms &#8211; including iOS and OSX.</p>
<p><strong>premake.</strong> Of all these technologies, I most want premake to rock. It uses Lua, which is an easy and low-dependency language, and it has a pretty good set of modules for emitting different projects. Most of the time, projects can be shipped, which is big, too. However, the core generators are finicky, and we had compatibility issues. And development velocity isn&#8217;t as high as we&#8217;d like. So we ultimately had to drop it. However, I think it&#8217;s worth a look again in the future.</p>
<p><strong>QMake.</strong> QMake is mostly associated with QT development, and exists to facilitate the preprocessing that QT requires to generate all of its binding + convenience features. It takes a simple configuration language, and can be effective. However, its support for mobile platforms appears to be rudimentary and it does not produce project files &#8211; just sequences build commands.</p>
<p><strong>Homebrew.</strong> My main experience here was a custom project generation tool I developed at GarageGames. (Ultimately, many others have touched it, and I believe that it is still in use as of this writing.) We decided to go the homebrew route because we needed to ship high quality project files to our customers. None of the existing tools could produce these (premake is now probably the closest). And our existing process of hand-tweaking projects resulted in a lot of broken releases. We ended up using PHP to process hand-written project file templates. It worked because we had a large enough team to be able to spend a few man-months refining it until it was good enough. The main take away from that experience was that it&#8217;s not as hard to do as you&#8217;d think &#8211; it&#8217;s just matter of patience and groveling through exemplar build files to learn the format. The real cost is maintaining on-going compatibility with all the different versions of all the IDEs. I hope that someday GarageGames releases this tool as open source.</p>
<p>So, with all those out there to consider &#8211; what am I using today? Well, we are using a hybrid of <strong>Rake</strong> and <strong>CMake</strong>. We use CMake for all the project generation + compilation, while Rake deals with sequencing calls to CMake and make or xcodebuild or what have you &#8211; mostly for the build box&#8217;s benefit. Our project targets iOS, Android, Mac, and Windows, and so far this combination has worked out well.</p>
<p><strong>Ultimately, you want a tool that builds from a single command and doesn&#8217;t require user intervention to produce final build artifacts.</strong> Otherwise, you will be constantly chasing your tail as you move from developer to developer or platform to platform. Any of these tools can achieve this, so it&#8217;s a question of choosing the tool or combination of tools that fit your situation the best. Good luck!</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/bengarney.wordpress.com/1101/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/bengarney.wordpress.com/1101/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=blog.bengarney.com&#038;blog=106034&#038;post=1101&#038;subd=bengarney&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://blog.bengarney.com/2012/08/26/some-thoughts-on-build-systems/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/08cfb70f32d12a81926575e0a3fc2d4e?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">bengarney</media:title>
		</media:content>

		<media:content url="http://bengarney.files.wordpress.com/2012/08/smokestacks.jpg?w=650" medium="image">
			<media:title type="html">Smokestacks</media:title>
		</media:content>
	</item>
		<item>
		<title>Flash Gaming Summit 2012 Slides</title>
		<link>http://blog.bengarney.com/2012/03/08/flash-gaming-summit-2012-slides/</link>
		<comments>http://blog.bengarney.com/2012/03/08/flash-gaming-summit-2012-slides/#comments</comments>
		<pubDate>Thu, 08 Mar 2012 11:53:15 +0000</pubDate>
		<dc:creator>Ben Garney</dc:creator>
				<category><![CDATA[Talks]]></category>

		<guid isPermaLink="false">http://blog.bengarney.com/?p=1083</guid>
		<description><![CDATA[My FGS 2012 talk on the future of Flash and what developers can do about it is available to watch and read online! I wanted to touch on a couple things based on feedback from different people. First, and this should be pretty obvious, everything in it is my own opinion. I tried to find [&#8230;]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=blog.bengarney.com&#038;blog=106034&#038;post=1083&#038;subd=bengarney&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
				<content:encoded><![CDATA[<p>My FGS 2012 talk on the future of Flash and what developers can do about it is available to watch and read online!</p>
<p>I wanted to touch on a couple things based on feedback from different people. First, and this should be pretty obvious, everything in it is my own opinion. I tried to find sources where I could, of course. Second, Flash is obviously not dead and not going to disappear in the immediate term. However, there is a real risk that it could face a long term decline, due to various reasons I explore in the talk. Like I say on slide 12, &#8220;declining asset&#8221; is a label used to make decisions not a business reality.</p>
<p>Finally, although I&#8217;m building some native tech right now, it supports Alchemy as a primary platform &#8211; so Flash is still a big part of my business plan. So my money is (literally) where my mouth is in saying that Flash is still a good platform.</p>
<p><a href="http://partners-ar.adobeconnect.com/p9dh8z22yjw/"><b>View recording of &#8220;It&#8217;s the end of the world as we know it (and I feel fine)&#8221; online now!</b></a></p>
<p><a href="http://www.slideshare.net/bengarney/fgs-2012-its-the-end-of-the-world-as-we-know-it-and-i-feel-fine"><b>View the slides for &#8220;It&#8217;s the end of the world as we know it (and I feel fine)&#8221; now on SlideShare!</b></a></p>
<p>Please feel free to post any questions about the talk here. Thanks for reading!</p>
<hr />
<p>My talk led to some strong reactions!</p>
<p>&#8220;Ben Garney is a very engaging speaker&#8230; This was my favorite talk of the day!&#8221; &#8212; <a href="http://area.autodesk.com/blogs/chris/notes_from_the_2012_flash_gaming_summit">Summary post from Autodesk&#8217;s community.</a></p>
<blockquote class="twitter-tweet"><p>@<a href="https://twitter.com/bengarney">bengarney</a> Good stuff, Ben. The only bad thing I heard from you was the name of the engine you&#8217;re working on. That was mine! *shakes fist*</p>
<p>&mdash; Phil Peron (@pperon) <a href="https://twitter.com/pperon/status/177765834284990464">March 8, 2012</a></p></blockquote>
<blockquote class="twitter-tweet"><p>@<a href="https://twitter.com/bengarney">bengarney</a> looking forward to these, apparently you ruffled a few feathers.</p>
<p>&mdash; Jesse Freeman (@jessefreeman) <a href="https://twitter.com/jessefreeman/status/177738648064761856">March 8, 2012</a></p></blockquote>
<p>Select quotes from the chat log in the video of the talk:</p>
<blockquote><p>ClutterMedia: he doesn&#8217;t know what he is taking about<br />
ClutterMedia: does he own a flash site or build a game<br />
ClutterMedia: if not go fuck him self<br />
PaulGene 2: this guy is depressing me<br />
terrypaton1: Talking about excellent topics Ben<br />
Dragonsnare: gets you depressed and shows you a drink lol<br />
Hamed: what the helll<br />
Hamed: why does he think adobe will ditch the future</p></blockquote>
<blockquote class="twitter-tweet"><p>FlashGamingSummit is a blast if you&#8217;re a Flash developer. Lots of like minds and stuff. @<a href="https://twitter.com/bengarney">bengarney</a> is such a downer though!</p>
<p>&mdash; Iain Lobb (@iainlobb) <a href="https://twitter.com/iainlobb/status/176446700955762688">March 4, 2012</a></p></blockquote>
<p>(Iain later walked out of my talk in protest.)</p>
<blockquote class="twitter-tweet"><p>@<a href="https://twitter.com/bengarney">bengarney</a> @<a href="https://twitter.com/fgsummit">fgsummit</a> Hmm prob the best talk I saw at <a href="https://twitter.com/search/%2523FGS2012">#FGS2012</a> &#8211; other talks take notice. Dont want a 20m company hist. lesson ina 30m talk.</p>
<p>&mdash; Mario Gonzalez (@1dayitwillmake) <a href="https://twitter.com/1dayitwillmake/status/176576986330841088">March 5, 2012</a></p></blockquote>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/bengarney.wordpress.com/1083/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/bengarney.wordpress.com/1083/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=blog.bengarney.com&#038;blog=106034&#038;post=1083&#038;subd=bengarney&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://blog.bengarney.com/2012/03/08/flash-gaming-summit-2012-slides/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/08cfb70f32d12a81926575e0a3fc2d4e?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">bengarney</media:title>
		</media:content>
	</item>
		<item>
		<title>Speaking At Flash Gaming Summit, Attending GDC 2012</title>
		<link>http://blog.bengarney.com/2012/02/14/speaking-at-flash-gaming-summit-attending-gdc-2012/</link>
		<comments>http://blog.bengarney.com/2012/02/14/speaking-at-flash-gaming-summit-attending-gdc-2012/#comments</comments>
		<pubDate>Wed, 15 Feb 2012 06:03:42 +0000</pubDate>
		<dc:creator>Ben Garney</dc:creator>
				<category><![CDATA[Talks]]></category>
		<category><![CDATA[game technology]]></category>
		<category><![CDATA[upcoming technology]]></category>

		<guid isPermaLink="false">http://blog.bengarney.com/?p=1035</guid>
		<description><![CDATA[Click here for slides and video. I will be presenting &#8220;It&#8217;s The End of The World As We Know It (And I Feel Fine)&#8221; at the Flash Gaming Summit 2012. My session is at 3pm &#8211; be sure to come! I&#8217;ll be talking about the future of the Flash platform, how to future-proof yourself against [&#8230;]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=blog.bengarney.com&#038;blog=106034&#038;post=1035&#038;subd=bengarney&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
				<content:encoded><![CDATA[<p><a href="http://blog.bengarney.com/2012/03/08/flash-gaming-summit-2012-slides/"><b>Click here for slides and video.</b></a></p>
<p><img src="http://bengarney.files.wordpress.com/2012/02/talkbadge.png?w=660" alt="" title="talkbadge"   class="alignright size-full wp-image-1052" /> I will be presenting &#8220;It&#8217;s The End of The World As We Know It (And I Feel Fine)&#8221; at the <a href="http://www.flashgamingsummit.com/">Flash Gaming Summit 2012</a>. My session is at 3pm &#8211; be sure to come! I&#8217;ll be talking about the future of the Flash platform, how to future-proof yourself against upcoming technology sea changes, and sharing some steps I&#8217;ve personally taken in that direction.</p>
<p><a href="http://gdconf.com/">GDC2012</a> is on my itinerary, too. I am getting some new, native, mobile-oriented game technology ready for launch. I&#8217;ll be doing some private showings at GDC, so if you want to get the skinny, track me down on <a href="http://twitter.com/bengarney">Twitter</a> or mail me at ben dot garney at gmail.</p>
<p>Have a great pre-GDC crunch! <img src='http://s1.wp.com/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/bengarney.wordpress.com/1035/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/bengarney.wordpress.com/1035/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=blog.bengarney.com&#038;blog=106034&#038;post=1035&#038;subd=bengarney&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://blog.bengarney.com/2012/02/14/speaking-at-flash-gaming-summit-attending-gdc-2012/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/08cfb70f32d12a81926575e0a3fc2d4e?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">bengarney</media:title>
		</media:content>

		<media:content url="http://bengarney.files.wordpress.com/2012/02/talkbadge.png" medium="image">
			<media:title type="html">talkbadge</media:title>
		</media:content>
	</item>
		<item>
		<title>Fast Bitmap Fonts in Flash</title>
		<link>http://blog.bengarney.com/2011/12/07/fast-bitmap-fonts-in-flash/</link>
		<comments>http://blog.bengarney.com/2011/12/07/fast-bitmap-fonts-in-flash/#comments</comments>
		<pubDate>Thu, 08 Dec 2011 04:43:04 +0000</pubDate>
		<dc:creator>Ben Garney</dc:creator>
				<category><![CDATA[Opinion]]></category>

		<guid isPermaLink="false">http://blog.bengarney.com/?p=981</guid>
		<description><![CDATA[I got fed up one day, and wrote a simple bitmap font renderer, BMFontRenderer. It parses bitmap font data from a generator like BMFont or Hiero (link on middle right of sidebar) and renders text of your choosing to a BitmapData. BMFontRenderer is under the MIT license, so you can use it as you like. [&#8230;]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=blog.bengarney.com&#038;blog=106034&#038;post=981&#038;subd=bengarney&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
				<content:encoded><![CDATA[<p><img src="http://bengarney.files.wordpress.com/2011/12/metrics2.png?w=660" alt="FreeType Font Metrics Chart" title="metrics2"   class="alignright size-full wp-image-983" /><br />
I got fed up one day, and wrote <b>a simple bitmap font renderer, <a href="https://github.com/bengarney/BMFontRenderer">BMFontRenderer</a></b>. It parses bitmap font data from a generator like <a href="http://www.angelcode.com/products/bmfont/">BMFont</a> or <a href="http://slick.cokeandcode.com/">Hiero (link on middle right of sidebar)</a> and renders text of your choosing to a BitmapData. </p>
<p><a href="https://github.com/bengarney/BMFontRenderer">BMFontRenderer</a> is under the <b>MIT license</b>, so you can use it as you like.</p>
<p>Here&#8217;s an example:</p>
<pre class="brush: as3; title: ; notranslate">
// Load the font.
var bmfont:BMFont = new BMFont();
bmfont.parseFont(font);
bmfont.addSheet(0, (new fontSheet()).bitmapData);
            
// OK, draw some text!
var out:BitmapData = new BitmapData(200, 100, true, 0x0);
bmfont.drawString(out, 0, 0, &quot;Hello, world!&quot;);
</pre>
<p>(You can see <a href="https://github.com/bengarney/BMFontRenderer/blob/master/src/BMFontRenderer.as">the complete example in BMFontRenderer&#8217;s GitHub page</a>.)</p>
<p>Great. So &#8211; <b>why would you want to use this, given TextField is right there, waiting for you?</b> (Translation: why did you get fed up, Ben?)</p>
<p>It comes down to <b>control</b>. TextField has a TON of knobs and buttons you can set. They all do semi-obscure things which are, in and of themselves, very exciting, but confusing to work with if you aren&#8217;t a font expert. Worst of all, it pulls font data from hard-to-inspect places that are populated by mxmlc at compile time or located on the user&#8217;s system, so you get different visual results depending on who is running your app, where and when you compiled it, and maybe even what browser it&#8217;s in.</p>
<p>The Flash IDE does a good job of hiding all this, and for beautiful animated vector text created by an expert in the tool, there is a great workflow. But when I need to show a high score at an artist-selected size in an artist-selected-and-provided font that has artist-approved antialiasing so it looks good on top of the artist-created background, it can be a lot easier to <b>let the artist export the exact characters they want, how they want them to look,</b> to a PNG. Then all I have to do is copy pixels around.</p>
<p>Fonts are less restrictive about <b>licensing</b> if you ship pixels instead of TrueType/vector data. Shipping raster data can save you a couple grand in license fees, nevermind cut down on your download quite nicely.</p>
<p>Doing it this way also puts <b>100% of the font handling code under your control</b>. There are no parts you can&#8217;t debug, analyze, optimize, timeslice, or otherwise fiddle with. Never underestimate the value of this when you have a deadline. This is why I love libraries like <a href="nothings.org/stb/stb_truetype.h">Sean Barrett&#8217;s stb_truetype.h</a>, which is a self-contained TrueType font renderer in a single C file.</a></p>
<p>There&#8217;s another fantastic bonus. Once an artist has characters in a PNG, <b>they can open them up and tweak them</b> &#8211; distress them, add glows or cutouts, or anything else that Photoshop can do. That&#8217;s a big realm of possibilities, and a lot easier than learning a font authoring tool.</p>
<p>To be sure, <b>Flash&#8217;s built in font rendering has solid uses.</b> If you need to dynamically animate, scale, or rotate text, you need vectors, and Flash has got you covered. If you want to display fully arbitrary unicode text, you may need to fall back on system fonts to fit in your download budget (<a href="https://github.com/PushButtonLabs/PushButtonEngine/blob/master/src/com/pblabs/engine/debug/GlyphCache.as">PushButton Engine has a nice glyph cache for speeding up rendering, though</a>). Or if you are working with people who are very comfortable in the Flash IDE, why not use a system they are familiar with?</p>
<p>For everything else, there&#8217;s <a href="https://github.com/bengarney/BMFontRenderer">BMFontRenderer</a>. <b>Enjoy!</b></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/bengarney.wordpress.com/981/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/bengarney.wordpress.com/981/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=blog.bengarney.com&#038;blog=106034&#038;post=981&#038;subd=bengarney&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://blog.bengarney.com/2011/12/07/fast-bitmap-fonts-in-flash/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/08cfb70f32d12a81926575e0a3fc2d4e?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">bengarney</media:title>
		</media:content>

		<media:content url="http://bengarney.files.wordpress.com/2011/12/metrics2.png" medium="image">
			<media:title type="html">metrics2</media:title>
		</media:content>
	</item>
	</channel>
</rss>
