November 26, 2014

How Not To Install Software

It's that time of the year again, when everyone and their pony puts on a sale, except now it seems to have started much earlier than the traditional Black Friday. Needless to say, this is the only time of year I go around buying expensive sample libraries. One of these libraries was recommended by a friend: LA Scoring Strings - First Chair 2, a cheaper version of LA Scoring Strings. It's $100 off, which is pretty nice, except that the page that describes the product doesn't actually have a link to buy it. You have to click the STORE link, and then buy it from there, because this is a completely obvious and intuitive interface design (it isn't).

So, after finding the proper link in the Store and verifying I am actually purchasing what I want to purchase, they give me exactly one payment option: Paypal. This is pretty common, so we'll let it slide, and the whole process seems to go smoothly until they give me my receipt. On the receipt page, they gave me a link to download the files, and a serial number. How helpful! Until I click the download link, which does not open in a new window, and instead opens a completely different webpage with absolutely no way to get back to the page I was just on, because there is no store page with this information and I have no user account on this site. So, I have to go to my e-mail, where they have helpfully e-mailed me a copy of the receipt (probably for this exact reason) to get the serial number.

I then go back to the download page only to discover that I am required to use their stupid download manager in order to download the product I just bought. There is no alternative option whatsoever. So I download their stupid download manager and it magically installs itself somewhere on my computer I will likely never be able to find because it never asked my permission to do anything, and then demands that I log in. Well, obviously, I don't have a log in, and no one asked me to register until now, so I go to register, which helpfully opens my web browser to register... on a forum. Well, ok, so I register on the forum with a randomly generated password, and activate my account.

So naturally, they then e-mail my password back to me, which by definition means they are storing it in plaintext. So now the password to my account was sent over an unencrypted, entirely open channel, which is insanely stupid, but this is just a sample library, so whatever. I go back to their download manager and put in my credentials and... the login fails. Well, maybe it takes a bit to propagate - no, it just isn't working. I try again, and triple check that I have the password right. I log out and back into the forum with that very same password, and it still works. It just doesn't work in the application.

Standard procedure at this point is for me to take every single weird punctuation character out of my password (making it much weaker) to address the possibility that these people are pants on head retarded and can't handle a password with punctuation in it. I change my password to an alphanumeric one, and lo and behold, I can suddenly log in to the download manager! Let's think about this for a moment. The password I used had some punctuation characters in it (like "!&#*@(?" etc.), but in order to make sure it was still a valid password, I logged in to the forum with that password, and it succeeded. I then went to this application and put in the same password and it failed to log me in, which means the program actually only accepts some random subset of all valid passwords that the forum lets you register with.

This is laughably bad programming, but my woes aren't over yet. I click the download button only to get this incredibly helpful message: "Cannot connect to download servers." Pissed off, I go play a game in the hopes that once I get back, the servers will work again. I close the game only to discover that my download manager is one giant grey screen no matter what i do to it. It's forgotten how to draw it's own UI at this point. I restart the program, and it has (of course) helpfully forgotten my login credentials. This time, it displays a EULA it apparently forgot to show me the first time around, and once I accept, clicking install successfully starts downloading the files!

Of course, once the files are installed, they aren't actually installed installed. I have to go into Kontakt and add the libraries to it's magical library in order for them to actually get recognized. I can't tell if this is AudioBro's fault or Native Instruments fault, but at this point I don't care, because this has already become the worst installation experience of any piece of software I have had to go through in my entire life.

What's frightening is that this is par for the course across the desolate wasteland that is Audio Sample Libraries. The entire audio engineering industry employs draconian and ultimately ineffective DRM security measures, often bundled with installers that look like they were written in 1998 and never updated. The entire industry uses software that is grotesquely bloated, digging it's filthy claws into my operating system and doing all sorts of unspeakable things, and there is no way out.

You can't disrupt this field, because samples rule everything. If you have good samples, people will buy your shitty sample libraries. EastWest moved from Kontakt (which is a pretty shitty piece of software considering it's the best sampler in the entire industry) to their own proprietary PLAY engine, which is unstable, bloated, entirely dependent on ASIO4ALL to even work, and prone to crashing. They still make tons of money, because they have the best orchestral samples, which means people will put up with their incredibly bad sampler just so they can use their samples, which are all in a proprietary format that will get you violently sued if you attempt to reverse engineer it.

