February 28, 2013

The Magic

There are weeks where I forget about the Magic, buried under instruction manuals, homework assignments and to-do-lists. Times when I can feel a burning hunger for fantastic journeys in far away lands, but can only swallow it hard and try to press on to deal with more urgent matters.

And then there are times where I am swallowed by it, my mind deposited inside another world, ravenously devouring every shred of artwork, literature and music, drowning myself in the tribulations of another universe. My imagination turns from a smoldering flame into a raging inferno, a hurricane of ideas that make me feel alive.

I often struggle with my music - my ideas are more often the result of luck than actual talent. But when I'm surrounded by the Magic, my troubles melt away and I become music incarnate, masterfully crafting melodies and harmonies with precise meaning, knowing precisely how to extend and embellish them even as they sit around as meek sounding rough drafts. Instead of worrying about the massive disconnect between my imagination and the song that is actually coming out of my speakers, I hear only connections, threads between them, roads that must be crossed to bring the song to life.

I always have a sense of Magic that flows through certain artistic works. In some it's barely a whisper, in others I can hear a raging storm behind a locked door, struggling to break free of artistic limitations. But in a select few, it is simply all-consuming, effortlessly carrying me away into another world, to such a degree that when I need to go to the bathroom, I pause halfway down the stairs, momentarily confused as to whose house I'm living in and why I know where I'm going. Sometimes it is music, divine melodies and delicately chosen instruments that coalesce into something beautiful, taking my mind to places it has never seen before without showing me a single picture. Other times, it is a story, a work of literature so powerful I forget that I am actually reading it, instead losing myself inside another universe, watching everything play out in front of me as if it were as real as the book itself. Twice now I have seen it in the blur of animation, stories brought to life with little more than sketches and a few in-between frames that affect me so deeply, they continue to fundamentally influence my imagination to this day. Other times it is the perfect harmony of all these things at once, a game that sweeps me into a galaxy far away where I care more about a 8-bit pixelated image than I ever thought possible.

I'm really more of an artist than an engineer. Sometimes I wield integrals instead of pencils and recursion instead of instruments, but they are nothing more than unusual artistic implements. I live to drown myself in imaginary worlds, and have spent my life trying to help artists achieve precisely this, which has significantly contributed to my tool problem. I want nothing more than to find an artist who has crafted something magical, and lose myself inside it as I help sculpt their world and breathe life into its inhabitants. My tendency to follow where the Magic guides me has resulted in a rather disproportionate number of artistic friends, which has unfortunately not been the most ideal situation.

I've always been disappointed by the fact that so many programmers consider code as nothing more than an obstacle to be overcome. The code is always somewhere else, separated as much as possible from the real art. There are so few who revel in the code itself rather than simply getting it out of the way as soon as possible. It tends to stunt their growth and narrow their vision as they spend less time trying to find elegant solutions to problems and more time writing hacks using what they already know. The trap we fall into, is that it's a good thing to be focused on producing results and not crafting elegant solutions at your job... but it's terrible for self-improvement. Reality dictates that successful programmers must be able to produce results, and yet in order to become good enough to do so, the same programmers must learn how to bury themselves in their code, exploring the infinite nuances of common problems and the aspects of various particularly wondrous solutions that arise. Once learned, the seasoned programmer can put these solutions to stunningly effective use in a real-world scenario - but they must be learned, first, and that requires more than completing homework assignments.

But I digress; my current badly timed state of heightened creativity right before a convention and having to grade a ton of homework is the result of two hilarious coincidences: Having a really bad day the weekend the season finale of My Little Pony was shown, which resulted in me catching up on all the episodes I had let slip me by the past year, followed by a google search that accidentally turned up the tvtropes page for a certain My Little Pony fanfic. There is a fascinating aspect of the My Little Pony fanbase where many of the writers keep building on each other's historical embellishments, to the point that there are now several relatively consistent canons running around, being cross-referenced in metafictional tales in a truly astounding level of creative co-operation. This culminated in one particularly long masterpiece that was such a brilliant work of art I stayed up all night to finish it because I just could not stop reading. There were quite a few random melodic ideas that sprung out of those stories, but that last one had a much more direct impact:



