Sure, but the ability to stay focused enough to write high-quality code for hours on end is a talent in and of itself. I know many programmers who I think I am equal to if we both sit down fully rested and program for a few hours, but they can keep churning out good stuff for a long time after I'm tired and checking Hacker News because I lost focus.
ADHD/ADD seems to be common in our industry, a side effect being 'hyperfocus' or what we (as an industry) refer to as 'flow'.
For me, amphetamines actually allow me to productively switch my focus. 8+ hours of hyperfocus, while making me seem like a ninja unicorn rockstar, is just not sustainable and burnout is a real problem.