Do Programmers Optimize... Life?

Back in university, a friend who was studying arts and I were talking and at one point I said something like "I see every situation as a problem requiring optimization", which elicited the response "How... sad".

Now I was probably no more than 19 at the time. By that stage I'd been programming for nearly 10 years, having started out on a Commodire VIC 20 (and yes I'm still bitter we didn't get a Commodore 64) then graduating several years later to the dizzy heights of an IBM PC-XT (complete with CGA graphics). That eventually got me onto Turbo Pascal, which marked a turning point.

That being said, even until the end of high school, it actually hadn't occurred to me that being a computer programmer was even a job, let alone that I should be one. I wasn't fast-tracking or jump-starting myself into a career. I just liked doing it and it had basically replaced that childhood stalwart of Lego. The two I think actually have a lot in common except programming is a far more tractable medium.

As it happened, I went to university not to become a programmer. In fact, I wasn't sure what I wanted to do yet. I just felt like I should go or even that it was expected (i was the first to go in my father's line). Interestingly, I had always had far more natural ability with mathematics.

During this period, a lot of what I now consider to be key indicators for a programmer-to-be were there: game-playing, basically. All sorts of games: computer games, card games, role-playing games. It borders on being a cliché. All of this relates to an affinity for problem solving, a penchant for analytical and rational thinking and an ability to conceptualize abstractions—all key abilities and qualities of a programmer.

This of course raises the age-old chicken-and-egg question of: do people become programmers because they have the right mindset or do they develop that mindset as a consequence of becoming computer programmers?

The truth, as always, probably lies somewhere in the middle (yes there is something between 1 and 0). It should be noted that people don't just magically have an analytical mindset. In spite of whatever natural predilections someone might have, a disciplined mind is something that is developed.

The question I'm getting to is: how much of this changes the way your mind operates? Learning analytical and problem solving skills for programming is one thing, But what about everyday life?

Let me give you an example.

Sometimes I'll walk home from work. This is a fairly long walk at about 5.8km (3.6mi). Pretty precise distance right? It probably won't surprise you to know I measured it with a GPS. Now like most reasonably modern cities, the layout is largely grid-based. The path to my house is not a direct line by road or walkway although it's pretty close. But I am "off" several blocks.

