{"id":19203,"date":"2013-05-20T02:25:35","date_gmt":"2013-05-20T07:25:35","guid":{"rendered":"http:\/\/www.shamusyoung.com\/twentysidedtale\/?p=19203"},"modified":"2023-12-16T13:22:55","modified_gmt":"2023-12-16T18:22:55","slug":"the-twelve-year-mistake-part-2-the-coder","status":"publish","type":"post","link":"https:\/\/www.shamusyoung.com\/twentysidedtale\/?p=19203","title":{"rendered":"The Twelve-Year Mistake Part 2: The Coder"},"content":{"rendered":"<p>It&#8217;s September of 2000. I turned 29 last month. I&#8217;m trying to move our family from Boston to Pittsburgh. In the middle of the move, Dad has died.<\/p>\n<h3>Funeral<\/h3>\n<p>I only ever saw Dad in the context of sitting around his tiny little efficiency apartments while he drank coffee and chain-smoked. He lived alone and only ate meals that could be prepared with one hand. His kitchen table was always a mountain of incoming mail, with a small spot reserved for his plate and utensils. You can tell where his favorite seat was, because it was the one spot on the couch that didn&#8217;t release clouds of dust when somebody dropped into it. His seat was surrounded by different eyeglasses, overflowing ashtrays, coffee stains, and open books.<\/p>\n<p>He never discussed his friends. I inferred that he had friends by the fact that he would abruptly get new stuff around Christmas. Sometimes I&#8217;d see personal mail mixed in with the overdue bills heaped up on the table. Once in a long while he&#8217;d get a phone call during my visit, but the calls were always terse and he never said who had called or why. His life outside of coffee and cigarettes was opaque to me.<\/p>\n<p>Dad&#8217;s funeral is&#8230; surprising. I can suddenly see that busy other life he lived. That other life was hidden because his friends were mostly fellow members of Alcoholics Anonymous. That was where he invested most of his time and that&#8217;s where his heart was. I suppose he was trying to save other people from <a title=\"Autoblography Part 19: Four Dollars\" href=\"?p=13314\">the fate he&#8217;d brought on himself<\/a>. I meet many of these people at the funeral, and I get a sense that he&#8217;d helped a lot of them directly.<\/p>\n<p>We&#8217;d never really understood each other. I never saw the very personal work he did sponsoring people as they fought to reclaim their lives from addiction. He never got the whole &#8220;computer programmer&#8221; thing, and was always jokingly (but also earnestly) a little disappointed that I never became a writer.<\/p>\n<p>After the funeral I return to Boston and begin the long job of dragging my family home to Pittsburgh and finding a permanent place to live.<\/p>\n<p><!--more--><\/p>\n<h3>House Hunting<\/h3>\n<p>The house search is trying for us. Buying houses takes a lot of time even when done quickly, and in the meantime we&#8217;re living with grandparents. Space is tight. Our stuff is sitting in storage. My work area is crammed in my bedroom, which isn&#8217;t optimal. It&#8217;s actually worse here than working in an office. Sure, I can wear comfortable clothes now, but Rachel is toddling around and Esther is still in diapers. Between the two of them they can make a lot of chaos and noise in such close quarters. Heather&#8217;s grandparents are good people, but they needle me sometimes. They don&#8217;t mean to, but like a lot of people we know they just don&#8217;t get this whole internet thing and they don&#8217;t really respect what I do.<\/p>\n<p>Her grandparents are generally good people. They&#8217;d have to be. They&#8217;re letting our family live upstairs from them, and kids are not quiet creatures. They&#8217;re generous, but they&#8217;re also old-fashioned. They see introversion as a character flaw and they see my working from home as strange. They also don&#8217;t like that I keep such odd hours. They make a lot of suggestions: <em>You should visit the family more. Have you thought about changing jobs? No? Have you thought about going to school?<\/em> I am not respected by people in Heather&#8217;s family, and I&#8217;ve responded (perhaps petulantly) by ignoring and avoiding them. This does not improve their opinion of me. This ignoring and avoidance thing is a lot harder to pull off now that we&#8217;re under the same roof.<\/p>\n<p>While the house-buying is problematic and slow, the sale of our Boston condo is simple and effortless. We technically made $35k on it, which is nearly a year&#8217;s salary for me. I&#8217;m sort of shocked at how little of the money lands in my hands. Realtor fees. Taxes. The legal costs of resolving the paperwork. Moving expenses. Paying off the credit card we stressed out when living in Boston. When it&#8217;s all over we&#8217;ve got just enough for a down payment on a new place.<\/p>\n<p><table width='600'  cellpadding='0' cellspacing='0' border='0' align='center'><tr><td><img src='https:\/\/www.shamusyoung.com\/twentysidedtale\/images\/shamus_2001_house.jpg' class='insetimage' width='600' alt='Rachel, playing in her new yard.' title='Rachel, playing in her new yard.'\/><\/td><\/tr><\/table><\/p>\n<p>We find a place to live in the extended \u00e2\u20ac\u02dcburbs of Pittsburgh. It&#8217;s a big house with a yard. There are enough bedrooms that we can give the kids space and still have a quiet room reserved for my office. It&#8217;s January of 2001 when we move in.<\/p>\n<p>Our lives improve right away. I can give Heather the attention she needs, and she can give me the space I need. I&#8217;m able to focus on work. I get some new asthma drugs which basically stop all symptoms and let me live a normal life. Now I can stop putting on weight. Maybe I should think about getting some exercise?<\/p>\n<p>I try writing a private blog for my coworkers to outline the stuff I&#8217;m doing and explain why job X was done a day early and job Y was done a day late. It&#8217;s very much a &#8220;here is the most interesting problem I&#8217;ve found today&#8221; kind of thing. My boss is worried that the public will find the thing and company secrets will be leaked. I put a password on the blog. People stop reading it.<\/p>\n<p>I get a lot out of doing the blog, and I find that the process of writing actually helps me sort through and analyze problems better than just sitting and thinking about them. Despite this, I still have the mindset that the blog is for the benefit of &#8220;everyone else&#8221;, so when people stop reading I stop writing. I also have a personal blog that follows the same trajectory: Rewarding to write, but ultimately abandoned when I realize I&#8217;m talking to myself.<\/p>\n<h3>Coding<\/h3>\n<p><table width='600'  cellpadding='0' cellspacing='0' border='0' align='center'><tr><td><img src='https:\/\/www.shamusyoung.com\/twentysidedtale\/images\/shamus_2001_renderware.jpg' class='insetimage' width='600' alt='This game ran on Renderware.' title='This game ran on Renderware.'\/><\/td><\/tr><\/table><\/p>\n<p>Over the last six years with this company I&#8217;ve done mostly art, with programming filling out my minor duties. After the move I transition to all programming. I get to do a lot of cool experimental work. Some of it pans out, some of it doesn&#8217;t. That&#8217;s how it is with prototyping.<\/p>\n<p>Here is an assortment of unrelated programming anecdotes to pad out the rest of this entry:<\/p>\n<p>I come up with a compression system for 3D models. I have this epiphany about how I can make 3D data compress down. My prototype is 15% more effective than standard <a href=\"https:\/\/en.wikipedia.org\/wiki\/Zip_(file_format)\">zip compression<\/a>. If I&#8217;d thought of this four years ago it might be worth something, but the <strong>d\u00e0\u00a4rk age<\/strong> of dialup is drawing to a close. Broadband is becoming widespread. Also, while a savings of 15% is pretty significant, 3D models represent only a tiny portion of the total volume of data that our users download. Eighty percent of their bandwidth goes to downloading sounds and textures. So my technique only saves 15% of 20% of their total downloads. And finally, my technique takes advantage of the fact that most 3D models are built on a coarse grid. This is becoming less true each day as computers get more powerful and artists dabble with curved surfaces. Basically, this is a clever trick that makes only a small difference for a vanishing number of people and only works on the kind of models nobody makes anymore. This is an idea who&#8217;s time has come&#8230; and gone.<\/p>\n<p>I write an interface system that auto-generates a dialog of different options into a collapsible list. This makes it very easy to manage huge numbers of options in a single dialog. It&#8217;s based on the dialog style used in the Unreal Editor, and it will save us a ton of work over the next decade.<\/p>\n<p>I write some code to procedurally generate trees. It&#8217;s very slick, very creative, and completely useless to our company. I end up shelving it, forgetting about it, and eventually losing the code.<\/p>\n<p>Our codebase was begun in 1994. It&#8217;s a very old-school set of code, written in vanilla C and tied to Windows on a very fundamental level. Our graphics are handled by Renderware. It&#8217;s not a bad graphics engine, except our version is from 1996 and here in 2001 it is now ancient beyond reckoning. For years our codebase was maintained by two guys, who passed files back and forth by email. There are now four coders on the team, and it is decided that the time has come for us to run things with a little more professionalism.<\/p>\n<p>We set up proper source control. We decide to transition from C to C++. We move to using the latest version of Renderware. (This is the same engine and version as the one used in Grand Theft Auto III, which just came out this year.) This means we&#8217;ll finally support these new graphics cards that are all the rage these days.<\/p>\n<p>For those of you who don&#8217;t write code for a living: C and C++ are sort of the same programming language, except not at all. C was extended to make C++, so any valid C code ought to be valid C++ code. There are a lot of annoying little edge-cases where this isn&#8217;t quite the case, and even an experienced programmer can quickly find himself buried up to his neckbeard in esoteric minutiae. This is particularly true if you have one million lines of C code that are using software libraries written by other people in C and now you want to flip a switch and begin programming in C++.<\/p>\n<p>Coding in all C was kind of like fighting with one arm tied behind my back. Sometimes I ran into problems where a C++ class was the right tool for the job, and I couldn&#8217;t use it. Now we&#8217;ve got a hybrid codebase with a bunch of strange header-juggling and a schizophrenic approach to <a title=\"Object-oriented programming\" href=\"https:\/\/en.wikipedia.org\/wiki\/Object-oriented_programming\">object-oriented<\/a> design, so now it&#8217;s like fighting with both hands, but hopping on one foot. I can&#8217;t tell if this is an improvement or not. It certainly makes the job <em>interesting<\/em>.<\/p>\n<p><table   class=\"\" cellpadding='0' cellspacing='0' border='0' align='center'><tr><td><img src='https:\/\/www.shamusyoung.com\/twentysidedtale\/images\/splash_confusing_road.jpg' class='insetimage'   alt='splash_confusing_road.jpg' title='splash_confusing_road.jpg'\/><\/td><\/tr><\/table><\/p>\n<p>See, the advantage of C++ is the way it shapes your program at a high level. C is a city made up of horse-roads. The roads are cheap and fast and if you want to go somewhere new you just blaze a trail directly there. The end result will be an incomprehensible roadmap of ad-hoc connections and routes. Fast to build, hard to maintain. C++ is like a nice modern city built on a crisp grid. It takes time and planning to set up, but it&#8217;s easy to use, document, and maintain. The migration we&#8217;re doing is like paving over all those horse-paths with asphalt: It&#8217;s a big improvement, but no amount of pavement will turn this tangled spiderweb into a grid.<\/p>\n<p>During the conversion we find some bits of code that nobody wants to touch. Our Jpeg library was written by a fresh college grad in 1994 or so. It is, without a doubt, the most singularly horrifying piece of code I&#8217;ve ever seen. Global variables defined in the middle of the file. Mutually recursive functions. The function names are all based on the specific details of jpeg files, so the functions are all named things like <code>JFIF_8 (), APP0_JFIF_Ex (), YCbCr (), XFF (),<\/code> and so on. They&#8217;re all impenetrable and written with unpredictable mixed case. Some of these names are identical to #defines aside from case or underscore placement. So&#8230;<\/p>\n<pre lang=\"c\">\/\/Somewhere in the middle of the file...\r\n\r\n#define JFIF8     (something inscrutable)\r\n#define YCBCR     (something inscrutable)\r\n\r\n\/\/Then, several hundred lines later...\r\n\r\nvoid JFIF_8 (JPx jx, JPy jy, J2* j)\r\n{\r\n  \/*\r\n  a half page of math and bit-shifting\r\n  *\/\r\n  if (rV &gt; gV || yV == YCBCR) \r\n    return YCbCr (&amp;j);\r\n  \/*\r\n  now a bunch of block memory copies using global pointers. Good luck finding \r\n  where they're freed, because it's nowhere CLOSE to where they're allocated.\r\n  *\/\r\n}\r\n<\/pre>\n<p><em>(Seriously. I wish I still had access to this code. The stuff I wrote above is just an imitation of the style. I don&#8217;t actually remember the specifics these days. The original is much better. It&#8217;s poetic in its awfulness.)<\/em><\/p>\n<p>Some of this old code is completely inscrutable. We don&#8217;t have enough time to properly go and re-write everything to follow C++ conventions, and nobody wants to touch the crazy minefields like the JPEG decoder. So we can&#8217;t just make a clean break. Instead, we kind of split the codebase between new and old using stuff like <code>extern C { ... }<\/code>. This is sometimes messy and problematic.<\/p>\n<p>Work is fun and challenging, but big changes are on the way&#8230;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>It&#8217;s September of 2000. I turned 29 last month. I&#8217;m trying to move our family from Boston to Pittsburgh. In the middle of the move, Dad has died. Funeral I only ever saw Dad in the context of sitting around his tiny little efficiency apartments while he drank coffee and chain-smoked. He lived alone and [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[16],"tags":[],"class_list":["post-19203","post","type-post","status-publish","format-standard","hentry","category-personal"],"_links":{"self":[{"href":"https:\/\/www.shamusyoung.com\/twentysidedtale\/index.php?rest_route=\/wp\/v2\/posts\/19203","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=19203"}],"version-history":[{"count":2,"href":"https:\/\/www.shamusyoung.com\/twentysidedtale\/index.php?rest_route=\/wp\/v2\/posts\/19203\/revisions"}],"predecessor-version":[{"id":56866,"href":"https:\/\/www.shamusyoung.com\/twentysidedtale\/index.php?rest_route=\/wp\/v2\/posts\/19203\/revisions\/56866"}],"wp:attachment":[{"href":"https:\/\/www.shamusyoung.com\/twentysidedtale\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=19203"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.shamusyoung.com\/twentysidedtale\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=19203"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.shamusyoung.com\/twentysidedtale\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=19203"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}