If I <i>need</i> a stimulant to keep me awake, I go to sleep. <p>Pulling an all-nighter when I'm already in sleep debt only produces code that sucks. The next day, I'm too tired to be functional and I've got a bunch of code that needs to be thrown out and rewritten. Sleep is a better use of time.
Definitely coffee. I don't drink much of it so I'm not that resistant to caffeine. If you're a regular coffee drinker than those caffeinated candies or energy drinks might be a better choice.
There seems to be stereotype that high performance geeks rely on caffeine drinks to stay alive. In reality only regular sleep cycles and adequate exercises can keep you at your peak performance over the long term. Meditations can help you to control your focus and weed out distractions, so you waste less of your time when the environment doesn't fit you.<p>If you really need to pull a few all-nighters, consider taking something on a measurable dosage, so when you decide to rehabilitate, you can adjust your intake on a decay curve.
<a href="http://en.wikipedia.org/wiki/Kratom">http://en.wikipedia.org/wiki/Kratom</a><p>Kratom is a great stimulant. If you take too much, you don't get jittery, you just get really happy.