So, even if you develop the best sampler in the world, it won't matter, because without samples, your software is dead on arrival. Almost all the samples that are worth having come in proprietary formats that your program can't understand, and no one can convert these samples to another format (unless they want to reverse engineer the program and get sued, that is). So now the entire sampling industry is locked in a oligopoly of competing samplers that refuse to talk to each other, thus crushing competition by making the cost of entrance so prohibitively high no one can possibly compete with them. And then you get this shit.

November 22, 2014

Never Reinventing The Wheel Is Anticompetitive

Reality is that which, when you stop believing in it, doesn't go away.
― Philip K. Dick
Nowadays, you aren't supposed to write anything yourself. In the world of open-source software, you're supposed to find a library that does what you want, and if that doesn't work, commit a change that makes it work. Writing your own library is a bad thing because it's perceived as redundant if there's already a library that does most of what you want. The problem is that this is inherently anti-competitive. If there's only one library that does something, you have a monopoly, and then you get Heartbleed, because there's zero diversification. However, if I try to invent my own wheel, I'll just be scolded and told to contribute to an existing wheel instead, even if my wheel needs to have giant spikes on it.

I'm beginning to wonder if these people actually understand how software works. Code is not some kind of magical, amorphous blob that can just get better. It's a skyscraper, built on top of layers and layers of code, all sitting on top of a foundation that dictates the direction the code evolves in. If someone invents a better way to architect your program, you can't just swap pieces of it out anymore, because you are literally changing how the pieces fit together in order to improve the program. Now, I'm sure many coders would say that, if there's a better architecture, you should just rip the entire program apart and rebuild it the better way.

The problem is that there is no one-size fits all solution for a given task. Ever. This is true for any discipline, and it is still true in the magical world of programming no matter how loudly you shout "LALALALALALA" while plugging your ears. By definition you cannot create a software library that is constructed in two different ways, because that is literally two different software libraries. Thus, just like how we have many different wheels for different situations, it is perfectly fine to reinvent the wheel to better suit the problem you are tackling instead of trying to extend an existing library to do what you want, because otherwise you'll end up with a bloated piece of crap that still doesn't do what you want. If you actually believe that it is possible to write a vector math library that covers all possible use scenarios for every possible solution, then I invite you to put monster truck tires on your smartcar and tell me how well that works. We might as well ask the Flying Spaghetti Monster to solve our problems instead.

You want there to be several different libraries for rendering vector graphics. You want there to be many different programming languages. You want there to be multiple text layout engines. These things create competition, and as each codebase vies to be used by more and more people, each will start catering to a slightly different set of problems. This creates lots of different tools that programmers can use, so instead of having to use their Super Awesome Mega Swiss Army Knife 4000, they can just use a butter knife because that's all they goddamn need.

At this point, most coders will struggle to defend their position by falling back on the tried and true saying of "well, for most programmers, this is perfectly reasonable." Exactly what do they mean by most programmers? Because most programmers use C++, C, and Java, and are probably maintaining systems that are 20 years old and couldn't possibly apply anything they were just told in any realistic scenario. Do they just mean programmers who are making hip WebGL applications? What arbitrary subset of programmers are we talking about here? Of course, at this point, it doesn't matter, because they are literally cherry picking whatever programming community supports their opinion, and we're praying to the Flying Spaghetti Monster again.

Diversity is important. I am tired of programmers living in some fantasy world where all diversity has been eliminated and everyone follows the One True Path, and uses the One True Library for each individual task. This is not a world I want to live in, because my problems are not your problems, and even if your library is amazing at solving your problems, it probably won't solve mine. I'll go even further and say that this kind of thinking is dangerous. It reeks of cargo-cult coding and institutionalized knowledge designed to destroy creativity.

When people say you shouldn't re-invent the wheel, they mean you shouldn't re-invent the wheel if that's not what you're trying to do. If your main goal is to make a game, you shouldn't write a graphics engine. If your main goal is to make a webpage, you shouldn't write a webpage designer. However, if you just finished a game and think "Gee, that graphics engine was terrible, I'm going to make a better one," then writing your own graphics engine is perfectly fine.

Including the entire jQuery library just so you can have the $("id") shortcut is like driving a smartcar with spiked monster truck wheels down a freeway. It's dangerous, stupid, and completely unnecessary.

October 18, 2014

Everyone Can Be Above Average

When everyone's special, no one is.
 — Anonymous
Time and time again, I hear the wise old members of our society insisting that my generation has been gravely misled. They claim that, by telling every child that they are special, no one is. They claim that everyone can't be above average.

This is painfully ridiculous.