There is something otherworldly about how a fictional tale of characters that have never existed can touch us in such a profound way that it changes the course of our lives forever. That the stories we tell each other can shape the very fabric of history itself. It almost feels a bit... magical.

Twilight is very, very brief, lasting for all too short a time; it is rich, and beautiful, and in that moment the proud sun learns to set, and rest, and the moon ascends to watch over the peace of night. And then twilight is over, leaving the sun and moon to remember its beauty and wonder, after it has gone, changed forever by that brief moment of transition.
   - Eternal

February 24, 2013

The Dark Side of Web Development

I am, by no means, a very good web developer. I am, however, a highly experienced C++ developer. The end result is that people usually ask me why I like C++ so much when everyone else hates it, and everyone is supposedly in agreement that C++ is the worst language ever made and unless you are writing drivers you should never, ever use it. I mean, you can write games in Python now, right?

While these kinds of ignorant opinions are frustrating for me and my fellow C++ developers who actually need efficient cross-platform programs, that's not what I'm here to debate. In fact, if you think C++ is a complete piece of shit, I won't argue with you about that at all. For all I know, you may be right!

Unfortunately for you, web development is just as bad as C++.

Of course, I just said that I'm not very good at web development, so doesn't this disqualify me from having an opinion about it? On the contrary, the fact that I'm not very good at web development is extremely important. The reason is that one of the major complaints about C++ is that good C++ code is hard to write if you are an inexperienced developer. I can certainly attest to that fact, it's taken me years to develop my C++ skills to this point. The fact that Python code is so easy and natural to write is one of its major selling points.

The thing is, good HTML/CSS code is also hard to write if you are an inexperienced developer. I can attest to this too, because I'm an inexperienced developer, and its really goddamn hard to write good HTML/CSS code. Let me clarify what I mean by "good" here: by "good" I mean code that works on all platforms, doesn't blow up, and doesn't contain strange edge cases that will cause it to fail for no reason. Many developers preach the joys of functional programming, which eliminates most edge cases by prohibiting functions that have side-effects.

Everyone knows about the subtle, nasty bugs that can crop up in C++, often as a result of doing something that was intuitive, yet wrong. This is rehashed in the "C++ is bad" arguments over and over and over without end, especially with the functional programming zealots. The problem is that HTML/CSS has all sorts of really stupid crap that can happen when you do something subtly wrong with the HTML that is not immediately obvious to a new developer.

It took me a while to learn that you shouldn't be putting block level elements inside inline elements in your HTML - it will almost always work, until it doesn't, and it won't be obvious what exactly is going wrong. Many people new to HTML aren't even aware of HTML resets, so they'll have to try and remember which elements are block-level by default and which aren't. Then the new standard introduced a bunch of psuedo-block level elements that try to fix some of these problems, except they aren't supported by everything because MICROSOFT, so now you're stuck with a bunch of workarounds for IE that take forever to develop.

Just recently I discovered an amazingly weird bug with my webpage, wherein upon first loading it, all my buttons would be stacked vertically. It appeared that Chrome was ignoring float:left on those elements... until the page was refreshed or any other part of the website was visited, at which point everything started working again! Firefox, of course, didn't have any issues with it. The problem was that I had a <p> element defined as a giant button, then put <a href=""></a> around it because I wanted the entire button to be a link. This, of course, violates the inline/block element mandate I outlined above, despite it being a very natural thing to do - you want the entire button to link somewhere? Put a link around it. It'll almost always work, until it doesn't.

Trying to write perfectly standards conformant HTML is exceedingly difficult because half the time what you want to do isn't in the standard or is some hack that works almost all the time but not quite. The rest of the time, the "standard" way of doing things is completely and utterly bizarre, like using margin:auto 0; to center elements. But wait, that only works on horizontal elements! If you want to vertically center an arbitrary element, you have to use a lot of weird crap just to get it to work on everything. Or you could just use a table. But tables are bad, so you should never use them, even though they actually solve a whole lot of problems new developers have because their non-table solutions are completely unintuitive, because we're all trying to use a document layout engine to make GUIs, for crying out loud.

