Why I Program the Way I Do

I started a new project this year, RocketTux, with the intention of using it as a way to transition from making MMO emulator mods in C++/Lua and crazy stuff in Blender/Python, to facilitating the creation of my creative visions by way of HTML5/Javascript. “That’s overly wordy, isn’t it, Rob?”, you may say, but the truth is that I am not one of those pedantic nerds who argues about programming paradigms, stacks, pointers, “computer security”, or any of the other numerous non-subjects so many “coders” and old-timey “programmers” tend to fuss about. Nope, much like Frédéric Auguste Bartholdi probably didn’t know how to smelt the copper that clads the Statue of Liberty, I really don’t care about the details of how computers get to the end point of presenting my creations. I… just don’t care, at all. So when I say I wish to use HTML5/Javascript to “facilitate the creation of my creative visions”, what I am doing is clarifying that I am content to use nerdy tools to make cool stuff!

So with that in mind, here are some answers to questions that may cross one’s mind when studying the source code of one my open source projects.

Q: Why are you such a terrible programmer?
I learned procedural programming in the early 1990s on a Commodore 64, where rudimentary functions in the BASIC language could be achieved by using GOTO statements and then returning to the line below the entry point with another GOTO statement. Since then I have puttered with other programming languages and systems, having long since decided that I definitely did not want the stress, stupidly long hours, and other head-sploding annoyances that come with working as a professional programmer (I’d rather clean toilets and be poor as dirt, yet happy!). I enjoyed solving the logic puzzles involved in programming, essentially being able to “tell” the computer how to achieve my goals, and that remains the extent of my interest in “computer science”. Sure, I know a lot about some computer hardware, because I find some of it interesting, but I sincerely couldn’t care less about the finer points of computer programming languages. I loathe C++ and other such languages for the way they dump things that computers should be… computing! onto the human being. “Computer, show me a house. Great, add a window here. Now make it French provincial. No, smaller. Better.” – why the hell CAN’T we do that today, like they’ve been doing on Star Trek for 50 years??? The answer is simple, the folks who are smart enough to program such a device are a bunch of pedantic nerds who would rather pick nits and talk gibberish in a thinly veiled effort to prevent their own obsolescence; I am not one of them. I am an artist who is content to use the tools required to give form to his creative visions. As such, I LIKE TO program in such a way that a person can actually understand what my programs are doing by, you know, reading the code and the comments and junk…

Q: Why do you use if statements rather than the ternary operator syntax?
Simple: The intention of the if statement is immediately discernible to anyone who is familiar with logical flow in general. If statements “make literal sense” and therefore have the capability of being universally understood. Take the following for example,

IF bob falls down and cuts his knee
    clean and bandage bob's knee
ELSE
    kill all humans

Clearly, the intent there is for our robot to kill all humans when it’s not occupied by healing bob’s wounded knee. And that would probably be clear to any literate human being, let alone people who are familiar with the syntax of a specific programming language.

Q: If that’s the case, then why do you use the short form syntax for objects and array’s in Javascript?
I do this because the shorthand method is also immediately clear to any reader.

var appleVarieties = [‘delicious’, ’empire’, ‘macintosh’];

It is immediately obvious that the variable “appleVarieties” is a container that holds a list of varieties of apples. The same goes for objects, which look pretty well the same as arrays, except that the entries also have names.

var profile1 = {
    name: 'John Smith',
    number: '555-555-5555',
    email: 'john@someplace.net'
}; 

Reading either of those declarations is not only easy, but they are both direct visual representations of structure of the objects. Furthermore, they clearly demonstrate the relationships between each element, as well as how the elements can be used by way of their parent variable.

var myAppleType = appleVarieties[0]; // myAppleType = ‘delicious’
var playerName = profile1.name;

Q: Why don’t you use ____ library/syntax/etc.?
Different strokes for different folks! When it comes to libraries though, trust that I have tested a multitude of libraries, game engines, frameworks, and so on over the years. There will always be a variety of ways to achieve the same goal and I prefer to use the least complex, most readable way to achieve things. “Kids these days” seem to love their convoluted as hell programming structures and, well, good for them if that’s what they like. However, I am content to do my own thing in a logical, easy to follow way.

Q: In RocketTux, why didn’t you parse the XML files for the Tiled levels directly?
Performance and simplicity. Given that it took very little effort to convert the comma separated values for the tile maps created by Tiled into Javascript objects and the reality that they would never change, why create hundreds of disk reads when it could be done in a single disk read? Computers have far more RAM than what is required to run the program, so I may as well load as much into RAM as possible, as it’s orders of magnitude faster than even solid state drives. Also, by creating 40 tile wide level sections as JS objects, it was easy in Phaser to string them together randomly to form ever changing level layouts (whereas loading a Tiled map within the Phaser framework appears to be an all or nothing, one shot deal).

Q: Again in RocketTux, why did you duplicate data in your loot groups rather than keeping it separate and then combine the arrays as needed at run time?
Performance. Why force the program to continuously build something that is literally never going to change in its constructed form? Especially given how easy it was for me to copy and paste the data from the spread sheet. In this way, all the program has to do is reference the array and pick one entry at random.

Q: You do realize that you’ll always be a terrible coder, right?
It’s called programming, not “coding”, and that thing you call a “method” is literally referred to and declared as a function… A “method” in programming is how one goes about programming without getting Cheetos dust all over the keyboard… Now, get off my lawn! 🙂

Essentially, I program the way I do to help clarify the intention of the program; Performance optimizations for an end-user version of the software can be compiled or configured in a build specifically for those people who will only ever use the software, provided that doing so will tangibly improve the performance of the software (aka, doing so is worth the time and effort).