When someone says that every child is special, they are saying that each child is special in their own way. Each child is blessed with a gift of their own, wholly unique to them. Every child being above average is only a paradox if you are lumping every single human experience into one giant number, which is an insulting perversion of the diversity of life.

No human being will ever produce the exact same art, or solve a problem in the exact same way. Each of us brings our own unique experiences to the table, and that is why we are all valuable. Only by exploring a plurality of techniques can we find a better one. Only by bringing to bear a huge number of unique perspectives on a problem can we find an exceptionally elegant solution. One of those perspectives will see something that most of us don't. One of those perspectives will create a work of art that no other human being could have conceived.

Yes, every child is special. Yes, every child can be above average... in their chosen field of interest.

A good example of this is to look at artists. Almost any artist who can do rudimentary shading is an above average artist. This is because most people aren't professional artists. Once you start looking at professions, having even the tiniest drop of talent will likely catapult you into being above average, because our modern world is full of specialists. If you pick any random profession, the average skill level of that profession, when summing over the whole of the human race, will be close to zero, because most people aren't in that profession.

So, simply by choosing a profession and learning the basics of it, a human being will be capable of doing things most other people can't.

Telling kids they're special is simply saying that they are unique, and that no other human being is like them. This is, much to the frustration of the institutions who would prefer us to be mindless factory drones, the truth. We each approach life in our own way, slightly different from everyone else. One person's perspective may seem useless and bland, just a pale shadow of everyone else, until they happen to stumble on that one place where their slightly different view of the world let's them see something no one else can.

When talking about a person as a whole, no one is better than anyone else. We simply experience the world in different, equally valid ways. We can be better than other people at a specific thing, but not in general.

Every snowflake is unique, but only when you look at them under a microscope. In the grand flurry of life, they all seem to blur together, forming featureless piles of uniformity. It is not enough to look for the truly exceptional. We must recognize that even the most insignificant details can make all the difference in the world.

It's the little things that matter.

September 22, 2014

What Use Is A Good Job?

I am not a particularly happy person these days.

Certainly this is not because of my financial situation. I have a six-figure job at some giant software corporation writing code no one will ever see. I can afford to buy whatever tickles my fancy because I have no family to raise, or even a romantic interest. I could stay here for years and make so much money I wouldn't know what to do with it all.

People often think that I am successful. Perhaps I am. I don't care. It doesn't matter to me. Things like cars and gaming rigs and fancy TVs are just a waste of space. The most precious material possession I currently have is a $130 custom plush I bought on a whim at a convention. The other things I buy are usually art prints or games that are on sale, never anything that costs more than $30. My total material purchases each month amount to 0.2% of my paycheck. Most of it goes towards supporting artists, not because I want more things.

A lot of my friends are artists. Most of them live in a dump. They don't have good medical insurance, and they survive on shitty jobs that pay almost nothing, if they can find a job at all. I can't tell you how depressing it is when all the people you care about are struggling to make ends meet and the most you can do is buy some of their prints. Every now and then some emergency comes up and I help them pay a particularly nasty bill, but none of this actually solves the underlying problem of them needing a better job.

The most important thing in the world to me is art and music. It is creativity in all its forms. Few people seem to share this viewpoint with me, and even fewer still put their money where their mouth is. To me, a world without art is dull and meaningless, and yet artists get no respect. They get paid almost nothing, they are scammed, and they are taken advantage of at every turn. The reaction most people have to this is "artists need to get a real job."

Oh, really? Is that what this is all about? Everyone should get a degree in applied mathematics and write software, huh? Whose going to draw all the icons? Whose going to draw the logo? Whose going to design the interface? Whose going to create the sound effects? Have you ever tried actually doing these things? It's hard! It's just as hard as writing software, but some people are better at drawing things than writing software. I'm tired of people thinking that artists are artists because they can't do anything else. Artists are artists because they can do things you can't do. They should at least be respected for that.

What do people even want with all this money? What are you going to do, buy another car? Does this make you happy, having a bunch of useless crap in your garage? Does buying a giant house that says "I'm richer than you are" make you happy? If you're going to tell my friends to get a real job, then surely you won't mind me telling you to get some real friends?

You know, friends who care about things other than consumerism. Friends who care about you because you're a human being instead of all the things you have. Friends who don't care how much money you have, or your social status, or whether or not you put on cologne in the morning. Friends who will go exploring with you, friends who follow you to conventions, friends who will fight to help you survive even when they themselves can barely pay the bills. Real friends are loyal to each other's hearts, not each other's things.