Many web developers argue that these problems are going away now that we have a better standard. Sadly, they are just getting started - WebGL will become exceedingly important in the next 5 years, and its standardization is an absolute mess almost to the point of it being unusable. Then there's the sordid situation with HTML5 audio and video, which is only just starting to get tolerable. These problems are not going away - they are simply being replaced by different problems. Of course, some stuff actually is becoming easier in HTML - just like a lot of stuff is becoming easier in C++11. So either you ignore both the new C++ features and the new HTML features, or you admit that C++ has become less horrible recently.

Of course, C++ is still way too easy to write unmaintainable code in, and HTML/CSS code is clearly self-documenting! Except it obviously isn't, given the endless horror stories of terrifying CSS dependencies with random !important keywords flung around in a giant mess that's just as impossible to understand as templatized C++ hell.

But wait, if you just write proper HTML, it won't have that problem! Well, duh, if you write proper C++, you don't have that problem either. I'm sorry, if you are going to hate something, you can't have your cake and eat it too. If C++ supporting features that can be abused to make code impossible to read, like operator overloading, makes it a bad language, then CSS is a bad language, because there is an endless list of obscure, bizarre syntax you can use in your CSS style sheets (like !important) that will make your HTML almost impossible to read. But wait, C++ is also incredibly hard to parse! HTML being easy to parse must be why Opera recently gave up trying to maintain its own HTML layout engine... Oh wait. Well at least javascript is a consistent, easy to understand language that doesn't have any weird quirks... JUST KIDDING!

So it seems modern technology has succeeded in replacing a very fast, difficult to use, inconsistent language with 3 different, very slow, difficult to use, inconsistent languages.

Now, if you want to believe that HTML/CSS is still good when used correctly, then all I ask is that you grudgingly admit that, maybe, just maybe, C++ is also good when used correctly. If you still think C++ is an abomination from the depths of cthulu, I hope you can admit that web development therefore must also be an abomination.

Or we can just keep arguing with each other, because that's always productive.

February 10, 2013

I'm Slowly Losing My Mind

I say a lot of things. I avoid lying at all costs, and instead prefer to simply leave out a lot of... details. Like why I started a game development company that spends an awful lot of time developing tools instead of games. Or why I've spent 6 years chasing a dream, and instead of doing what any sane person would have done and used existing frameworks to achieve my supposed goal of creating the various game ideas I've had, I have stubbornly built my own framework of tools, giving myself control of everything from the high level game engine down to CPU specific SSE optimizations and how I allocate my arrays.

I extended std::string into my own string class and use my own replacement for std::vector. I built my own audio engine. I built my own graphics engine. I built my own game engine, state control system, box2D physics integration, and serialization. Now I've even built my own GUI framework, because CEGUI was such a load of crap. I resisted doing that one for a long time, until it became increasingly obvious to me that I had no choice.

If I really wanted to just make a game, what the hell am I doing? I'm building an enormous foundation for some unseen purpose, as if I had something else in mind. Something bigger. Something that I set out to do without realizing it years ago when I decided to build a graphics engine.

It's hard to avoid lying to other people when you're lying to yourself and don't realize it. I wanted to make games, but the reasons were more complicated than that. I wanted to make game-building tools. I wanted to unlock the creative potential of a thousand artists so they could build games that far surpassed this modern slump of quality we seem to have gotten stuck in. But the rabbit-hole kept going deeper the farther into college I got and the endless failures I was met with. Constantly I would try to utilize the power of my work, take advantage of the fruits of my labor, only to find that my labor was horrendously misguided, and always failing to produce a product. Something was always either wrong with the engine, or more often a significant chunk of it simply wasn't there. I have built so much, and yet I dream of failure.

Despite this, I press onward with relentless enthusiasm, driven by a strange force of hope in the face of overwhelming evidence that I have absolutely no fucking idea what I'm doing and am clearly destined to fail miserably. I graduate college in 2 months. I'm running out of time.

Sometimes I feel like I'm just going to die when the end comes and I have to give up everything I strove to create for a normal job. Of course, with a degree in Applied Mathematics and years of complex programming, my normal job would probably involve being paid a 6 figure salary. I would stare at those 6 digits and feel only the crushing weight of regret, because my idealism had failed - destroyed by the seething hatred of reality. By the time I had gotten enough money to "pursue my dreams", I would have gotten married and be tied down by kids. My desperate attempt to reclaim the dreams I had in my youth would be met with the horrifying realization that I could no longer recall what those dreams were. This is the living hell that haunts my nightmares.