So immediately we have two problems:

  1. There are a number of different paths going a combination of horizontally and vertically with the requirement that at some point a given number of horizontal moves need to be made (assuming the longer distance is vertical in this relative frame of reference; and
  2. Any diagonal shortcuts are big potential time-savers as they, unlike any horizontal or vertical moves, can reduce the total distance needed to travel.

But it gets more complicated than that. Every road that needs to be crossed can be avoided (by changing route or using an overpass or underpass), crossed at a set of traffic lights or crossed where there are no lights. The traffic lights are significant because they will have timed pedestrian crossings. These may take longer to come up but are guaranteed to come up within a certain time period. With no lights on a particularly busy street you might be waiting awhile.

Sound familiar? In algorithmic terms, we have the classic (and common) choice between a deterministic and a probabilistic solution. So we can profile our street crossings:

Overpass/Underpass Traffic Lights No Traffic Lights
Best Case 0 seconds 0 seconds 0 seconds
Expected Case 0 seconds 60 seconds1 Varies2
Worst Case 0 seconds 150 seconds3 Varies2
1. Based on (3) and the possibility of an early crossing if traffic is sufficiently light
2. Each example needs to be considered independently and can vary by weather, whether it's school holidays or not, time of day and other factors
3. Based on experience of average cycle length of relevant traffic lights.

But wait, there's more! Pedestrian congestion needs to be considered. That bridge over Wellington St might be a convenient way to avoid a busy road and be out of the rain but it also has an awful lot of people on it going (at this time of day) to the train station.

Add to this you may need to vary the route for, say, trips to the supermarket, post office, an ATM, the butcher and so on.

Pretty full on, right?

Now I would imagine that if you're not a programmer—and not in IT altogether—your reaction to above is somewhere between bewilderment and horror. But if you are a programmer I'd say there's a pretty reasonable chance that you're not that surprised.

Before you write me off as suffering form severe OCD, perhaps this will allow you to downgrade it to, well, mild OCD. In this (excellent) movie Spy Game Nathan Muir (Robert Redford) is teaching Tom Bishop (Brad Pitt) spycraft. In a restaurant Muir says:

Muir:
Every building, every room, every situation is a snap shot. I'm sitting here talking to you, I'm also checking the room-memorizing it-the people, what their wearing, then I ask the question-what's wrong with this picture? Anything suspect? You gotta see it, assess it and dismiss it - most of it without looking, without thinking.
Bishop:
Without thinking?
Muir:
It's just like breathing. You breathe don't you?

My point is that the above scenario of optimizing the walk home—which I assure you has happened—is not something that I actually put much thought into or any preplanning. Like Muir, it's a reaction as automatic as breathing.

So am I hugely atypical (for a programmer)? Did programming make me this way? Did I become this way because of programming? I'm hoping the answers are "no", "somewhat" and "somewhat" but who can say for sure? Perhaps I'm just an allegedly functional savant?

I will say that I would be honestly surprised if the higher-order thought processes required to be a good programmer didn't leak into non-programming areas. If it didn't I think I'd find that level of compartmentalization a little disturbing.

49 comments:

Kraln said...

I also optimize paths, but I add weight for routes not being traveled twice.

... Are we both nuts?

Adam Griffiths said...

I would just like to point one small thing out to you. You say above in your post:-

"Any diagonal shortcuts are big potential time-savers as they, unlike any horizontal or vertical moves, can reduce the total distance needed to travel."

Whereas if we are taking the term block meaning a square, then subsequently you'd walking down the hypotenuse of a triangle. Since these triangles are all right-angled triangles then any diagonal shortcuts are not actually shortcuts.

Now we come to Pythagorus' theorum that any right-angled triangles hypotenuse squared is equal to the sum of the other two sides squared. Therefore in your problem diagonal shortcuts don't help shorten the journey time, it's simply a more direct route. But you knew that anyway.

But if we're taking the block in a literal sense, then there probably is a a small saving in time compared to my first attack.

Yes programmers do indeed optimize life.

Anonymous said...

I do this with driving routes, things like left vs. right turns, required U-turns, road conditions (pot holes, road construction), speed limit, the side of the street my destination is on, if I have a second destination, the location of the sun (for shade or "sun in eyes" purposes), common cop locations, schools (avoided during school start or end times), ease of driving (lots of straight vs. curvy or multiple turns) and probably a dozen other factors I'm not thinking of right now.

So, no, plotting your walking path in an informed manner does not surprise me.

Bill the Lizard said...

Adam,
Euclid showed us that the shortest distance between two points is a straight line. You don't walk down the square of the hypotenuse, you walk down the hypotenuse. It's shorter than the sum of the two sides.

Rich said...

The problem with being an optimizer is that human interaction and human social norms are so inefficient that you tend to optimize out of them. And thus, real programmers end up avoiding human contact in favor of more efficient means to whatever end...

Anonymous said...

Living in a place not grid based makes this fun + the roads are smaller, so crossing them diagonally is possible too.

But yes, I also weight for boredom/novelty as well.

Anonymous said...

@Adam Griffiths,

Come on, man. Imagine a right triangle. Are you honestly claiming that the hypotenuse is the same length as the sum of the other two sides?

Anonymous said...

Everybody optimizes things like this. Most of them do it by experience and rule of thumb. Programmers know how to do a better job of it, that's all.

Anonymous said...

Anonymous 1:13 AM: Which profiler did you use, when you discovered that "programmers know how to do a better job of it"?

Anonymous said...

@Adam Griffiths,

Is your company hiring? I'm sure there's an opening for a debugger. The hypotenuse is obviously shorter than the other two sides, otherwise you'd have a square!

Anonymous said...

Even dogs can also solve optimization problems. Just google 'Do dogs know calculus?' and you'll find a PDF detailing how dogs run+swim a path with the shortest time when retrieving a ball from the the water.

Hale said...

For someone supposedly hell-bent on optimization, you sure are wordy. I do the same thing, though, without ever thinking about it, and I'm also a developer/programmer/designer, but I've met enough programmers without this ability to firmly believe that the mindset comes first.

P.S. You have a misspelling in your Spy Game quote: "what their wearing" -> "what they're wearing."

Imagist said...

I do think that programmers optimize more than most, but in the case of walking distances, I think nearly any intelligent person would optimize. It's not just an inherent penchant for solving problems that would cause one to optimize a walking route. Walking takes time; time in which it is difficult or impossible to do many mental activities. Reading, homework, gaming, and many other things are nearly impossible to do while walking (I say "nearly" because I have done all of the mentioned activities while walking, at great risk to my own health). Anyone with an active mind would quickly get bored with all of the time spent walking and not using one's brain, so the brain finds things to do in order to combat boredom.

eslav said...

they're

Anonymous said...

not sure that this is simply a programmer thing either. as a mathematics major/geek, i find myself doing this same thing often. i was on a hike yesterday, and found myself thinking of which path to take along the trail that minimized unnecessary energy expenditure. or when i'm at work at the back room at target, i try to prioritize my tasks based on me not wasting time walking to the farthest location and back, but rather on me walking to the nearest location, then next nearest, etc, until i reach the furthest location and task last. i'd argue that programming did not bring this about (i can barely make a class function in C++) but rather that this is a type of mindset that particularly lends itself to math and computer science learning

Anonymous said...

I'm in a very similar boat: lego as a child, started programming when I was 9, started studying CompSci in University when I was 15. Now I own an IT consulting business. I *love* efficiency.

I'm constantly optimizing things like this. Not just routes, but everything. I don't think I have OCD because I'm far too messy, but even the messiness has a reason - it is far more efficient to clean once in a while than to clean 15 seconds at a time. :)

Anonymous said...

Micro-optimizations in walking are just as bad as in programming. The end goal is only to get there; getting there as fast as possible is secondary (and with walking, it's not even necessarily a goal at all, as there may be other aesthetic considerations - like, where do you like walking?) I like to optimize as much as any programmer, but in most cases (including programming!) my time is far better spent on other parts of the problem.

Anonymous said...

@Adam Griffiths,

I like how you involve Pythagoras' theorem in your argument against, well, Pythagoras' theorem.

Anonymous said...

Programmers do do this.

It's not just us, though.

I'm a computer scientist by training, and I do this sort of thing all the time.

My dad is a medical doctor, and he does these sorts of optimizations instinctively, too.

My younger sister is a graphic designer, and she's a master at "life optimization". Less analytical about it, but an amazing sixth sense for seeing ways to improve processes.

So yeah, programmers do this, but we're far from the only ones. Nothing particularly special about it, imo.

Harold Fowler said...

LOL< pretty good stuff dude!

RT
www.anon-tools.tk

Anonymous said...

im so smart i actually use my brain to choose between variable options with a highly complex set of arguments. It must be because im a programmer normal ppl dont have a brain i think.. Sometimes when i eat stuff i think like is it better to eat the potatoe or the potatoe chip if i want to loose weight and get laid by that hot girl i like..

im a programmer btw, but for some reason i dont think optimizing life is in anyway reserved for programmers. True you might be more aware of it than other people but that doesnt really exclude them from having a brain.

Bassicly this lol post is saying that only programmers have brains rofl.

Anonymous said...

Good article. One of the "system programmers" at my prior job, was not a fan of using his directionals when driving. Driving is a system, and turn signals are really important to the system, but not to the selfish individual who doesn't care about the system. I continually wondering if people are just ignorant of how a system works, or whether they are really selfish jerks.

Anonymous said...

Adam Griffiths, I know that you have been reamed by mean spirited posters about your comment that the diagonal route is not shorter, but it is. Given a block of size 1, walking along the two sides gives you a total length of 2. Walking across the diagonal gives you a length of the square root of 2, roughly 1.4. You save .6 blocks by crossing the diagonal.

Anonymous said...

I'm a programmer and I don't think that those people who are not programmers do this any less they are just less aware of it or at least less aware of the processes and calculation taking place in their mind. if this means anything it means that you could probably document your reasoning and logical behind your chosen path. The question is can you develop a system that will get you the most efficient path each time given all the variables.

Anonymous said...

I like to implement OSPF around the house and BGP when out and about ;-)

Anonymous said...

Everyone does this unconciously. The fact that he has a mathamatical/programming background allows him to devulge further into the details.

Not everyone who is a programmer does this. Most could care less. If you look around, you'll find people have streamlined specific parts of there life and work. The 'How sad..." comment is just another teenager being calcous with another persons interest.

Aerospace engineers are cheifly concerned with safety and optimization. We fall into the same sterotype of optimizing what other people consider inane. It's fun and it makes us better at our jobs.

Earl Grey said...

I am not a programmer and have no interest in programming.
I am just a non nerd that makes a living from computers.

I would just do the walk because i would be too busy thinking about getting laid or the day before when i got laid rather than the best way to program some nerdy stuff.

Anonymous said...

I too come from a similar background (progamming from a young age) and I was wondering the same thing and get exactly what your saying, and since I can relate I guess

@other people: The main point is that it is not only a "programmer" who optimizes life, but rather the depth, consciousness, and relativly automatic nature of the process that seemes to by a directly application of the same logic we use when we are programming.

I do this all the time for paths, but you can apply this to people to.

For example: what possible benefits can becomming associated with this person bring me, what will it do to my status, their status etc, how will it affect the realtionships of either party respectively and/or potential for future relationships for others, etc.. but usually I ignore such thoughts and act irrespective of the previous thought exercise.

Anonymous said...

ur doing it wrong! just move close to the office and move on to other problems. like fixing this comment box.

Anonymous said...

I'd hazard it's a predilection but not limited to programmers. As a child I was a big fan of the book cheaper by the dozen. I always remember the father determining that it was faster buttoning your shirt from the bottom up.

One reason I got into computers because I found most of the people I had as chess partners in NYC were computer programmers. I'll never forget the guy earning US$50.00/hr (early 80s) and how he really couldn't play chess that well.

Once I started working with computers I found a very enjoyable hobby that I'd get paid for doing.

I too automatically optimize everything as habit. In addition I have a preference for precision coupled with little patience for people who apparently think otherwise.

bertrandom said...

Douglas Coupland briefly mentions this in his book Microserfs, about the Microsoft campus and the shortest path a programmer can take.

Anonymous said...

When your friend commented: 'How...sad', he wasn't correct. But I know what he meant. The problem is that you see the world in terms of exactly one variable: Efficiency. Instead, you could try for a whole panoply of variables: Beauty, Novelty, Human Encounters, any of the infinite number of human values that we all (even programmers) hold.

Or you could try doing a bit of what social scientists call 'satisficing', 'Satisficing (a portmanteau of "satisfy" and "suffice") is a decision-making strategy which attempts to meet criteria for adequacy, rather than to identify an optimal solution. A satisficing strategy may often be (near) optimal if the costs of the decision-making process itself, such as the cost of obtaining complete information, are considered in the outcome calculus.'

But your story implied that once you went through you optimization procedure, you left the problem as completely solved. A real programmer would have examined it again and again, solving it differently each time. Your friend thought it was sad that you used your brain in only one way, and could not see the beauty, or possibility of human encounter, in your walking trip. I think you are just a lousy programmer. How....sad.

Anonymous said...

I think the old school Jesuits like Isaac Jorges optimized life

Anonymous said...

Adam... it's the triangle inequality you need - the length of any side of any triangle (excluding the limiting case where the triangle is squashed down into a straight line) is shorter than the sum of the lengths of the other two sides.
the longer side.

VictusFate said...

Over time, I've moved away from optimizing code to tackling social entrepreneurship(matching work with passion is one area that needs help). There are huge bottlenecks all around us, and the most profound impact some of us can have is outside of .cpp files as entrepreneurs, and idea engines.

Anonymous said...

optimizing: agreed, that its not exclusive to programmers/compsci

life optimizations: do you time and record everything you do to calculate the optimizations/efficiency? if you do, at what granularity/what level of obsessiveness*?

i myself, logging everything i do in life unfortunately* is central to my work/life habit

Andreas said...

I bike to work, and have done so in four different cities in this decade. I always try to optimize as I ride, not only which roads/bike paths to use, which includes a significant consideration of elevation change (which can be fun!), but also when to use them. "Oh, if I leave work now I'd only save 3 minutes compared to if I leave 5 minutes from now, so I'll work the extra 5 minutes and arrive 2 minutes later, due to the lift-bridge..."

Anonymous said...

Yea but dogs don't sovle the problem with calculus. They have pavlovian-learned that if you walk or swim straight towards something you will get there in the shorted time (which is true on the surface of the earth over short distances, but not true, say, if you are a satellite slingshotting around a planetary body where GR becomes significant).

Physicists optimise this stuff too :)

