Programming is Like a Dream
Have you ever noticed that computer programmers are very easy to startle? Walk up behind an accountant or a web designer sketching out banner ads, and nine times out of ten they’ll know you’re coming from a mile away. But computer programmers aren’t like that. You can stand right behind a programmer for ten minutes and quite often they will not even know you are there–especially when they are working on a difficult section. The larger the system, the deeper the trance.
I just read two fantastic essays describing programming as a dream-like state. I’d never thought of it this way before, but I’d have to say that’s the most dead-on accurate description I’ve ever heard.
Now, imagine you were in deep sleep, dreaming away about apples at 3am, and I came bashing into your room and said “Sorry, but we need you to dream about bananas now.” Do you think you could go straight back to sleep in a few seconds, dream about bananas for a bit, and then jump back to your original dream about apples? No, of course not, but this is what managers expect when they throw new tasks at us while we’re busy coding the first one. When this happens we’ve lost the hours we’ve spent on the first dream, we’re completely lost for half an hour, and then we eventually manage to get into the new dream.
This is very true. It takes a little while to “shift gears”. For small programs, it’s not so bad, because you can conceptualize the whole thing in a few minutes or seconds. For large systems it takes longer to get yourself back into the right frame of mind. You have to think about all the things you were thinking about when you put it down last, and this is often a lot harder than it sounds. There’s a small time penalty that’s paid every time a programmer sits down to work, but it’s only paid once per session. This is why a lot of programmers prefer to work in one long stretch instead of several short ones. In six 30 minute stretches, zero code will get written–zero good code, anyway–because you spend the entire time just getting started. In one three hour stretch, however, you might just compose a masterpiece.
I can sit down and start coding right away, but I don’t really “hit my groove” for an hour or two. Sometimes I try to accelerate that by leaving myself a thread the day before. I’ll intentionally not finish a block of code I was working on, but I’ll leave myself copious notes on how to write it so that when I sit down in the morning I can start right away on that block. In the morning I don’t really have to think about the block too much because the answer is right there, but by-and-by as I code it up the thoughts start rushing back to me. By the time I’ve finished writing the block, my head is where it needs to be and I can pick it up from there. Sometimes if the code is very complex I just keep thinking about the code until morning. Most programmers can and will do this, too. Some perhaps can’t hold onto the code for days or weeks, but virtually all can for a few minutes or even a couple of hours.
I know it sounds strange, but think of it this way: Have you ever had a dream that lingered? You know, when you have a nightmare or other intense dream, and it keeps coming back to you while your doing other things throughout the day? Your mind is still dreaming the dream even though you are awake, and you can feel it back there drifting around. Keeping code in your head feels very much the same way.
There’s a right and a wrong way to interrupt a programmer. The best answer is “don’t”. But if you must… If you think about programming like dreaming, you’ll realize that programmers remember more if you interrupt them gently than if you barrage them. If someone wakes you out of bed and starts shouting a long list of things at you to remember, you’ll almost certainly forget what you were dreaming. However, if someone shakes you gently and gives you a few seconds to open your eyes and look around before they start talking, it’s a lot easier to remember the dream for later. The same works for programmers. If you just walk into their office and start talking, one of two things will happen: they’ll completely forget what they were coding, or they won’t really be paying attention to you. However, if you quietly walk up to them and let them know you are there but say nothing until they are ready, the programmer can come to the end of the thought they are on. Once they’ve finished their thought, it will be easier for them to pick up next time and still pay attention to what you have to say.
Let’s take a maze for example. There is a task for the programmer to come up with an algorithm of finding the way out of the maze. When a programmer is working on this task he isn’t just a God’s Finger showing the directions to a little girl lost in a great maze. He isn’t that girl or the walls of a labyrinth either. He is actually all of that in a same time. In order to solve the task he must BECOME the labyrinth, the walls, the lost little girl and whatever else may just came along with it. It is not a figure of the speech – the programmer is literally SLEEPING and DREAMING that all in his mind.
My brother contends that it is this same phenomena that makes programmers so bad at estimates. The problem is, as he says, that the programmer already knows everything that needs to be written. When you have it all in your mind, it seems like it should be easy to write it all down. But it’s not. The physical act of writing the code takes a long time. But more importantly, your mind never thinks about all the “meaningless” details. It knows how to code them so well it doesn’t even need consider their existence anymore. Unfortunately, the computer still needs them. It can’t infer. All those loose ends, niggling details and corner cases end up eating a great deal of time… sometimes more than the rest of the program.
How does programming feel to you? What is your experience like?
March 18th, 2009 at 12:44 pm
Good insight about estimating. People always expect an exact estimate from me and the best I can do is a range, say 1-3 weeks or something similar. Sadly I don’t get into the flow as much as I used to, far too many new responsibilities. I may as well be a manager, but I’m expected to code as well, and the two just don’t mix.
I miss the days of working on new and novel ideas, but when you have to make money you drift towards the lucrative area of our industry: dull, complicated business software no one wants to write.
March 18th, 2009 at 1:59 pm
Yeah, I manage too, and I agree the two don’t mix.
The best approach I’ve found is to try and block off parts of the day for each, and just shut my door or put on my headphones when I really need to jam. (Sometimes I don’t even turn any music on! I just listen to white noise or nothing at all.) Thankfully everyone here is pretty good about not bugging programmers with headphones on unless they really need to.
March 19th, 2009 at 3:14 am
Excellent article. Accurate and useful. Thanks
March 19th, 2009 at 5:10 am
[…] Programming is like a dream […]
March 25th, 2009 at 3:43 pm
I remember in college that I used to write out the code on paper before I went over and typed it into the computer over at the computer lab. If I recall correctly, it worked perfectly every time. Mind you, these weren’t hugely involved projects. But as a comparison, for the times I just deep-sleeped it, typed ‘er out in the trance state, my programs were fraught with errors. For me, at least, putting pencil to paper interrupted my world-class dream state where I could plunge into unwieldly complexities that were only tangential to the solution.
As a self-anointed world class dreamer, I’ve got to discipline myself, or I’m fraternized.
November 2nd, 2009 at 4:31 pm
I have been programming for years with the sound of breaking beach waves through headphones. Put them on, start the sound, and off you dream 😉 Having the complexity of a large project or complex challenge in your head, with relaxing sounds in your ears is a cool creative kick. Nice article.
November 2nd, 2009 at 5:41 pm
This is dead accurate. I call it a “programming fugue”. My family’s had to learn that you just don’t interrupt Dad when he’s programming. Over time, I’ve found that, if the person interrupting just stands there, I’m able to sort of “partition” my awareness so that most of me’s programming, but a little part’s aware that somebody wants something, and I can be very intentional about getting to the point where stopping isn’t too costly.
November 3rd, 2009 at 1:07 am
Excellent article! I love it!
November 3rd, 2009 at 2:54 am
It’s called “flow” and it’s hardly limited to programming. Any activity requiring intense concentration and the fluid use of experience and skill will generate it. You think a surgeon wouldn’t be easy to startle during an operation?
November 3rd, 2009 at 2:18 pm
I totally agree!!
If I am writing some code and I get interrupted, I completely lose my place, my “trance” never really comes back, and everything I had in my brain is like, gone.
and people wonder why I get so irritable when I am interrupted!
November 3rd, 2009 at 6:17 pm
[…] http://www.independentdeveloper.com/archive/2009/03/17/programming-is-like-a-dream […]
November 3rd, 2009 at 9:05 pm
Love the article. I am a senior in high school, and I actually noticed this today when working on a huge lab. I know that this is very little compared to what you guys do, but I still feel the same way. Anyways, I am very passionate about computer science (competitions, comp sci club and stuff), and am seriously considering majoring in it. Can anyone here tell me what a career in comp sci is like? From what you guys have said, it sounds like my ideal job.
November 4th, 2009 at 12:29 pm
Psychologists call it “flow”, everyone else calls it “the zone”. Especially gamers. It’s the exact same thing, though
November 5th, 2009 at 3:38 am
This is so true… I think I’ll print a few copies of this and throw around in the office… 🙂
November 5th, 2009 at 5:02 am
Wow! What a great read, that’s exactly how I feel when I program.
Unfortunately where I work most people are aware they shouldn’t interrupt, but do it anyway and think it’ll be okay as long as they precede their interruption with a “…sorry, but … ” or a “…I know I should put this on the helpdesk, but….”
I should send this round to them all! 🙂
November 6th, 2009 at 4:23 am
I think programming is more like a nightmare, you never have time for yourself, you spend a lot of time on things you tend to give for granted, weekends gone, late night working and the worst part is having to try to stay up to date on technologies and stuff. Every day I regret more not working on something else than programming, worst part is I used to love it
November 6th, 2009 at 9:34 pm
Rbuenon: sounds like you need a new job. I work from 8-4 five days a week. No overtime, no weekends – ever. And it’s not really too hard to stay up to date with the latest tech… maybe 15-20 minutes every day over coffee.
November 10th, 2009 at 4:13 pm
Personally, I always tell my kids that programming is an invaluable skill, but to avoid taking it as a career. Aside from the crazy demands most employers make, if you try to forge your own path there are always the fear of someone showing up on your door with a patent on the idea of using a program to operate a computer!
November 11th, 2009 at 10:57 pm
Nice and true article, I like the dream metaphor. A person that has never programmed in his/her life has now idea how complex and demanding it in general really is. The article brings a good insight on this.
November 13th, 2009 at 7:44 pm
That is spot-on. I never noticed that about myself before.
November 16th, 2009 at 2:28 pm
Truly a work of art – you’ve nailed it right on the head. Thank you for this!
November 17th, 2009 at 10:18 pm
Very useful info. My hubby is a programmer and I can be in the same room with him working on code and scare 5 years of life out of him by just asking a question. It doesn’t occur to me that the podcast and music he’s listening to is any different than the sound of my voice, but when I say something… it’s like a jolt directly into his brain stem. I have to send him an instant message and say, “hey, I need to ask you something when you have a second.” Mind you, I’m only 4 feet away at the desk across from him. It seems ludacris to me, but hey, if it works, what the heck.
November 20th, 2009 at 3:36 am
It’s very true. I used to be such a fun loving, easy going guy before I took up a career in software engineering. I work in a busy radio station and have constant noise around me, but after many years I’ve developed coping mechanisms that help keep the gremlins at bay.
1. Some good music.
2. Some good design work and a clear road map for the project/task.
3. Leaving a bread crumb tail. i.e. code comments, good project management tools, etc
4. Evil facial expressions and growling sounds.
5. If all else fails, threats of physical harm …..
On topic here’s a little video I posted a few days ago.
http://www.youtube.com/watch?v=4ddkTYpCcc0
November 22nd, 2009 at 12:17 pm
never saw programming this way… but this article is so true!
great work!
November 25th, 2009 at 4:39 am
I would prefer “trance” over “dream”, but it comes down to the same effect. This is the main reason I sometimes get in a fight with my girlfriend. She never learns not to talk to me when I’m coding, because I won’t hear her any way…
November 27th, 2009 at 9:00 am
After a while people close to you learn to deal with it, my mom would come and put food on my desk … take the food the next morning untouched and she would place another plate and so on. I talked to her about this she said that her soul hurt because i wouldn’t eat but she knew it was better not to interrupt me. After a while i learned to eat not thinking about it because i started getting sick. People at work now are not used to this and it is very distracting. It’s also very hard to explain to them what you mean by “do not disturb… ever” i’ll show them this article next time.
November 27th, 2009 at 1:47 pm
Love the description – so spot on.
I would add however that sometimes when a problem seems to difficult to resolve or if you have been working on a problem so much that you are too involved in it going round in circles trying to resolve it – you sometimes can not see the wood for the trees, and sleeping on it overnight will add a sense of clarity to the whole problem and either a new idea comes to mind as a better way to code it, or you wonder how and why you were going about things so convoluted when it was really quite easy. I find now that if a problem seems to trouble me, I will put it to bed for the rest of the day, but still have it in the back of my mind and sleep on it – the following day 9 times out of 10, it will be resolved in a better more effecient method that i have come up with. JB
November 30th, 2009 at 7:33 am
[…] further reading: http://www.independentdeveloper.com/archive/2009/03/17/programming-is-like-a-dream http://alexthunder.livejournal.com/309815.html […]
December 2nd, 2009 at 1:51 pm
on the point. thanks
December 4th, 2009 at 5:40 am
Good article. I am struggling with the same issues. Interference is not good for me. I getting out of a state of flow or I am not getting in to it. Interference can be so much. Unfortunately I do not have my own office. We are 5-6 persons sitting in the same small room all the time. Two colleagues conversation, or one colleague talking to me, mails poping up, instant messages, my phone, what ever will take me out of my state of flow.
Neal Ford the author of The Productive Programmer handles this in his book and talks about this. I have the book and have attended to his talk. He recommend using headphones with or without music, what suites you best. This will probably tell the human interferers that you are occupied. Or pretend you are on the phone 🙂 In the chapter Focus he recommends turning off all things that distracts you, balloon tips, growl, instant messenger, mail, and such. Also create quiet time. I.e. 9-11 AM, 3-5 PM.
For me all context switching between tasks and systems/projects with an manager or other consecuenses forcing me to re prioritate is something of the worst.
Anyway good luck with finding the state of flow (and keeping it for some time)
December 4th, 2009 at 2:56 pm
Great post! The right music gets me in “the flow” when my workday starts. Stopping at the end of the workday is a lot harder for me, since the feeling of being productive (like a trance) is so good. The part about writing notes under a part that isn’t finished is a great idea!
January 26th, 2010 at 11:24 am
thank you very much for this post… it is spot on!
April 7th, 2010 at 4:47 am
[…] enligt den här artikeln Filed under Datanörd var uri = […]
May 23rd, 2010 at 8:54 am
I’ve never really thought about programming in this way, but I think you’re spot on with regards to work flow. If I keep getting interrupted when I’m working on something complex productivity takes a big hit, but if I can keep working on the task for long periods at a time productivity improves. The downside is I then often lose track of time, but I guess you can’t have everything 🙂
May 29th, 2010 at 9:35 am
Until now I though I was abnormal. And was losing my mind.
The knowing the symptoms are common amongst other programmers bring GREAT RELIEF.
GREAT ARTICLE!!!
August 4th, 2010 at 7:14 pm
This is similar to meditation. You can sit and try to still your mind, but it’s only after 20 minutes that you really are even beginning to get focused. If you can keep at for an hour or two, you can go really deep. You can’t go really deep in 5 minutes – the mind takes time to focus. Same with programming an intricate project. Maybe that’s why so many of us get our best work done late at night when there are no distractions.
August 18th, 2010 at 1:53 pm
Hack mode… on. I find my best time to go into my programming trance usually hits around 10-11 PM, and continues on to around 3… after that, things start getting a little too fuzzy. Putting on some good ambient (Oddly enough, the Halo 2 Soundtrack Volume 2 works great for this) really helps me get focused.
October 12th, 2010 at 6:47 am
[…] came across this interesting article by the Independent Developer Blog. I woke up this morning like other mornings I’ve had when my mind is in “Programming […]
November 9th, 2010 at 10:45 am
I refer people to this ALL the time. So glad I came across this article! <3
November 13th, 2010 at 6:00 am
Interesting article! I too found this comparision very correct… My mom used to come behind me while i was programming all the time and i just used to say yes to each of her questions. 🙂
enjoy coding!
December 16th, 2010 at 8:01 am
[…] is Like a Dream – http://www.independentdeveloper.com/archive/2009/03/17/programming-is-like-a-dream […]
July 5th, 2011 at 12:08 am
[…] stumbled into Lisa’s post which talks about Programming as a Dream. I liked this article very much and the illustration given […]
January 5th, 2012 at 12:32 am
Hi, how are you? I hope you do well. I wanted to say that I like Independent Developer » Blog Archive » Programming is Like a Dream.
March 5th, 2012 at 10:55 pm
[…] So sometimes I have a really hard time coming up with something to post here on the SNQ blog… well OK I always have a hard time with it but sometimes it is really hard. This seems to be one of those times… So what I want to do is share with you something that I came across a while ago that I found very interesting and hopefully you will too. Hopefully it will also give you a little insight into the mind of a programmer: http://www.independentdeveloper.com/archive/2009/03/17/programming-is-like-a-dream […]
March 27th, 2012 at 2:07 am
Great article dude!
very very interesting point of view, will definitely experiment on this, thanks!
Scalino – NHA webmaster
April 21st, 2013 at 2:58 am
It’s called “flow” and it’s hardly limited to programming. Any activity requiring intense concentration and the fluid use of experience and skill will generate it. You think a surgeon wouldn’t be easy to startle during an operation?
April 21st, 2013 at 5:46 am
this’s exactly why I’m so struggling with estimating time for the projects. great insight! never thought about it that way.
April 21st, 2013 at 7:09 am
My wife is an artist and she is much the same.
April 21st, 2013 at 9:43 am
I like to think of it as a stack machine. If you gently let me know you need something I have a bit of time to finish my current operation and push my critical registers onto the stack before jumping to your subject (with hot-swapping obviously), but if you just interrupt me and start overwriting my registers I lose a bunch of work, not to mention being confused as to what’s going on in the first place.
Of course that analogy doesn’t work very well with non-programmers. In that case this article is excellent.
April 21st, 2013 at 9:44 am
I keep writing the same artificial intelligence (AI) program over and over, in [English] and in [German] and in [Russian]. It is so difficult to code the AI Minds in Forth or in JavaScript, that I need to enter one of the dream-like states described above. Generally I can only code AI in the middle of the night or the early pre-morning. If some morning work needs finishing up, then I might manage to work on it some more in the afternoon or evening.