Skip to main content
Escape Characters

Project Management

What does programming look like?

Unless you're looking in very particular places, or trying to get something to bend to your will, you're not often going to run across something that constitutes "programming." The user interfaces of the last 20 years have all but abstracted us from what it means to program a computer, and replaced it with what it means to interact with a computer.

If you're interested, I can show you some cool stuff. And I swear it'll get to a point that has nothing to do with programming at all. Yeah? Alright. Maybe we'll all learn something.

So: code. What can it look like? Here's a function I use on idkfa to give users an idea of the age of various posts.

function short_time_diff($first, $second) {
// Calculate the magnitude of distance between both dates $difference = abs($second - $first);

// Progressively determine if magnitude is greater than certain
// increments in time. Return values if larger, but detect smaller
// measure of time for smaller difference magnitudes (year, month,
// week, day, hour, minute, and finally, seconds)

if($difference > 31556926) { return ($difference >= 0 ? '+' : '' ) . floor($difference / 31556926 ) . 'Y'; }

if($difference > 2629743) { return ($difference >= 0 ? '+' : '' ) . floor($difference / 2629743 ) . 'M'; }

if($difference > 604800) { return ($difference >= 0 ? '+' : '' ) . floor($difference / 604800 ) . 'W'; }

if($difference > 86400) { return ($difference >= 0 ? '+' : '' ) . floor($difference / 86400 ) . 'D'; }

if($difference > 3600) { return ($difference >= 0 ? '+' : '' ) . floor($difference / 3600 ) . 'H'; }

if($difference > 60) { return ($difference >= 0 ? '+' : '' ) . floor($difference / 60 ) . 'min'; }

return ($difference >= 0 ? '+' : '' ) . $difference . 'S';

/* A few weeks ago. */
//Friend: "You know, that girl, whose birthday it was... [Name], she thought you were cute."
//Drunk, Sleepy Josh: (incredulous look, with a mouth over-full of water)
//Friend: "She did, man."
//Drunk, Sleepy Josh: (swallows water) "I don't believe you." (walks off)

}

The function above's name is short_time_diff. It takes two parameters, the variables $first and $second, which are integers that represent time in the number of seconds since January 1st, 1970, 12:00AM (otherwise known as "epoch time"). The idea behind it is to calculate time differences between $first and $second, and return those differences in terms of short signifiers like ("+3S" for "three seconds time difference" and "+3M" for "three months time difference). The lines with "//" or "/*" preceding them are called "comments" or "remarks." These are for documentation purposes: for programmers to write notes, reminders, or warnings for themselves or others.

The above is pretty simplistic, but demonstrates something you'll likely see frequently: helper functions that make small things easier, especially if you have to repeat their functionality frequently. This code is used almost everywhere on idkfa v3, where it's used to measure the distance between when a post was created and now (to give you a sense of how old a given post is).

The code below is a a little more complicated: it is the code that idkfa uses to inspect posts, determine if there are "naked" links ("http://yahoo.com," etc.), and then rewrites their HTML so that you can click on them (rather than having to copy and paste).

function linkURL($text) {

// Find everything that matches a URL string pattern
$matches = array();

preg_match_all(
"`(=\")?https?://[-A-Za-z0-9+&@#/%?=~_|!:,.;]*[-A-Za-z0-9+&@#/%=~_|](\">||\"\s*/>)?`",
$text,
&$matches,
PREG_SET_ORDER | PREG_OFFSET_CAPTURE
);

$offset = 0;
foreach( $matches as $match ) {
// For each match, detect whether somebody put an HTML anchor
// around the URL, or if the URL is inside of an anchor attribute
// definition
if($match\[1\] || $match\[2\]) {
// Someone did the work for us, carry on
continue;
} else {
#$text = str\_replace\_once($match\[0\], "$match\[0\]", $text);
// We'll have to do some replacing ourselves, keeping track of how
// we're mangling the string as we go along
$replacement = '' . $match\[0\]\[0\] . '';
$text = substr_replace($text, $replacement, $match\[0\]\[1\] + $offset, strlen($match\[0\]\[0\]));

$offset += strlen($replacement) - strlen($match\[0\]\[0\]); } }

/* Years ago, half-remembered, sitting next to some school field */

// Friend: "You know I was talking to [Name] the other day."
// High School Josh: "Oh?"
// Friend: "She said you had a nice ass."
// High School Josh: "Oh. I... I disagree."

return $text;
}