Also, when optimising a bike journey, I have found that it's normally much quicker to just get the car-route and follow that (talking about optimising a journey in London here, which (like most major cities in europe) is distinctly non-grid-like), since you get wide fast-moving roads. This is way quicker than remembering hundreds of little twists and turns, and frequently having to get off and push through bollards, simply in order to go the smallest distance (which isn't always the fastest way, and he says :) )

Gregg Obst said...

As a software developer, I can relate to this. I even optimize my routes through the cubicle farm to the bathrooms and the various conference rooms at work. It drives less like-minded folks crazy.

Anonymous said...

I understand what you're saying, but look at where programmers end up: in front of a computer deep inside a cubicle farm. Is that really optimizing for "life"?

Anonymous said...

I have solved your walk home problem... get a bike. Then it matters a lot less, since you don't waste as much time walking, you exercise more, and chicks love guys on bikes.

Anonymous said...

@Anonymous June 24, 2009 11:00AM

I am a Computer Scientist and I ride a bicycle everywhere. I find that I optimise my route even more than walking as I am concerned with maintaining altitude (reducing hills), reducing exposure to traffic, reducing red lights and looking for the shortest distance. My specific area of expertise is multiple objective optimisation and I find that this is a natural fit to this daily activity as I am constantly changing my routes depending on the conditions of the day (rainy, more or less traffic, dark or light).

