I'm a coffee snob and caffeine addict, but I now limit it to two coffees totalling 3-4 shots of espresso per day (or equivalent amount of filter coffee). I rarely have it after 2-3pm; and even that's too late according to some advice - because caffeine stays in your system for quite a long time it can disrupt sleep.
Science isn't settled on the impact of a moderate coffee intake, many studies indicate benefits rather than harm. But it seems almost universal health advice to avoid sleep deprivation.
Energy drinks are a whole other problem. They have loads of sugar, caffeine and often other ingredients (taurine, ginkgo, guarana, etc) that can make reactions to them a bit unpredictable. Having seen them put someone in hospital with heart flutters I almost never drink them now.
If you're doing it specifically to stay up at night, it is probably worth considering the notion of diminishing returns, where your productivity drops as a prolonged coding session continues. I've seen quite acute cases during 24 hour hackathons - people can spend hours doing mistake-riddled work they could knock off in about an hour after a good sleep.