{"id":47821,"date":"2019-08-29T06:00:12","date_gmt":"2019-08-29T10:00:12","guid":{"rendered":"https:\/\/www.shamusyoung.com\/twentysidedtale\/?p=47821"},"modified":"2019-08-29T13:57:37","modified_gmt":"2019-08-29T17:57:37","slug":"game-programming-vexations-part-1-five-years-later","status":"publish","type":"post","link":"https:\/\/www.shamusyoung.com\/twentysidedtale\/?p=47821","title":{"rendered":"Game Programming Vexations Part 1: Five Years Later"},"content":{"rendered":"<p>My programming posts are always popular, which is strange because it seems like they shouldn&#8217;t work at all. I don&#8217;t know where I got the idea to write about the fussy details of programming in casual, non-technical terms. It seems like non-programmers would be bored by all the stuff that has no bearing on their lives, and programmers would be irritated by all the entry-level explanations for things they already understand. But for whatever reason, both kinds of people show up for these articles.<\/p>\n<p>Whichever group you belong to, buckle up. I expect some of this to get pretty controversial by the standards of programming flame wars, and I think I&#8217;m going to need to be more technical than usual.<\/p>\n<p><!--more--><\/p>\n<h3>Jai<\/h3>\n<p>It&#8217;s been five years since <a href=\"?p=26011\">I wrote about Jon Blow and his mad scheme to create a programming language for games<\/a>. At the time, I half-expected that this would be the last we heard about the idea. Not because I don&#8217;t have any faith in Blow specifically, but because the internet is awash in grandiose projects meant to solve herculean challenges, and the vast majority of those projects never make it out of the design phase. It&#8217;s easy to explain why something is a problem<span class='snote' title='1'>That&#8217;s pretty much what I do here.<\/span>, and it&#8217;s not that hard to make suggestions, but it&#8217;s murderously difficult to solve those problems with code. In the programming world, talk is cheap and working solutions are hard to implement<span class='snote' title='2'>Actually, I hear this holds true outside of programming as well.<\/span>.<\/p>\n<p>Making a new programming language is like getting a puppy. It seems like a lot of fun, but it also turns out to be a lot of responsibility. You can daydream about all the magic features you&#8217;d love to have in a language and how cool your syntax will be. But eventually the novelty wears off and you realize you&#8217;re now obligated to take care of something that no longer delights you. The fun goes away and the work doesn&#8217;t, which is when the daydreaming programmer will fall in love with a new idea and abandon the old one. Statistically, betting against new languages is the safe thing to do.<\/p>\n<p>Despite my pessimism, Blow has made some amazing progress over the last five years. He&#8217;s building the language, while also using the language to build a game. This series is going to look first at what problems we have in game development, and &#8211; later when I have a chance to try it &#8211; what Jai does to address<span class='snote' title='3'>or fall short of addressing<\/span> these problems.<\/p>\n<p>This series was originally going to be about Jai, but:<\/p>\n<ol>\n<li style=\"font-weight: 400;\">The introduction kept growing and growing as I set out to explain WHY we need a programming language for games.<\/li>\n<li>I found myself caught in many digressions filled with long pent-up gripes about C++.<\/li>\n<li style=\"font-weight: 400;\">Jai isn&#8217;t out yet. It might possibly see a limited-public demo of some sort in 2019, but it hasn&#8217;t happened yet.<\/li>\n<\/ol>\n<p>So instead this series is about the vexations of games programming, with the understanding that maybe in some distant future I&#8217;ll write a series about Jai and see how well it addresses these concerns.<\/p>\n<h3>Domain is Everything<\/h3>\n<p><div class='imagefull'><img src='https:\/\/www.shamusyoung.com\/twentysidedtale\/images\/stock_construction.jpg' width=100% alt='I&apos;m sure this dude is good at whatever it is he&apos;s doing, but I wouldn&apos;t ask him for advice on how to run a restaurant.' title='I&apos;m sure this dude is good at whatever it is he&apos;s doing, but I wouldn&apos;t ask him for advice on how to run a restaurant.'\/><\/div><div class='mouseover-alt'>I&apos;m sure this dude is good at whatever it is he&apos;s doing, but I wouldn&apos;t ask him for advice on how to run a restaurant.<\/div><br \/>\nAs soon as game developers start talking about climbing over the wall around C++ and running off to find a new language, people start evangelizing their favorite languages. <i>X does everything you need for game programming! Y is the best language for all projects! Z meets all the criteria you&#8217;ve listed!<\/i><\/p>\n<p>Without fail, the people giving this advice have never shipped a game and in fact aren&#8217;t game developers at all. They&#8217;re usually coming from some other field.<\/p>\n<p>I don&#8217;t know what the deal is with this particular discipline, but everyone presumes to know everyone else&#8217;s business. I don&#8217;t imagine most auto mechanics would casually attempt to tell an airline mechanic how to maintain a turbine. I don&#8217;t think the airline mechanic would tell a structural engineer how to construct a <a href=\"https:\/\/www.youtube.com\/watch?v=f1U4SAgy60c\">tuned mass damper<\/a>. I would hope the structural engineer wouldn&#8217;t go around lecturing NASA engineers about how to construct launch vehicles. We understand that even though all of these professions involve engineering and using tools on machines to some degree, they&#8217;re all highly specialized fields with very limited overlap.<\/p>\n<p>Two coders might use different languages to solve different kinds of problems using different hardware at different scales, but they&#8217;re not shy about advocating languages and <a href=\"?p=35702\">coding practices<\/a> to each other. The field is full of dogma and online discussions are a mess of <a href=\"https:\/\/www.youtube.com\/watch?v=KlPC3O1DVcg\">peacocking<\/a>, <a href=\"https:\/\/www.youtube.com\/watch?v=Aa55RKWZxxI\">condescension<\/a>, and <a href=\"http:\/\/www.paulgraham.com\/avg.html\">arrogance<\/a>.<\/p>\n<p>Maybe we tend to treat all programming disciplines the same because they look so similar. You can tell an auto mechanic from a carpenter with a glance<span class='snote' title='4'>Assuming they&#8217;re working, obviously.<\/span>. But coders working in web development, video games, embedded systems, machine learning, and driver maintenance are all superficially the same. They all sit in chairs and type code on a computer. Maybe this tricks us into thinking these people are all doing the same job.<\/p>\n<p>Some programming projects don&#8217;t care about performance as much as code clarity. Others are optimized for a low memory footprint. Others are worried about maintaining code for decades. Others have to sacrifice development time to safeguard against the possibility of errors. As John Carmack once <a href=\"http:\/\/number-none.com\/blow\/john_carmack_on_inlined_code.html\">said<\/a>:<\/p>\n<blockquote><p>&#8220;Now, a great deal of stuff that goes on in the aerospace industry should not be emulated by anyone, and is often self destructive. Most of you have probably read various popular articles about the development process that produces the space shuttle software, and while some people might think that the world would be better if all software developers were that &#8220;careful&#8221;, the truth is that we would be decades behind where we are now, with no PC&#8217;s and no public internet if everything was developed at that snail&#8217;s pace.&#8221;<\/p><\/blockquote>\n<p>Different problems have different solutions, and programmers outside of gaming are often trying to explain to us that their hammers are excellent tools for driving our gaming screws. And to be fair, I&#8217;m sure game developers are just as eager to find a non-gamedev programmer and lecture them about how gaming&#8217;s screwdrivers are the perfect tool for digging their trenches.<\/p>\n<p>I don&#8217;t know. Maybe I&#8217;m wrong and auto mechanics really do lecture HVAC engineers about how to maintain their hardware, and I just don&#8217;t see it because I don&#8217;t hang out in those circles. Still, it seems like engineers who operate on physical hardware are more likely to identify their domain during a discussion, while programmers are more likely to get in arguments without any of them ever making clear what <b>kind<\/b> of programmers they are.<\/p>\n<p>Domain experience is everything. Game development and systems programming have about as much in common as plumbing and VCR repair. While we&#8217;re having this discussion on languages and programming methods, I&#8217;d encourage everyone to keep the issue of domain experience in mind. Maybe all developers in domain X are dum-dums for not using your awesome language \/ tool, or <i>maaaaaaybe<\/i> there are a bunch of details to X that you don&#8217;t know about. Maybe the language \/ tool that you think is dumb and broken is actually designed for a completely different job than the one you&#8217;re doing.<\/p>\n<h3>What is a Game?<\/h3>\n<p><div class='imagefull'><img src='https:\/\/www.shamusyoung.com\/twentysidedtale\/images\/stock_esports.jpg' width=100% alt='' title=''\/><\/div><div class='mouseover-alt'><\/div><\/p>\n<p>Before we go any further I should make it clear that as far as this series is concerned, a &#8220;game&#8221; is a program which:<\/p>\n<ul>\n<li style=\"font-weight: 400;\">Runs in realtime.<\/li>\n<li style=\"font-weight: 400;\">Is interactive.<\/li>\n<li style=\"font-weight: 400;\">Renders some sort of 3D scene<span class='snote' title='5'>Even if the gameplay itself is 2D.<\/span>.<\/li>\n<li style=\"font-weight: 400;\">Is targeted at modern gaming hardware like PCs and consoles.<\/li>\n<\/ul>\n<p>For this series, when we talk about games we are <b>not<\/b> talking about text-based games like <a href=\"http:\/\/www.hammurabigame.com\/hammurabi-game.php\">Hammurabi<\/a>. We&#8217;re not talking about strictly narrative experiences like <a href=\"https:\/\/mrwasteland.itch.io\/twwds\">The Writer Will do Something<\/a>. We&#8217;re not talking about classics like the original <a href=\"https:\/\/en.wikipedia.org\/wiki\/Myst\">Myst<\/a> or <a href=\"https:\/\/en.wikipedia.org\/wiki\/King's_Quest\">King&#8217;s Quest<\/a>.<\/p>\n<p>This is obviously a very narrow definition. It excludes a lot of simple 2D sidescrollers but might include some non-gaming simulations as well as 3D modeling programs like Blender. I&#8217;m not trying to change the definition of game on you, and I&#8217;m not trying to claim that <em>Peggle<\/em> and <em>Cooking Mama<\/em> aren&#8217;t games. I&#8217;m not using this definition to be a gatekeeping jackass. I fully admit these experiences are actually games and they have just as much artistic merit as anything else with the label &#8220;video game&#8221; slapped on it.<\/p>\n<p>I&#8217;m excluding these things because &#8211; from the standpoint of a modern game developer &#8211; they&#8217;re fairly trivial programming problems and won&#8217;t benefit from any of the language stuff I&#8217;m going to be talking about. I&#8217;m just trying to avoid saying &#8220;realtime interactive 3D software for PCs or consoles&#8221; every time I&#8217;m talking about the challenges of AAA game development. If I make a claim like, &#8220;All games need to worry about framerate&#8221;, remember that I&#8217;m talking about a game with polygons and moving images. I don&#8217;t want to get dragged into pedantic arguments over <a href=\"https:\/\/en.wikipedia.org\/wiki\/Zork\">Zork<\/a> et al.<\/p>\n<p>When programmers wish for a better tool for doing game development, they&#8217;re usually working in the AAA space and wishing for a way to escape C++. This is not really a problem for bedroom programmers working on small-scope projects in Unity. The small teams have lots of languages and tools to choose from, and they&#8217;re usually worried more about money and less about pushing the hardware to the limits. So for the rest of this series, I&#8217;m going to assume that any language intended to displace C++ must therefore be useful to projects on the AAA scale. I&#8217;m not promising that Jai will do that, or even that Jon Blow has made that promise<span class='snote' title='6'>Although it is apparently one of his goals.<\/span>. I&#8217;m just saying I think that&#8217;s what a challenger language would need to do.<\/p>\n<h3>Domain Difficulty<\/h3>\n<p>We all have challenges to deal with and things that make our particular domain difficult, and I get that claiming that no existing tool is &#8220;good enough&#8221; for your domain smacks of arrogance. Everyone will think you&#8217;re bragging about how hard your job is, which carries the implied insult that everyone else has it easier. Other programmers will not let this sort of claim go unchallenged.<\/p>\n<p>(For the record, I&#8217;m not saying game development is more difficult than other domains, I&#8217;m just saying its difficulty takes a different form.)<\/p>\n<p>Hopefully I&#8217;ve placated you enough and you&#8217;re at least willing to entertain the notion that games programming has challenges you don&#8217;t see<span class='snote' title='7'>Or that are present to a lesser degree.<\/span> in other kinds of programming. Over the next 12-ish entries, I&#8217;m going to talk about some of the major problems that I hope Jai will address.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>My programming posts are always popular, which is strange because it seems like they shouldn&#8217;t work at all. I don&#8217;t know where I got the idea to write about the fussy details of programming in casual, non-technical terms. It seems like non-programmers would be bored by all the stuff that has no bearing on their [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[66],"tags":[],"class_list":["post-47821","post","type-post","status-publish","format-standard","hentry","category-programming"],"_links":{"self":[{"href":"https:\/\/www.shamusyoung.com\/twentysidedtale\/index.php?rest_route=\/wp\/v2\/posts\/47821","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.shamusyoung.com\/twentysidedtale\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.shamusyoung.com\/twentysidedtale\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.shamusyoung.com\/twentysidedtale\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.shamusyoung.com\/twentysidedtale\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=47821"}],"version-history":[{"count":6,"href":"https:\/\/www.shamusyoung.com\/twentysidedtale\/index.php?rest_route=\/wp\/v2\/posts\/47821\/revisions"}],"predecessor-version":[{"id":47879,"href":"https:\/\/www.shamusyoung.com\/twentysidedtale\/index.php?rest_route=\/wp\/v2\/posts\/47821\/revisions\/47879"}],"wp:attachment":[{"href":"https:\/\/www.shamusyoung.com\/twentysidedtale\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=47821"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.shamusyoung.com\/twentysidedtale\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=47821"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.shamusyoung.com\/twentysidedtale\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=47821"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}