It is a natrual consequence of the work that I do that I obsess over finding the most optimal route, and boy does it shit my wife when I suddenly peel off into a side street because I've suddenly calculated it to be closer to optimal!

Anonymous said...

Hi, this is the first time I see this blog, but would like to comment:
I think in this way you might lose or not see alot of what life has.
Do you know the story of the little prince?
there is a passage there where he can buy thirst relieving pills, so he asks what for?
and the merchant tells him that it would save him time. he then answers that if he had spare time, he'd rather use it for a nice walk to the well and a drink when he gets there.
What I mean is that when you walk you should take your time, notice the world, examine things and people, make interactions, or just smile to people. In my opinion it's more important than to have more time. it's also a kind of relaxing activity, probably contributes to your confidence and self assurance too. After all it's your life, for you, you don't get a grade for efficiency, or linearity. It's not a race...
well, just my point of view.
see you

Anonymous said...

Spending your life (8-16 hours a day depending on your job) breaking situations and requirements into flows, objects, and behaviors then executing them WILL bleed into your life if you are doing it right. There's nothing wrong with you, most of us do the same thing (or at least I do). I think it makes us better members of society. I am sure a number of other professions provide the same base mindset.

Protip: Never talk to your girlfriend about it unless she is the same way. Being able to provide a flowchart of how a difficult conversation is likely to go evidently makes you an "over-analytical asshole". Drawing it out before the conversation and showing it to her after to prove a point makes it worse.

