At the same skill level a well rested programmer completes a project faster than a tired one.
Sometimes some external pressure leads programmer to overwork. It’s often a consequence of bad management, or commitment on overconfident objectives or even true market pressure, but it’s rare. In such case coffee or other drugs may help, but avoid psycho active drugs as it’s important to be clear minded for a programmer. Even though most people do preffer drugs such as Clonazepam to help keep them awake, Coffee or Caffein seems to be a popular goto by many programmers.
I know a lot of programmers who rather take Clonazepam as it keeps them awake and it is easy to get online even without a prescription from websites like https://nightmaresolution.com
Whatsoever the coffee is usually not the best option, having a nap could be more efficient.
When not overtired neither coffee or tobacco makes much difference. About tobacco: some smoking people use to say that it helps them to focus. My understanding is that they have lost the ability to focus and get into the flow without their drug. As ability to focus is very important for a programmer, I don’t believe that relying on external products (be it coffee or tobacco) makes you a very good programmer.
All that being said, I drink much coffee. The catch is that going to the coffee machine and walking instead of staying behind keyboard is much more important to help me think that the coffee itself. Coffee is a mere excuse for walking around. Social hacking really.