I've been on both sides of the fence, now. I can tell you that money stops mattering once you can pay rent on a nice place, buy food, and afford dentist appointments. Everything beyond that is meaningless and empty. It's just numbers on a screen. Sometimes it lets you buy an expensive toy for yourself that you wouldn't have been able to afford otherwise, but they are always just that - expensive toys. They fade with time.

Friendships don't.

There is a future for me out there. I cannot walk that road alone. I will not leave my friends behind simply because society doesn't think they're important. I don't know how I'm going to get there yet, but one of these days, I'll figure it out. That day, I will find a better job. A job that doesn't involve satisfying the whims of a bunch of old men in business suits. It will be hard, it won't pay very well, and I won't be able to afford a new car, but contrary to what everyone thinks, it is possible.

And I'll be a lot happier than I am now.

August 8, 2014

Can We Choose What We Enjoy?

One of the most bizarre arguments I have ever heard in ethics is whether or not people can choose to be gay or not. The idea is, if being gay is genetically predetermined, it's not their fault, therefore you can't prosecute them for something they have no control over.

Since when did anyone get to choose what makes them happy? Can you choose to like strawberries? Can you choose to enjoy the smell of dandelions? At best, you can subject yourself to something over and over and over again and enjoy it as a sort of acquired taste, but this doesn't always work, and the fact remains that you are still predisposed to enjoying certain experiences. Unless we make a concentrated effort to change our preferences, all enjoyable sensory experiences occur without our consent. We are not in charge of what combination of neural impulses our brain happens to find enjoyable. All we can do is slowly influence those preferences, and even then, only sometimes.

This concept of people choosing what they enjoy seems to have infected society, and is often at the root of much bizarre and often unfair prosecution. If we assume that people cannot significantly change the preferences they were dealt by life, either as a result of genetic or environmental influences, a host of moral issues become apparent.

Gender roles stop making sense. In fact, prosecuting anyone on the LGTB spectrum immediately becomes invalid. Attacking anyone's sexual preferences, provided they are harmless, becomes unacceptable. Trying to attack anyone's artistic or musical preferences becomes difficult, at best. We know for a fact that someone's culinary preferences are influenced by the genetic distribution of taste buds in their mouth. It's even hard to properly critique someone's fashion choices if they happened to despise denim or some other fabric.

As far as I'm concerned, the answer to the question "why would someone like [x]" is always "because their brain is wired in a way that enjoys it." Humans are, at a fundamental level, sensory processing machines that accidentally achieved self-awareness. We enjoy something because we are programmed to enjoy it. To insult what kinds of sensory input someone enjoys simply because they do not match up with your own is laughably juvenile. The only time this kind of critique is valid is when someone's preferences cause harm to another person. We all have our own unique ways of processing sensory input, and so we will naturally enjoy different things, through no fault of our own. Sometimes, with a substantial amount of effort, we can slowly change some of those preferences, but most of the time, we're stuck with whatever we were born with (or whatever environmental factors shaped our perception in our childhood).

Instead of accusing someone of liking something you don't approve of, maybe next time you should try to understand why they like it, instead. Maybe you'll find a new friend.

July 6, 2014

I Don't Care Anymore

This weekend, I went to a convention and bought a ton of stuff. This was unusual for me, because I am not normally someone who invests in materialism. Having a lot of stuff is not something that is important to me. Two things changed this year: I now have an obscene amount of disposable income, and I stopped caring about what other people think is important, because they don't care about what I think is important.

Respect is, inherently, a two-way street. When we are talking about things that are inherently subjective, like what kind of food I enjoy eating, or what books I like to read, I will not respect your opinion if you refuse to respect mine. There is absolutely no reason for me to care about what you think if you don't care about what I think. On the flipside, if you respect my opinion, but disagree with me, I will also respect your opinion, even if I disagree with it.

I buy art prints because I want to support artists. I want to support artists because I think art is more important than anything else, but few people share this view. Furthermore, most people don't care what I think, and expect me to conform to whatever vision of importance they subscribe to.

Before, I grudgingly tried to give society the benefit of the doubt. I tried to show respect to other people's admittedly bizarre concept of what is important in a human life, in the hopes that this respect would be reciprocated. It is now clear to me that society at large is dumber than a rock and isn't worth my time, so I'm not even trying to appease it. I simply don't care anymore.

I do not have time for meaningless debates about my life choices. If people don't understand how I spend my money or my time, it's because they don't see the world the way I see it. They don't value the same things I value. This does not automatically make me wrong, it makes me different, and I don't give a shit about stupid ideological bullcrap. I don't care about what they think is important because they don't care about what I think is important. They can sit there all day long, writing stupid comments about how I am wasting my talents, or how I should join a startup, or work for some company they love, or how I'm depriving humanity of some stupid thing I don't care about. I don't care.

