Some of the best code I've written has also been in an exhausted/ not-fully-awake state
Some of the best code I've written has also been in an exhausted/ not-fully-awake state
The coding proper can be done in a less vigilant state: it is like laying bricks or folding napkins. The hands know what they are doing. (Exaggerating here, but not too much. God knows I have coded tired or drunk or stoned, and not even my worst work.)
I so wish I could code stoned. I've never been able to in any meaningful way. I don't code inebriated anymore, but in my twenties it was preferred. These days I think my brain basically responds to inebriation of any sort as "why are you still working while I'm trying to enjoy myself?".
It was something I had been considering, analyzing, debating and discarding as impossible for several weeks prior to that. Then when it came down to it, not only was I able to implement it, but it worked perfectly for more than 6 years before anyone was able to improve on that design.
I attribute the success to two things: (a) the fact that I had done a lot of analytical work beforehand; (b) the inhibition-lessening effect of alcohol that allowed me to enter the zone and implement the solution without worrying about complexity or other external factors.
Once the core idea worked - and worked it did! - all that was left was to revisit it the next day, sober this time, and fix the remaining issues, documentation and tests.