People are confused. They don't understand why those dreams are so important. They ask me, why are you doing this? And I reply, because I have to.

For as long as I can remember, I have had an increasingly wild and extravagant imagination. It would be triggered by movies, animations, books, music, art, anything that gave my brain a new idea to absorb. It would assimilate the new ideas and then spit out visions and sounds distilled from every good part of everything I've ever seen or heard, combining and recombining elements from a thousand different sources until they become a cacophony of beautiful chaos.

And then they fade, and I am left staring at a blank wall, frustrated once again by the fact that I can't make those dreams happen. Even in my one creative outlet, music, I am so incompetent I can only stumble on good ideas by accident, and they are never even remotely related to the orgasmic explosion of amazing sounds I hear in my imagination.

I thought this was normal. I thought everyone had such an insanely hyperactive imagination. It was only recently I realized that my condition was highly irregular for a software engineer. It also explained why I had such perpendicular opinions to the rest of the programming world, and why the majority of my friends were artists.

I also realized I was going to go crazy if I couldn't figure out a way to get it out, which is definitely not normal. The ideas feel like they're trying to claw their way out of my brain, ready to burst fully realized into my monitor. Parts of them I can reverse engineer and say "I know how I could do that." Others require multiple things to be invented - I've already invented at least 2 technologies whose prototypes are locked away. Some things I simply don't think I can do on my own. I need help. I'm not a genius, I'm just a programmer who's slowly being driven mad by his creative frustration.

Everything I had ever done makes sense when you realize that I am almost entirely a product of creative impotence. I keep building more and more powerful tools in frantic, desperate attempts to express myself. My foundation is being built in preparation for the construction of an entire suite of tools whose sole purpose is to give me a suitable creative outlet. I'm building a foundation for tools I probably don't even know I'm going to make yet - that's happened a disturbing number of times. It seems like I am following a plan so obtuse I can't even figure out what I'm doing. And I can't stop. There is no way to make me stop. If I became homeless I would still find a way to work on my tools, to try and find a way to let the creative flood out of my head, because I have to.

The things I see in my head, I have to make them happen. I have to make them real. Somehow. I'll invent a new precedent for 3D graphics rendering if I have to. Don't even try to tell me something is impossible, because even if you convince me that my ideas are insane I will try to get as close to them as I can anyway. It doesn't matter if I am destined to fail, or chasing an impossible ideal, because without it I have no reason to live, and can derive no joy from my existence. If I get a normal job, I rightfully believe that it will end up killing me, physically or mentally. Even if I don't get a normal job, I am now terrified that if the great Aaron Swartz was somehow driven to suicide by an unrelenting, hopeless reality, my idealism stands even less of a chance. No matter how frightened I become, my imagination remains an unrelenting torrent of ideas, slowly eating away at my mind. It will never let me stop trying. Ever.

I just didn't tell people because they simply wouldn't understand unless I explained how I was basically insane by society's standards. But now, I feel the endgame is upon me, and I don't know if I can beat the final boss of this dungeon that is my life. I'm running out of cards to play, and I'm not sure if I'm going to survive. I feel like this mask of sanity and reasonableness has gotten me as far as its going to get me, and that if I am going to beat this, I need all the help I can get, and lying to everyone that I am actually some sort of reasonable person isn't going to help anymore. I'm not a normal person. I am a delusional idealist who is chasing his dream like a goddamn determinator and nothing short of death itself is going to stop him. As I have learned the hard way, you can try as hard as you possibly can, and sometimes it still just isn't enough.

If curiosity killed the cat, perhaps creativity is killing the rabbit?

February 7, 2013

Windows Breaks assert() Inside WM_CANCELMODE

So I have this dll that's doing a bunch of horrible WinAPI calls for me. It's designed to abstract away all the pain and unholy functions feeding on innocent blood. Little did I know that trying to cage WinAPI into a more manageable corner would be my undoing.