Giorgio said...

This sounds like a work for Djikstra..

Anonymous said...

Its OK to optimize, but NEVER forget good old commnon sense -- as in program
testing for example.

If your beautiful coded program is fully optimized with 'state-of-the-art'
graphics layout, it is still a useless (or dangerous) program if only one bug is
not resolved.

In the old days, a simple method was used to test for bugs sometimes:

Hit the keyboard randomly, and press ENTER.

(Many programs aborted/crashed/rebooted that way)

And what comes to mind, is Flight 447 Air France, which as I understand it so
far, was brought down by software which could not process incorrect readings by
faulty hardware.

alexwy said...

Interesting post

@Anon above me

That is interesting about the aircraft software unable to interpret faulty readings. How would such a program recover from fauly input from faulty hardware (which I imagine) would be automated? Sound the horn?

Art Vandalay said...

I'm right there with you. In my case, I was optimizing the distribution of music files among shallow directories on my Flash storage-based music player. I described it as "algorithms everywhere": http://ripplingbrainwaves.blogspot.com/2009/01/algorithms-everywhere.html

andren.lars said...

I do the exact same thing when riding my bike home from work. I also analyze if a parallell street would save me time because of less traffic etc, naturally including the extra time it takes to go the extra distance away from the closest street. Glad to hear Im not alone doing so.

Post a Comment