I think stimulants and amphetamines definitely have an effect on programming. Maybe it affects quantity more than quality, but Paul Erdos, one of the most prolific mathematician ever, comes to mind:
His colleague Alfréd Rényi said, "a mathematician is a machine for turning
coffee into theorems", and Erdos drank copious quantities. After 1971 he also
took amphetamines, despite the concern of his friends, one of whom (Ron Graham)
bet him $500 that he could not stop taking the drug for a month. Erdos won the
bet, but complained that during his abstinence mathematics had been set back by
a month: "Before, when I looked at a piece of blank paper my mind was filled
with ideas. Now all I see is a blank piece of paper." After he won the bet, he
promptly resumed his amphetamine use.