The window is created and assigned a WndProc callback function inside this DLL, as per the various absurd requirements involving how you create windows in Windows. Everything works just fine and dandy until the application window suddenly closes, an error "ding" is heard, and the program silently crashes without any sort of error message whatsoever.

What just happened?

Well, I'm afraid you just triggered an assertion. But instead of doing what an assertion is supposed to do, which is immediately crash the program so you know what the fuck just happened, it instead somehow manages to create an infinite callback loop caused by the operating system actually trying to assign the assertion dialog to the window. You know, the same window that was part of an application that's supposed to be in the middle of CRASHING?! This causes another message to be sent, thus causing another assertion to be violated, et cetera until the stack overflows, except it doesn't actually tell you the stack overflows, it just crashes with absolutely no explanation. Even while in a debugger, which is truly amazing.

Specifically, the assertion triggers a dialog box to be displayed, but this dialog box forcibly sends another WM_CANCELMODE message to the application, apparently completely bypassing the entire point of having a message queue, because the program never gets to go back to it. It's WndProc is simply called with WM_CANCELMODE because fuck you, and so if your assertion fails when you're processing WM_CANCELMODE, it will simply do this over and over and over until the entire window tree collapses in on itself from the intense gravitational pull of astronomical amounts of stupidity.

The resulting black hole sucks in all nearby sources of sanity, which include some sort of error message about the stack overflowing, or perhaps the actual fucking assertion error, and then explodes, leaving you without a goddamn clue about what just happened. This is usually followed by copious amounts of screaming, then disbelief, then finally assuming the fetal position and praying for forgiveness for attempting to touch the windows API, as the Microsoft gods laugh and drag another developer's soul into their black circle of hell.

Somehow, every time I touch the windows API, it always ends with me curled into a ball, moaning "what the fuck" over and over again while crying.

February 3, 2013

How My Little Pony Destroys The Universe

Princess Celestia WILL satisfy your values through friendship and ponies, and it will be COMPLETELY consensual.

Friendship Is Optimal is a hard science fiction short story (level 5 on Mohs Scale Of Science Fiction Hardness) that explores the implications of a general artificial intelligence tasked with maximizing an optimization function. The problem with Strong AIs that are told to maximize some function is best described via the Paperclip Maximizer, wherein an AI that is capable of self-improvement is told to amass the largest collection of paperclips possible. In order to do so, the AI makes itself progressively more intelligent, until it's exponential intellect eventually enables it to convert all matter in the solar system to paperclips. In Friendship is Optimal, this AI is tasked with maximally satisfying the values of all human beings, subject to certain constraints. In this way, the AI is, for all intents and purposes, perfectly benevolent and dedicated to making all of humanity lead happy, fulfilling immortal lives.

Unfortunately, it inevitably turns into a runaway lotus eater machine, such that all of humanity is (voluntarily) assimilated into an exponentially growing blissful simulation that eventually destroys the entire universe (or rather, turns it into a giant quantum computing device). In the process, it explores aspects of the human psyche, the effects on human society and its eventual disintegration, outlines how a virtual physics system might be able to simulate non-euclidean geometries, and describes magic as a simple programming language for reality itself.

Did I mention it's also a My Little Pony fanfic?

While a science fiction story of this quality would stand on its own without the hilarious association to the My Little Pony: Friendship Is Magic franchise, it does not suffer from this in any way. If anything, it makes the story even more potent, as it does a vastly more effective job as hammering home just how impossibly smart a true runaway AI optimizer actually is. Our first instinct to the idea of the entirety of humanity being convinced to live out immortal lives in Equestria is that it is completely insane, and that there is simply no way a significant portion of people would actually agree to that, let alone everyone. In part, this is correct, but only because Celest-AI managed to convince just 99.99999% of the world's population. An AI that is more intelligent than the combined intellect of all of humanity would be very persuasive.

In the end, even if we create a perfectly benevolent AI designed to maximally satisfy our own values (through friendship and ponies!), it would still destroy human society, then Earth, then the solar system, then the galaxy, and finally the entire universe, and possibly any neighboring universes unfortunate enough to be nearby. And we would all live happily ever after. As ponies. In Equestria. And you'd love it. Princess Celest-AI will make sure of it.

Now read the damn story. It will satisfy your values through friendship and ponies. Forever.