I may like art that you think is stupid. I don't care, I like it, and I think it's important. I think every facet of human diversity is a beautiful thing that should be encouraged instead of brutally stamped out in elementary school. I think creativity is what makes us human, and what will ultimately be our last useful skill after robots have taken over everything else. I think we have better things to do then argue about shows for little girls.

I'm going to do everything in my power to support those artists, because other people won't. I will spend my entire life fighting with every fiber of my being for better welfare and support for artists that live in poverty. These artists aren't poor because they're lazy, they're poor because people won't support them. They're poor because society doesn't think they're important.

But I do, and you can be damn sure I'm going to do something about it.

June 28, 2014

How To Make Your Profiler 10x Faster

Frustrated with C profilers that are either so minimal as to be useless, or giant behemoths that require you to install device drivers, I started writing a lightweight profiler for my utility library. I already had a high precision timer class, so it was just a matter of using a radix trie that didn't blow up the cache. I was very careful about minimizing the impact the profiler had on the code, even going so far as to check if extended precision floating point calculations were slowing it down.

Of course, since I was writing a profiler, I could use the profiler to profile itself. By pretending to profile a random number added to a cache-murdering int stuck in the middle of an array, I could do a fairly good simulation of profiling a function, while also profiling the act of profiling the function. The difference between the two measurements is how much overhead the profiler has. Unfortunately, my initial results were... unfavorable, to say the least.
BSS Profiler Heat Output: 
[main.cpp:3851] test_PROFILE: 1370173 µs   [##########
  [code]: 545902.7 µs   [##########
  [main.cpp:3866] outer: 5530.022 ns   [....      
    [code]: 3872.883 ns   [...       
    [main.cpp:3868] inner: 1653.139 ns   [.         
  [main.cpp:3856] control: 1661.779 ns   [.         
  [main.cpp:3876] beginend: 1645.466 ns   [.         
The profiler had an overhead of almost 4 microseconds. When you're dealing with functions that are called thousands of times a second, you need to be aware of code speed on the scale of nanoseconds, and this profiler would completely ruin the code. At first, I thought it was my fault, but none of my tweaks seemed to have any measureable effect on the speed whatsoever. On a whim, I decided to comment out the actual _querytime function that was calling QueryPerformanceCounter, then run an external profiler on it.
Average control: 35 ns
What?! Well no wonder my tweaks weren't doing anything, all my code was taking a scant 35 nanoseconds to run. The other 99.9% of the time was spent on that single, stupid call, which also happened to be the one call I couldn't get rid of. However, that isn't the end of the story; _querytime() looks like this:
void cHighPrecisionTimer::_querytime(unsigned __int64* _pval)
{
  DWORD procmask=_getaffinity(); 
  HANDLE curthread = GetCurrentThread();
  SetThreadAffinityMask(curthread, 1);
  
  QueryPerformanceCounter((LARGE_INTEGER*)_pval);
  
  SetThreadAffinityMask(curthread, procmask);
}
Years ago, it was standard practice to wrap all calls to QueryPerformanceCounter in a CPU core mask to force it to operate on a single core due to potential glitches in the BIOS messing up your calculations. Microsoft itself had recommended it, and you could find this same code in almost any open-source library that was taking measurements. It turns out that this is no longer necessary:
Do I need to set the thread affinity to a single core to use QPC?
No. For more info, see Guidance for acquiring time stamps. This scenario is neither necessary nor desirable.
I couldn't get rid of the QueryPerformanceCounter call itself, but I could get rid of all that other crap it was doing. I commented it out, and voilà! The overhead had been reduced to a scant 340 nanoseconds, only a tenth of what it had been before. I'm still spending 90% of my calculation time calling that stupid function, but there isn't much I can do about that. Either way, it was a good reminder about the entire reason for using a profiler - bottlenecks tend to crop up in the most unexpected places.
BSS Profiler Heat Output: 
[main.cpp:3851] test_PROFILE: 142416 µs   [##########
  [code]: 56575.4 µs   [##########
  [main.cpp:3866] outer: 515.43 ns   [....      
    [code]: 343.465 ns   [...       
    [main.cpp:3868] inner: 171.965 ns   [.         
  [main.cpp:3876] beginend: 173.025 ns   [.         
  [main.cpp:3856] control: 169.954 ns   [.         
I also tried adding standard deviation measurements, but that ended up giving me ludicrous values of 342±27348 ns, which isn't very helpful. Apparently there's quite a lot of variance in function call times, so much so that while the averages always tend to be the same over time, the statistical variance goes through the roof. This is probably why most profilers don't include the standard deviation. I was able to add in accurate unprofiled code measurements, though, and the profiler uses a dynamic triple magnitude method of displaying how much time a function takes.

April 20, 2014

Complexity Is Irreversible

Once again, programming language flame wars are erupting over the internet. This latest one gives us a helpful list of "harmful things" and "less harmful things". Unfortunately, I felt that it was a little inaccurate, so I decided to improve it:

Harmful thingsLess Harmful Things
Things That ExistThings That Don't Exist

Just to clear up any confusion, here is a helpful diagram:

This alt intentionally left blank

As many very smart people have pointed out over the years, the ultimate enemy of software development is complexity. Unfortunately, you can't get rid of complexity if the thing you are making is inherently dependent on something complicated. I think most people will agree that real life is a pretty complicated place, and the human brain is an awfully complex irrational thing that is trying to interact with real life.

This can't end well, and it doesn't. When we try to do anything, we wind up with something complicated. This isn't because all problems are complicated. The issue here is that in order to push a button on your calculator application, you have to go through a UI thread to the software through 10 different functions each calling into the operating system which is on top of the kernel which is on top of the microkernel which is on top of the BIOS which is on top of the motherboard which is controlling the CPU which is built using microcode which is executed using a bunch of extremely tiny logic gates on a chip.

Now, we could build a computer whose entire purpose is to let us push a button on our calculator application, and it would be much simpler! All we would need is a button command built into the motherboard to a RISC CPU that operates a few logic gates on a chip. This mysterious object is called a calculator. You know, the real, physical calculators that nobody uses anymore.

The reason we don't use them anymore is that we need our computer to do a lot more than simply be a calculator. This is why everything is so complex - if you want something that does several different simple tasks, you will end up with something complicated, even if the tasks are themselves simple. We can, of course, still pretend that everything is simple, just as the OS abstracts away all the low-level nonsense required to make your computer work properly, like setting that goddamn A20 gate on the CPU every time it boots. However, simply pretending something doesn't exist does not make it go away, which is why that stupid A20 gate still causes mysterious boot errors. Hence, any simple program written in any language imaginable is still subject to mysterious bugs and memory leaks that don't make any sense because they are caused by the inherent complexity of the system they are built on top of. You can't un-complicate something. Complexity is irreversible.

Nothing you do will fix this. If you use C to try and keep everything simple, you'll destroy the entire internet's secure infrastructure because of a completely retarded mistake involving an asinine and ultimately useless memory allocator. But if you use a managed language, before long you're writing a UI in XAML and suddenly you're looking at a call stack the size of Mount Everest.
What the fuck
Despite this, there is no end to the deluge of misdirected attempts at "solving" or "reducing" complexity, despite the impossibility of the task. What happens is that a programmer makes a bunch of mistakes, and notices a pattern. Because they're a programmer, they immediately invent a language that prevents them from making those mistakes, and then claim it's the solution to all the world's problems, while conveniently forgetting that the rest of the world has completely different problems.

But, I digress. My point is that the only way to write a piece of software that doesn't break is to hire someone who's so incredibly smart they can deal with all this complexity.

The problem is, no one is that smart.

April 6, 2014

Fiction

I was reading a story on the plane today. It was the tale of a terrible war, a battle between two civilizations bent on the destruction of the other. It spoke of barbaric acts, of unspeakable horrors, of cruelty and pain on such a magnitude it could only exist in a place devoid of morality.

None of it is real. No one is really dying, no one is having their heart broken, no one's lives are really being destroyed. And yet, it bothers me. It bothers me because I know such tales of war were not composed in a vacuum. The power that story holds over me does not come from the imaginary characters it paints, but of the real people it is based off of. The lives that really were lost, the tragedies that tore us apart, the chapters of human history most of us would prefer to forget.

I sometimes find it difficult to keep reading, to discover the horrors I know are lying in wait for our beloved protagonist. With each tragedy that befalls them, I find myself feeling sorry for the character in the story, even though they aren't real. Yet, I'm also feeling sorry for the millions of people I have never met who suffered the same fate. It's difficult to continue because every chapter reminds me of the perils of human existence. I'm not sure there is a happy ending to this tale, or if there is, what the tremendous costs might be.

Perhaps we seek happy endings in our stories because we care about these imaginary characters that have been invented for our benefit. Or perhaps it is because we desperately want to believe that our lives also have a happy ending. We project our troubles and battles into what we read, wanting to believe that we can be the protagonist in our own tales.

This story speaks of tremendous struggles, of soldiers who lost everything and fought to save their nation from being lost to the sands of time. It is brutally effective in reminding us of what we truly hold dear, of what really matters in the end. It puts you in the armor of a new recruit who is suddenly left wondering if he should have spent more time enjoying life now that his could very well be extinguished in a moment. You watch a soldier die by the hand of his own commander simply because he refused to obey a command he knew was wrong.

You don't need a sword to tear the life out of your closest friend. A drunk driver could do the same. A rare disease. Cancer. We may frame heartbreak in many different ways, but the emotion stays the same. The pain of loss is something that transcends mere words, and we can feel it's power even when we're reading about people who never existed.

Sometimes, stories are hard to read because they remind us too much of the world we were trying to escape in the first place. They remind us of everything—and everyone—we could lose.

And those... those are the most precious stories of all.

March 18, 2014

The Problem With Photorealism

Many people assume that modern graphics technology is now capable of rendering photorealistic video games. If you define photorealistic as any still frame is indistinguishable from a real photo, then we can get pretty close. Unfortunately, the problem with video games is that they are not still frames - they move.

What people don't realize is that modern games rely on faking a lot of stuff, and that means they only look photorealistic in a very tight set of circumstances. They rely on you not paying close attention to environmental details so you don't notice that the grass is actually just painted on to the terrain. They precompute environmental convolution maps and bake ambient occlusion and radiance information into level architecture. You can't knock down a building in a game unless it is specifically programmed to be breakable and all the necessary preparations are made. Changes in levels are often scripted, with complex physical changes and graphical consequences being largely precomputed and simply triggered at the appropriate time.

Modern photorealism, like the 3D graphics of ages past, is smoke and mirrors, the result of very talented programmers and artists using tricks of the eye to convince you that a level is much more detailed and interactive than it really is. There's nothing wrong with this, but we're so good at doing it that people think we're a heck of a lot closer to photorealistic games then we really are.

If you want to go beyond simple photorealism and build a game that feels real, you have to deal with a lot of extremely difficult problems. Our best antialiasing methods are perceptual, because doing real antialiasing is prohibitively expensive. Global illumination is achieved by deconstructing a level's polygons into an octree and using the GPU to cubify moving objects in realtime. Many advanced graphical techniques in use today depend on precomputed values and static geometry. The assumption that most of the world is probably going to stay the same is a powerful one, and enables huge amounts of optimization. Unfortunately, as long as we make that assumption, none of it will ever feel truly real.

Trying to build a world that does not take anything for granted rapidly spirals out of control. Where do you draw the line? Does gravity always point down? Does the atmosphere always behave the same way? Is the sun always yellow? What counts as solid ground? What happens when you blow it up? Is the object you're standing on even a planet? Imagine trying to code an engine that can take into account all of these possibilities in realtime. This is clearly horrendously inefficient, and yet there is no other way to achieve a true dynamic environment. At some point, we will have to make assumptions about what will and will not change, and these sometimes have surprising consequences. A volcanic eruption, for example, drastically changes the atmospheric composition and completely messes up the ambient lighting and radiosity.

Ok, well, at least we have dynamic animations, right? Wrong. Almost all modern games still use precomputed animations. Some fancy technology can occasionally try to interpolate between them, but that's about it. We have no reliable method of generating animations on the fly that don't look horrendously awkward and stiff. It turns out that trying to calculate a limb's shortest path from point A to point B while avoiding awkward positions and obstacles amounts to solving the Euler-Lagrange equation over an n-dimensional manifold! As a result, it's incredibly difficult to create smooth animations, because our ability to fluidly shift from one animation to another is extremely limited. This is why we still have weird looking walk animations and occasional animation jumping.

The worst problem, however, is that of content creation. The simple fact is that at photorealistic detail levels, it takes way too long for a team of artists to build a believable world. Even if we had super amazing 3D modelers that would allow an artist to craft any small object in a matter of minutes (which we don't), artists aren't machines. Things look real because they have a history behind them, a reason for their current state of being. We can make photorealistic CGI for movies because each scene is scripted and has a well-defined scope. If you're building GTA V, you can't somehow manage to come up with three hundred unique histories for every single suburban house you're building.

Even if we did invent a way to render photorealistic graphics, it would all be for naught until we figured out a way to generate obscene amounts of content at incredibly high levels of detail. Older games weren't just easier to render, they were easier to make. There comes a point where no matter how many artists you hire, you simply can't build an expansive game world at a photorealistic level of detail in just 3 years.

People always talk about realtime raytracing as the holy grail of graphics programming without realizing just what is required to take advantage of it. Photorealism isn't just about processing power, it's about content.

February 20, 2014

Success Is Relative

It seems that many people view success as some sort of absolute value, usually inextricably tied to how much money you make. Ignoring the fact that we should not be tying success to monetary value, we should also not be treating success as some sort of absolute value based on where you end up. What really matters is where you started from.

Climbing a mountain is not that impressive when you start half a mile from the peak. On the other hand, if you start all the way at the bottom, climbing the whole thing is very impressive, indeed. A blogger once said that being born as a middle-class straight white male is like playing life on easy mode. Minorities have many cultural barriers they must break down to reach the same level as a white male, often because they are born poor.

Poor people have a huge range of difficulties that are hard to appreciate unless one experiences them first-hand. To the middle-class, overdraft fees, parking tickets and unexpected taxes are nothing more than an annoyance. To the poor, they are the stuff of nightmares. A single slipup, a single misstep, and they will lose all the spending money they had for the next 3 months, and possibly not be able to buy dinner. They must work demanding, low-paying jobs that leave them physically and mentally exhausted, which itself makes it even harder for them to land a promotion or pursue their hobbies.

Robbed of the mental energy to work on things they find interesting and fun, poor people often slip into depression, or self-destructive lifestyles, because there literally is no way out. The only way out is for them to somehow be less stressed, which requires a better job, which requires them to have more time to spend bettering themselves, which requires them to be less stressed, which requires a better job...

It's the worst kind of catch-22, and it's one whose existence is repeatedly and blatantly denied by a middle-class oblivious to the struggles of the poor. They do not understand the herculean efforts it takes to do things that seem simple and routine for themselves. They do not appreciate how impressive it is when a poor person elevates themselves to a position that they might consider demeaning.

What's worse is that they over-inflate their own progress, and then act as though a poor person could have done the same thing. "Just teach yourself how to do it," they say. "Use the internet," they say. They don't understand that without a decent education, poor people either do not understand the importance of these things and shouldn't be expected to, or they have so much to learn they can't possibly find the time to do so in conjunction with the soul-sucking job that occupies most of their time. Being poor is not a slight disadvantage, it's like starting a race half a mile behind your opponent with a lead weight attached to your ankle, and your opponent has a motorcycle.

Many of my acquaintances, when they hear of my 6-figure salary, automatically assume that I am successful. That I have somehow beaten the odds through concentrated effort and landed an amazing job they can only dream of. The truth is that what I have accomplished is hardly anything special. I won the genetic and environmental lottery. I was gifted with talents that gave me a jump start on skills that happened to be wildly in-demand in today's economy. I went to excellent schools, and had attentive parents that never shielded me from my own failures, but encouraged me to learn from them. I worked just as hard as everyone else, but I didn't even need to. My efforts in making music and building games never accomplished anything. All I had to do was dutifully finish my schoolwork until I graduated with a degree in applied mathematics, and poof, I had a fantastic, cushy job many people would kill for.

This is hardly impressive. I have simply traveled the path that was set up for me, and every attempt I made to excel, to do more than simply walk down the road in front of me me has been met with abject failure. I was given a gift, a free ride halfway up the mountain, and I haven't made it very far at all. The people at the bottom look up to me and see success, without realizing that I have climbed the same distance they have.

They are just as successful as I am - they just started farther down.

When I see an artist just barely managing to make ends meet, I see success. When I see a musician living in a run-down apartment and paying rent, I see accomplishment. When I see a writer making ends meet with a few odd commissions, I see tenacity. Our culture heaps scorn on those who do what they love and barely manage to make a living out of it without realizing how brutally difficult this is to do. Simply managing to feed yourself by following your dream is an accomplishment on par with finishing a master's degree.

I am not writing this to belittle myself, or others, but to elevate those who have accomplished a great deal, and get comparatively little recognition for it. I write this because too often artists set absurd goals for themselves without knowing that the ones they idolize didn't climb nearly as many steps as themselves. Artists look around and see themselves barely surviving off of their art, and wonder if they are a failure, when in fact simply being able to sustain oneself like that is a great accomplishment. Sadly, it seems that it is an accomplishment that does not come with a diploma, or a trophy, or even respect.

I hope that artists, and poor people in general, will eventually realize that they are just as successful as everyone else - they just have more steps to climb.