How long (in hours) have you coded in a single sitting (one session)?
Before Stackoverflow - about 18 hours. After stackoverflow - about 18 minutes.
3hrs. I try to keep it at a 2hr max, spend a few minutes doing something else, then get back to it. I found i was killing my posture and feel lots better after getting in the habit of getting up.
I found that I can recoup better if i run into a problem, ie focus my thoughts and think about a problem differently, if i get away from the monitor.
Edit: 6 hours max. 5 hours is pushing it for me, anything more and i'm just "pretending". After 5 hrs i need some RockBand or hit the gym for an hour. This is the only way i've pulled off 60+ hr work weeks, to take breaks.
Note I have these rules in place for my own sanity after a horrible experience with last minute coding for a deliverable. Nearly the entire weekend was coding except to get food and go to the bathroom. The next work week i was useless. Not to mention the code was buggy, like an ant farm.
No, I am NOT making this up... in college I spent a 37 hour stretch of non-stop programming, with the exception of using the bathroom and stopping to order a pizza. Actually, at one point of that, I spent over 6 hours of continuous coding without ever compiling... leading to probably my record for most compiler errors :P I thought I wasn't really tired after all of that until I went to the class the project was for, submitted my code, walked out of the room and just about walked into a wall... at which point I went home and slept for about 16 hours :)
I'm making the assumpion by single sitting, you mean uninterrupted run of coding with the office door closed, staying in your chair and not taking any phone calls or answering emails, etc. I'm also assuming no breaks for web surfing - except perhaps to lookup something relevant to the topic at hand.
In any case, for me that was just over nine hours coding up a FLASH based file system (with an IO cache) for an embedded system based on VxWorks RTOS. I had worked out the design the night before and wrote about 2500 lines of code (with comment lines) in the nine hours - to be fair some RTOS device model interface code was leveraged from another file system I had implemented previously. Anyway, it was noteworthy to me at the time because the source all compiled on the first try and also passed all the test vectors I carried over from the other file system test code. Over the course of a few days of validation, one subtle bug was eventually found in the wear leveling algorithm, but it worked well with no additional bugs found as far as I know after that.
Last week I put in from 8AM to 2AM on a very tight deadline with a 2 hour break for kids & supper. If I get in a "zone", hours will slip buy. If I find I'm stuck on something, though, I will usually stop and take a break to refocus.
When I was younger and had more energy/less distractions I pulled a few all-nighters to get the projects in on time. I hope I don't see any of those any time soon.
I have a similar experience to Adam doing 36 hours straight other then bathroom and going to the vending machine for some food. The reason for this was I had back-to-back assignments due.
Towards the end of it I believe productivity was getting very low. But like Adam I didn't think I was that tired after all that considering how long been going at it. When I finally hit the couch I didn't get back up for 14 hours.
Back in university I had an assignment where we were asked to write whatever was needed to break five blocks of ciphertext. I really got into it and wrote some of the most amazing C I've ever come up with..but it still took about 40hours broken only by bathroom and food breaks...
The time flew by and the assignment was ready about two weeks early :)
For our university's final year project, five of us began the coding just a few days before the deadline. As a team, we split up into small sets and cracked through the separate parts needed - it was a 3d game engine - with our head coder jumping from sound effect code, to vertex generation, to memory management routines.
It was a very long stretch, I don't think any of us really remembers the number of straight hours spent coding, but with the help of Pro Plus, Rocket Fuel coffee and several pints of Red Bull we managed to not only get the project done, but actually get pretty good grades on top. There were some shifts spent asleep, but there was always one of us staring at the screen at any one time.
Collectively, we rocked!
I did a 36 hour stretch many years ago when my boss promised a General a demo on Monday of functionality that hadn't been written yet.
Once I sat at my desk for 8 hours and coded for zero. A new record!
On a "surge" before a trade show some years ago:
120 hours overtime in one week. that is 160 work hours. The overtime was, of course unpaid.
The week before was 105 hours overtime.
Sleeping on the floor of an unused office.
Don't do this. Some of the damage to the code took years to undo.
IIRC the code output was something like 1500 lines per day.
My friend and I spit out a P2P application based on the Gnuttella protocol in one 24 hour sitting. It was sophomore year of college and we started the night before it was due. ;)
23 hrs pair programming. switching the driver 3 times and normal meal breaks
10h working + 2h breaks 20h a week compressed to two days a week. Did that half a year.
On a 'business trip to hell' (also known as Albion, MI) I had to pull three 24+ hour shifts in 5 days plus regular shifts because muy boss gave the customer "carte blanche" to redesign the system we were installing and I had to re-write almost all the underlying code from floating-point to integer arithmetic (this was in 1986 so it wasn't as easy as it would be today) and re-test systems that had 8 hour batch cycles. I spent 9 days at that godforsaken place when I was only supposed to be there for 2 1/2 (and only had two suits).