The code above demonstrates the pattern matching, string manipulation, iteration, and decision paths common in any program.

Somewhat confusingly, not all code is strictly "code." Sometimes, in certain contexts, the purpose of code is to describe a problem, or a solution to a problem, rather than to act directly on something. In fact, many computer languages are designed to be explicitly descriptive, and to contain no "imperative" or command-like pieces at all. Somewhat counterintuitively, these types of languages can be a powerful asset, as they reduce a programmer's responsibility of solving the problem his or her self, instead relying on more efficient, and more likely better tested code to solve the problem based on their computer language descriptions.

Take for instance, the code below:

class YourRoomContext extends ChildContext {

static $actions = array(
"first::look|examine|search:bed" => "find_phone_act",
"first::look|examine|search:*" => "look_act",
"first::get|find|pick up:phone|cell|cell phone" => "get_phone_act",
"first::charge|plug in:phone|cell|cell phone" => "plug_phone_act",
"first::wake up|get up:" => "wake_up_act",
"first::open:eyes" => "wake_up_act",
"first::get out:bed" => "wake_up_act",
"first:bed:get:bed" => "wake_up_act",
"first::open|close:door" => "door_act",
"first::go:door|out|apartment|hallway|outside" => "leave_act",
"first::leave:*" => "leave_act",
"first::call:work|office" => "call_work_act",
"first::go:bed" => "go_bed_act",
"first::go:desk" => "go_desk_act",
"first::put on:clothes" => "dress_act",
"first::get:dressed" => "dress_act",
"first::yell:cats" => "yell_at_cats_act",
"first::whatever:" => "whatever_act",
"first::find|get|pick up|grab:glasses" => "get_glasses_act",
);

public function find_phone_act( $key ) {
list( $id, $subject, $verb, $object ) = explode( ":", $key );

if( $this->glasses ) {
if( !$this->phone_found ) {
$this->phone_found = true;
res(
$id,
nl("Ah, there it is. How adorable. Like a
nightmare-frightened child, or a
heat-siphoning pet animal, your _phone_ slept with
you in the bed. And looking at the _phone_, it
doesn't look good. Looks to be completely dead."

)
);

/* Rest of the class code is omitted for brevity. */

/* Two years ago

Friend: "So what's the deal with [Name]?"
Josh: "Well, we went on two dates. First was dinner, and I thought it went pretty well. Then we went to play frisbee golf and had lunch. And then I didn't call her back."
Friend: "Ah."
*/

}

This example comes from the text adventure I'm working on. (A text adventure is a very, very simplistic video game in which players type commands like "go mailbox" or "look around" in a text box, and the game responds by letting them interact with a virtual world through textual descriptions). The code above is a data structure definition, mapping possible user actions (find, get, pick up, etc.) and their operands (glasses, clothes, door, bed) to specific functions in the code. However, in no part of this code do I explicitly tell the computer "do this" or "do that." Instead, other parts of the code are taught to interpret and react to the patterns above, and I'm free to change the mappings however I see fit without changing the underlying code itself.

For example, in the first mapping, it says that if the terminal with ID "first" types a command that has its verbs interpreted to "look," or "examine," or "search," and that command wants to operate on the "bed," then call the "find_phone_act" function. So if somebody types "search the bed," they'll get forwarded to the appropriate "find_phone_act" handler, and they'll successfully find a phone in their bed.

With code like this, I can describe my text adventure rather than having to explicitly predict and then code every single response. It makes programming much easier, and leaves more time for other things (like, say, writing an actual adventure story, rather than just lines and lines of code). Languages like HTML (the structure of every web page you've ever seen), CSS (Cascading Stylesheets, describing the look and feel of a web page without defining its context), SQL (Structured Query Language, which gives programmers abstract but powerful access to data in databases), and numerous others are critical to developing modern applications, so much so that it's rare to use "just one" programming language in any given circumstance.

These three examples are part of a working codebase, part of numerous if not dozens, maybe hundreds of files that make up a complete program or application. They represent what a few dozen lines of code can look like, how they represent ideas, and how they're at once small, self-contained microcosms of mathematical and logical complexity, and also part of a greater whole.

However, one point remains to be stated: between the some hundred lines listed here, it likely took hours of testing, wrangling, getting things wrong, getting things right, rewriting, reworking, optimizing, and then finally arriving at a final solution. The short_time_diff function was wrong in its first few iterations, and even then it's slightly misleading as it only tells you at least how big the time difference is, but never the exact value. The text adventure code is just a simple mapping, whereas the code behind it has taken upwards of 20 hours to design, write, and improve upon as I've solved problems and added features to the adventure engine. And linkURL function above, while short compared to other functions on idkfa, took me 7 years to get it to its current state, and even still it has a few corner cases I can't account for.

---

I'm not including any of this to brag, or condescend, or to confuse. I'm including it to show you that while "code" in TV and movies flashes on the screen and looks like noise, the real thing is just about as confusing and noisy, if only formatted slightly more coherently. That, and I guess to give you a sense of magnitude of what programming looks like, feels like, its purpose, and what it takes to sit down and do it.

Now... now we get to the part that might be misconstrued as bragging. The following is a list. A list of personal projects I've had in the past years, their basic description, and the size of their codebase.

It's a difficult problem, and one mostly unsolved, to say how many hours go into each line of code. The general trend is, of course, the more lines, the more complex the project. The idkfa v3 codebase is about a thousand lines longer than the original idkfa, and yet the majority of it took a fraction of the time it took to complete on idkfa v2. (The idkfa v2 is also a cobbled together mess of patchwork and shame, but that's another story.)

One could ask: if original idkfa had features that new idkfa didn't, why would original idkfa's codebase be shorter? I would argue in that case that a shorter codebase is not necessarily a more "correct" codebase, nor is it one guaranteed to be as safe, or robust, or as efficient. New idkfa has considerably more error checking than its predecessor, and runs much, much faster, such that I've yet to have to approach any solutions for page caching. At the cost of slightly more complex code, I was able to improve the quality of the project altogether.

There's also that the original Basement Chronicles, Iterate/Literate, Logparse, Dull Glow, idkfa v3, and the Precious applications all use nearly identical database abstraction functions that I've written once and reused throughout. This means that while I have about ~300 lines worth of database functionality in each of these projects, I've only written that functionality once. The time spent getting those 300 lines correct in the beginning has saved time later on.

There's also the complexity of the problems you're trying to solve. For example, Paste is a program that copies information inputted from the Internet to a file, and then writes that information to a file, and then displays that file. Computationally, this is about as simple as an Internet application can get. No logic, no login page, nothing. It could be written in maybe a few dozen lines if you didn't care so much about how the information was presented to the user, or if people would want to attempt to hack your site through it.

On the other hand, take Logparse. It's main function was relatively simple to implement (read a bunch of files, see who sent which message, record it, move on). However, the difficulty wasn't in reading in files, it was identifying all of the different patterns each of my assorted chat clients generated (MSN, AIM, Trillian, GAIM, etc.), and being able to put them all into a single database. The process consisted of finding a pattern, trying to capture that pattern, succeeding/failing, moving on to the next pattern/try different way to capture pattern. Each test run took about 5 minutes. There were many, many patterns. It was a slow, slow process.

The point... the point is time. Incredible, irredeemable, vast amounts of time. And despite what people may think, I don't spend the majority of my time at work on these personal projects (unless severe boredom sets in). This means that these hundreds, maybe thousands of hours when and if I'm ever done with a project, are logged in that narrow band of time called nights and weekends. When I have my free time.

To call it "free time" probably isn't a great way to put it. When you think of the free time of a soon-to-be 26 year old white male, you think of parties, or working out at the gym, or spending time with (their own) family, or significant others. And in some cases, I may approximate these things. But there's maybe a distinction that should be drawn, and that is how I handle my free time when there is a project. When there is a project, I have in my mind (stuck on what seems to be infinite repeat) that there is a project, and the notion that I need to finish it, or work on it, or otherwise consider it heavily until I can get back to it. My interest in everything else somewhat wanes, and my drive for this one thing seems to shove everything else onto the backburner.

Maybe you are this way, too. Maybe then you'll understand when I say that having a project is an exhilarating experience, a fun dance of known and unknown in a potentially knowable universe. Everything else seems to fade away...

And then it's done. You've figured out how to retrieve hierarchical data from a database using a single query. You've figured out how to efficiently store read/unread post information using a novel storage mechanism. You've got the bike ticking off RPMs. You've figured out exactly how much of your life you've spent listening to Ben Folds. So on and so forth.

And it's been hours. Days. Weeks. Time has passed quickly. You've neglected to eat, sleep, bathe, socialize. You were still functioning, but as a means, not an end. Conversations became difficult, distracting, and often tended back towards the project. That is the allure of the project, after all: if may just solve everything. Or maybe just the simple question you set out to answer, frivolous though it may be. But it's an answer that can be had. Must be had.

I like to think I've got some control over this fugue state, but it's not something I can easily shut off. Left to my own devices, I would much, much rather work on algorithms and databases than spackling or painting walls, going to a party, replacing decks, cleaning bathrooms. Things becoming of a 26 year old white male. But when there is a project nothing else really seems interesting or important.

I may be dramatizing a bit, but what I'm saying isn't far from the truth. Pragmatism, common sense, and the other side of my brain can usually kick in to at least give me a few hours reprieve. But focus always seems to blur. And I can't stop my mind from wandering back to where it wants go to.

---

And there are projects that never finish.

Chances are, you didn't read the code examples above. That's fine. I would hope they just gave you a sense of code, rather than an understanding. Even programmers sometimes have a distaste for reading code that isn't immediately relevant to the problems they're trying to solve. Too much noise, too little time. However, had you done so, you might've noticed strange things in the comments. Things that might've been copied and pasted in error, but not the case.

Like I mentioned before, code comments are meant to give you an idea what the programmer is thinking. Code, while it is effectively the most precise way to define an idea, is not always the most accurate when it comes to perfectly simulating an idea. Comments are included to not only reflect the programmer's intention, but also their feelings and misgivings on a given topic. A programmer's job is not only to be productive, creative, imaginative, and graceful and elegant in implementing their solutions, but like an engineer building a bridge, they are always held accountable for their actions. And the first question to be asked of a programmer when they are found to be wrong is "What were you thinking?"

And in such cases, discerning intention from pure code is a painful, time consuming process. And thus, out of necessity, this means that programming source code is a multi-channel medium. You have the pure logic and syntax of a computer program, carefully wrapped in plain-English documentation. The cold, calculating machine and the humanity that defined it. Two streams on the same wire. And this, to some degree, is how I feel things might be represented if you wanted to record how I think. There's the purity of thought, and then how I have to, how I am forced to communicate it.

I started writing this with the intention of it being about programming, and projects, and how my passions for them drive me away from other things in my life. And how in just this last year I've put together more projects, with more lines of code, and with more time dedicated on potentially fruitless (or sometimes entirely useless) pursuits than I had in the seven or eight years before that.

And at some moment in the middle, I lost interest, because I knew what I was writing wasn't what I was thinking about anymore. The project had lost steam, and another one had taken its place. My mind, again, had started to wander, because someone gave me a piece of information that was interesting, vague, ambiguous, and a seemingly impossible outlier. And my mind immediately started grouping it with the rest of the data I had similar to it, recovering archived information, drawing comparisons, performing analysis, calculating meaning, keeping me awake.

The conclusion I draw is that I just don't get it, and likely won't. People use words like attraction and relationship and whatever else, and I understand that they are words, but nothing exists where there should be some underlying thought to which those words should translate.

So I don't understand what the term attraction is supposed to entail. Six girls sit around a table in a bar, all of which have fruity alcoholic drinks with straws, most half-empty or emptied, and more than likely not the first. One walks over, the one who's supposed to be having a birthday (and isn't likely to have paid for any drinks, or to have had any shortage), to greet a group of newcomers whom she doesn't know. She greets each one in succession. One in particular, a male, somewhat overweight, non-descript, dark, shabby clothing, a slovenly neckbeard, unfashionable glasses and a utilitarian haircut shakes her hand in introductions and immediately forgets her name. She smiles politely, small talk is made with the newcomers for less than five minutes (little of which is with the quiet, neckbearded one), and then newcomers depart.

At some point, it is taken away from this that "she thought [I was] cute," of which I was apparently oblivious, and had to be informed of later. The last female who described me as "cute," or more specifically, that "[I] have a nice ass," now almost ten years ago, had a computer infected with the particularly destructive W32.Blaster virus and was stuck in an infinite reboot loop. I fixed her computer, and we never spoke in person again. This isn't me stating that I think people feign attraction to get free technical support, nor am I accusing said person of such a thing. Correlation is not causation, and one example does not determine the sample set. I more bring it up to establish possibility (however unlikely), and to get a sense of probability: in a 10 year span, I've been aware of people being attracted to me no more than three times (sometimes I am not oblivious). Normal males say that "three is greater than zero," and consider that a win. I prefer, instead, the more realistic weighted moving average, which operates over a discrete time window, which, by now, has rendered probability of attraction down to a comfortable zero again.

My point being: I wasn't (intentionally) being rude when, in response to my friend telling me somebody might have been attracted to me, I just said "I don't believe you," no matter how much I'd had to drink. Instead, I was stating that given the incredible unlikelihood of the event, and the context of whatever information would have had to have been passed to signal attraction, and the nigh-impossibility of attraction occurring on any given day based on my personal collected data, that I was having a hard time believing them. Given my utter absence of faith in my handling of such things, I have to go with what I'm given. And for what I've been given, my worldview is better supported with the assertion that attraction just doesn't apply towards me, and in all likelihood, everything before, and events in the future, are most likely in error.

And I guess it follows that if I don't understand attraction, then I don't understand what the term relationship is supposed to mean. I'm of the assumption that attraction leads to relationship, but this is something I've never understood, despite the varied examples all around me. The genesis (and eventual armageddon) of any relationship is a completely unknown and foreign process. I've only ever been witness to the sudden massive toggle flipping from not relationship to relationship, seemingly overnight (ha), and that same toggle flipping massively back when a relationship ends. Apparently, you're not supposed to know what a relationship is before you're in a relationship, nor how to start a relationship or determine whether you can or should start a relationship until you've been in a relationship, nor whether to end a relationship until after you've ended one.

Which makes first dates (the aftermath of one as described in the comments above) seem all the more bizarre a ritual, and even more insane if they're blind dates. Human beings are amazingly complex, diverse, and intelligent creatures that live for 60 or so years. Conveying the nature of a person over the course of a couple of hours by way of eating, small talk, interview-like questioning, and occasional eye contact doesn't seem effective, or even possible to me. All that I can get out of that is if the other person chews with their mouth closed (which, while this is a great determinant of whether a person should be allowed to live, is maybe not the fairest thing to judge their entire personality by). I wish I knew what was supposed to be accomplished, or sought. The choir of angels scenario seems pretty unlikely.

Despite constant consideration, I can't understand the simplest things.

---

My family has a good family friend. She's an emergency room doctor, one of the best in Arizona, in fact. And she is deathly afraid of stage performers (specifically, when the stage performers come off the stage and into the audience for any reason). Any time she's in an audience where there's the possibility that the stage performers may approach her for something, she panics. Even if they want nothing to do with her, simple proximity makes her afraid. Afraid of what they'll do, or what they'll ask, or say, or whatever they might do to single her out or make her uncomfortable.

Strangely, this lady also loves musicals and dinner theater. Which to this day I don't understand, but can't help but appreciate.

Describing her fear, she has said (from what I remember), "Give me a person who is on the floor, bleeding, dying of something horrible. I know what to do with that person. I know how to save them, patch them back up, and my job will be done." But somebody starts singing in the aisles, and she has to go to her happy place. It's something she just isn't programmed to handle.

I can relate to this to some degree. Extreme introversion aside, there's nothing that eats at me like an interesting project that I haven't finished yet. I can see, plain as day, from start to finish, what it will take, where it will go, what it must do, how it must do it. There's some comfort in that, I suppose, combined with the thrill of creation and innovation. Granted, I'm not saving anyone's life, or even making anyone's life better in most cases, but it's a similar thing: it's something we know how to do, and we do it well, and it's what ultimately drives us. It's the rest of the world that doesn't make sense.

Which is, I guess, where I make my departure. This lady has a husband, a son, a family, and is generally a warm, kind, contributing member of society. Like how I assume many doctors are out of necessity, she has to compartmentalize, divide her life strictly between work and not work. If she didn't, her life outside of work would be stress, litigious patients, and the incredible likelihood of imminent accidental death.

I have no such division (nor such a compelling reason to create one). My profession is computers, with most if not all of my hobbies consisting of or relating to the same. If there is a project, I have no problem coming home and working on it until I have to sleep for work the next day. I'll get tired, or hungry, or uncomfortable, and do something else for a while, but usually only as an intermission. Because for a while, this is what makes me happy. Until suddenly it's over. Or I'm distracted by something else, finding something more compelling or urgent.

It's only the familiar loneliness that returns interstitially that reminds me that perhaps I'm working on the wrong project(s).

I think I've referenced 'The Nerd Handbook' before. The older I get, and the less beholden I am to social, familial, and professional obligations, I find that I am slowly becoming more like the 'nerd' that the author describes. I've always liked the article because it succinctly and humorously defined qualities that I've so often struggled against (but eventually just had to accept and move on). Reading again recently though, in my current mindset, I like less the implication placed upon the author's intended audience.

In writing the article, he's speaking directly to the significant other of a 'nerd,' and, presumably, that significant other is frustrated by the nerd's personality. He describes the same compulsions and obsessiveness as my own, and describes ways to 'hack' the process in order to better deal with the nerd's quirks and idiosyncrasies. But even the author expresses some disbelief at the existence of the audience, and acknowledges what I imagine to be requisite frustration on the significant other's part (should they exist).

I've thought about this some.

Say I'm wrong at every point. I've made every wrong decision, and have come to every wrong conclusion, and I am also the extreme minority in how people lead their lives and their relationships. And, also say that there's somebody on the opposite end of the spectrum, with every correct understanding of how this system is supposed to work.

Like the case with the birthday girl, what would they necessarily conclude, given their 'Nerd Handbook' level knowledge in considering my case?

They would see obsessive compulsion, constant distraction, ill-consideration for emotional reasoning, complete misunderstanding of all social norms as regards attraction and relationships, and a bizarre and unhealthy fixation on puzzles, toys, and constructs that don't exist in the real world.

They medicate children for those symptoms these days. Or at least pass diagnoses of psychological conditions.

I'm not convinced these are all bad traits to have, nor could I really change them if I wanted to. Just that at face value, this is how I would have to seem, to tipsy girls at bars, to blind dates, whomever. Representing myself as anything else seems disingenuous. And while redeeming qualities may exist elsewhere, our culture (or what pieces I've been lead to believe pertain to relationships) values traits much differently for males than I happen to align with. Great weight is placed on physical attractiveness (at the tender age of 26), alongside communication, and emotional understanding, and paying attention, and listening, and how closely you can approximate Edward Cullen.

Which, I guess, is just too goddamn bad.

I'm not trying to be self-deprecating. I'm trying to be realistic. And to some degree, specific in documenting (and maybe apologizing for) what goes through my mind, and is sometimes expressed when drinking, when my well-founded and oft-analyzed pessimistic world views as regards relationships are challenged.

I'm sorry, friends, blind dates, even you, random girl at a bar. Your time may be better spent elsewhere. I just don't understand.