views:

1813

answers:

30

Sometimes, I think that coffee does nothing more than help me to write bad code really fast. What are your experiences? Does a can of Coke or a cup of coffee actually improve your productivity when writing software?

Programming requires both logical and creative thinking, and both of these suffer when you are tired. I have a feeling that a couple of hours of sleep or a quick walk outside would do much more to energize the mind. What do you think?

+37  A: 

Not usually. I write bad code regardless of what drugs I'm on.

Alan
+1 for cute/funny -1 for OT
BCS
I wouldn't say OT. He's answering the question, isn't he ? :)
Kamil Kisiel
He is responding to the question, but I'm not sure it counts as an answer though.
BCS
It's subjective... it answers it for him.
Jason Coco
Is an offtopic answer to an offtopic question offtopic? I think not. +1 here =)
Artur Carvalho
i'm not sure. if anything is offtopic it's our discussing about his answer isn't it? lol
Johannes Schaub - litb
+1 for inciting meta-commentary
e.James
...and +A for the heck of it :)
e.James
+2  A: 

I'd say that whatever keeps you at your mental sweet spot is a good thing. If you need your coffee in the morning to get there, go for it. If you tend to drink so much that you get jittery, scale it back. Sometimes a little extra edge is good, but you're not going to be able to get that all the time.

Dana the Sane
+3  A: 

The only effect caffeine has on me is to give me insomnia and improve my attention span. I don't work faster/slower or better/worse because of it, I just work more.

BCS
+5  A: 

Personally I don't think working long hours or supplementing with anything helps me at all. As soon as I feel I'm no longer being productive, and I'm way out of my sweet spot, it's time to take a break. If I'm too tired to stay up, it's time to sleep. If I'm just tired of staring at the screen, it's time to go out and take a walk, go for a jog, or relax some other way.

Kamil Kisiel
That's awesome. I wish I was aware of my sweet spot to know to stop. I usually keep going and then just end up not even billing the time I spend "circling the airport."
Yar
+13  A: 

Whatever benefits you receive from the stimulant properties of caffeine must be weighed against the loss in productivity caused by its attendant increase in frequency of urination.

Caffeine blocks receptors for antidiuretic hormone, inhibiting your body's ability to retain water. Hence the kidneys remove more water than usual from the bloodstream, meaning more trips to the bathroom.

Be sure to account for this lost time in your overall cost-benefit analysis.

mseery
+1 for an actual "LOL" :)
e.James
+1 very true. However I consider that "down-time" part of my daily workout!
Robert Gould
90% percent of programming is thinking, I can do that almost anywhere (83% of statistics.... ;)
BCS
This is a very interesting answer. While I believe it to be accurate, my experience is quite different. About 6 months ago I switched from several sodas a day to just water. I find that I have to use the bathroom MUCH more often now. Of course regardless, I'm sticking with water :)
Evan Teran
How many more trips during the course of a programming session are you suggesting? What does your control group consume during the same period: nothing, water, beer, etc? What about if I'm consuming the same amount of caffeine but in the form of ristretto espresso?
onedaywhen
It happens that when I go to bathroom or smoke a cigarette I resolve some problems I couldn't resolve reading code.
labilbe
Do not forget to include distance-to-bathroom in your cost/benefit analysis. Also, do you wash your hands? That could be another SO question, of course.
Yar
+1  A: 

I need a certain amount of caffeine every morning to bring me up to baseline, work or no work

If I need to crunch a lot then a little extra caffeine helps me get in a few more hours.

I did go through a period of several red bulls a day for a year or two, but came to the conclusion that I needed to change jobs, rather than just fry myself for a hopeless manager who couldn't say no.

Summary; in moderation, if it works for you - good.
If you find yourself living on the stuff - bad.
Productivity - about the same, but might get you a few more hours in the day.

seanb
+3  A: 

Improves my coding.

But the self-perpetuating high/crash cycle that comes from a strong caffeine tolerance does NOT improve my coding, so I try to keep it to a minimum. Maybe a cup of tea in the morning and a coffee when I REALLY need to focus (eg. deadline)

jacko
+3  A: 

i think it's more of a placebo effect than producing any real effect.

but if you have a whole routine setup to juice you up to be in the zone, and it includes a cuppa good java then by all means go for it.

melaos
A: 

coffee keeps me awake the morning after i passed the night programming usually very often, but only one cup a day. you can try apples also

Oscar Cabrero
+2  A: 

I can't speak for everyone, but in my experiences caffeine only serves to make me lose concentration in what I'm doing, whether it be coding or something else. I don't drink caffeinated drinks anymore, due to a recent polyphasic sleeping experiment. Water rox.

Rayne
+6  A: 

Effects of caffeine on performance and mood: withdrawal reversal is the most plausible explanation. This paper claims to show that the short-term boost of caffeine for productivity comes from temporarily countering the long-term depression of your baseline. If this is right, caffeine can help, but only if you're already hooked on it. (I have no idea, I rarely drink coffee, and soft drinks never.)

Darius Bacon
+1 (Anecdotal evidence) If I don't get enough caffeine I (and others around me) start to notice the withdrawal symptoms. Generally headache, irritability and lethargy.
Colonel Sponsz
+3  A: 

I drink tea. It helps dull out the headaches and invigorates the mind at times. Puts me in a better state to write code---or, even, to concentrate on anything serious I am reading on the screen.

ayaz
+4  A: 

Like every drug, this heavily depends on the user. Some people become brilliant with coffee, others just nervous (and less productive). As I see it, the main problem here is the popular belief "coffee is good" even when it's plain obvious that it isn't for someone. People tend to listen more to rumors than what they actually, personally feel.

Aaron Digulla
A: 

Red Bull gives you a good kick .

Geo
No, Red Bull gives you wings!
Jason Z
+1  A: 

Caffeinated drinks improve my life productivity!!

I remember the first time I drank a coffee black, it was late, a release was due, and the kitchen wasnt being restocked until morning...

WACM161
A: 

1 liter of caffeinated beverage enhances my concentration and speed. More than that leaves me sitting there twitching, unable to focus long enough to get anything done.

Brian Knoblauch
+7  A: 

From Wikipedia:

In large amounts, and especially over extended periods of time, caffeine can lead to a condition known as caffeinism.[67][68] Caffeinism usually combines caffeine dependency with a wide range of unpleasant physical and mental conditions including nervousness, irritability, anxiety, tremulousness, muscle twitching (hyperreflexia), insomnia, headaches, respiratory alkalosis[69] and heart palpitations.[70] Furthermore, because caffeine increases the production of stomach acid, high usage over time can lead to peptic ulcers, erosive esophagitis, and gastroesophageal reflux disease.[71]

There are four caffeine-induced psychiatric disorders recognized by the Diagnostic and Statistical Manual of Mental Disorders, Fourth Edition: caffeine intoxication, caffeine-induced anxiety disorder, caffeine-induced sleep disorder, and caffeine-related disorder not otherwise specified (NOS).

Caffeine-dependency among programmers seems to go hand-in-hand with sleep deprivation (and is often a cause).

High caffeine consumption has a whole host of nasty side-effects that complement the effects of sleep-deprivation perfectly. Insomnia is the real kicker. You need to sleep, you are knackered, but you can’t sleep because of the caffeine. So you either go to bed later or you lie awake for hours. When the alarm goes in the morning you are not recharged. You drag yourself out of bed and drink that first coffee/tea/Red Bull to get you started for the day.

Sleep deprivation leads to confusion, loss of concentration, impatience, memory lapses, depression and psychosis. DHH wrote an interesting article about the effects of sleep deprivation on programmers.

Dan Dyer
While I do prefer a good paraphrase instead of direct quotes, I must say that this is what I think. Whatever positive FX caffeine has are overruled by sleep disturbance.
Yar
+3  A: 

In my heavy caffine days I eventually discovered that the crash when it wears off is much worse than the slight boost you get while it's working. That may be acceptable when the pop machine's a short walk away, but it can be deadly when you are driving cross-country. Thus I learned to never drink caffinated drinks when driving long distances.

Eventually I started getting tremendous migranes on the weekends. I am not a headache-prone person at all, so this was scary. Asprin and Advil wouldn't make a dent in it. When I finally realised it was caffine withdrawl (I only imbibed at work during the week), and the suggested solution was to "keep drinking on the weekend", that's when I called it quits. I refuse, refuse to have my life controlled by a stupid little drug. I drink only caffine-free drinks now.

T.E.D.
A: 

I sometimes drink coffee. But to tell you the truth, I am more like a fan of energy drinks such as red bull. Although I know the synthetic ingredients and their effects, I tend to believe, that I feel better after I got a glas of it.

However... I think this goes back to the time when I consumed a lot of that stuff as a game developer with my boss having always whole palettes of Red Bull available. ;-) Maybe it is rather the sugar contained in energy drinks. I don't know.

I also prefer to take a walk outside and get a fresh breese of air. Energy drinks simply are the topping that taste nice and make me feel like a typical programmer (couple of years ago it was cola and cold pizza. Nowadays the pizza is at least allowed to be still hot and it's energy drings, lol).

Mephisztoe
+1  A: 

Guy Steele's answer, written in 1976:

Caffeine doesn't help me composing this verse.
It only awakes me; my thoughts all disperse.
One thinks better dozing, collapsed in a heap;
Why else are most students in classes asleep?

Darius Bacon
+5  A: 

Caffeine + Brain = MOAR BRAIN

GregD
+1  A: 

I believe that good or bad code depends on FOUCS, if you are in focus, but a little tired coffe can help you, but if you are not focused and you drink a coffee it only help you write some bad code.

how do you know? I think that if you find yourself reading the same line more than once - you should quit.

rabashani
"FOUCS" -- LOL!
j_random_hacker
haha priceless!
e.James
+2  A: 

I find caffeine to be a real double-edged sword. On the one hand, it increases my working memory. This sounds good until I write ridiculously complicated, non-modular code because it's too easy to keep lots of stuff in my head at once. Secondly, I find that it greatly increases my ability to focus, provided that I constantly have something to actually do. However, it makes me more impatient when waiting for things like builds, for tests to run, etc., so these kinds of things take me out of the zone faster when I drink lots of caffeine.

dsimcha
A: 

Normally, it's probably a net negative.

But if I'm working a job where they make me clock in at a certain time on the dot each morning, then I need it to actually be productive at a time when my body would prefer to be asleep still (I'm a night person, and would much prefer to wake late and code in the evening).

And hey, I just like the taste.

madlep
+2  A: 

It's a double edged sword.

If it's an occasional extra shot to help you get through a tough morning after not enough sleep it can help to keep you alert, although clearly too much can affect concentration.

But if it's a regular thing then it probably just feels like it's helping because without it you'll be suffering the withdrawal symptoms. It's an addiction. Also, it tends to feed the cycle of not sleep enough or well enough.

A much better solution IMHO, is:

  1. Start you day with slow-release, low GI/GL carbs (porridge is a particularly good source). This will help get your blood sugar balanced from the start. It's amazing how much of a difference this can make!

  2. Take power naps. These are ideally mid-morning (before lunch), and should be for no longer than about 15 minutes (more details can be found on the web). It's not easy for everyone to find somewhere discreet to do this - but if you can, it can really rejuvenate you.

Phil Nash
"...it can really rejuvenate" him? I don't believe you. It might refresh him but I'd be mighty surprised if it actually reversed the aging process...
Flubba
I stick by that. It can actually make you feel younger if you do it regularly. However, I really meant it more metaphorically - in the sense of refreshing, as you say.
Phil Nash
+2  A: 

Coffee (and other caffein drinks) is bad. Get enough sleep, eat healthy, exercise and make sure you drink enough water instead. Works a lot better. Also, you'll probably live longer and healthier (longer until you turn into a vegetable), meaning more time to program and have a good time =)

America's no. 1 Drug Problem - Coffee

Svish
+1  A: 

Caffiene makes my thoughts go all over the place. Explains a lot of software built on caffiene. Better to drink lots of water, fruits, rest, nap, focus, and get fresh air.

Jas Panesar
A: 

2 coffee a day keep the "Daily WTF" away.

on a more serious note: I think coffee helps through "energy bumps" (after lunch). But more than those and it is harder to concentrate.

But that may be more due to the ritual than to the caffein. I don't really like Red Bull oder other energy drinks, so I can't say anything about those.

bernhardrusch
+15  A: 

When I quit drinking coffee, as well as smoking cigarettes, my programming productivity went through the roof. I was convinced for years that caffeine and nicotine were improving my natural talents; you can find tons of studies showing that nicotine improves short term memory, for example.

But you know what those studies didn't talk about? Withdrawl. I was drinking 2 pots of coffee a day and smoking 2 packs a day. I was on a constant up/down/crash/withdrawl cycle. All day long. If I hadn't just put chemicals into my system, I was thinking about them. I was planning my meetings around being able to get a smoke in, or which ones I could be late to so I could smoke before them. I would need 15 minutes before a long meeting, so I could have 2 cigarattes, so sneak out for one. Do you know how embarassing it is to come back from "the bathroom" in the middle of an important meeting, and realize that company executives know that you ditched the meeting for 10 minutes to smoke a cigarette and refill your coffee?

On top of that, I was fairly tightly wound. After all, I was either riding a constream stream of uppers, or crashing from them. Throw in the constant vending machine sugar and corn syrup buzzes. Never mind the health effects of this lifestyle (I was putting on 25 lbs. year for the last 2 years that I lived like this); when I went for a checkup in 2007, the doctor considered putting me on cholesterol drugs because my cholesterol was so high, and I was only 28 at the time! I was a miserable jerk to be around. I had to work extra hard to be nice to people, because I was so edgy all of the time.

Maybe some people can handle caffiene and cigarettes, but I can't. There was nothing "productive" about it for me.

In the last 18 months or so, I quit smoking, no longer consume caffeine in any form (other than trace amounts in food), cleaned up the way I eat, and exercise (a combination of cardio and intense weightlifting) 6 days a week. Over that period of time, I dropped 30 lbs. of fat, put on 30 lbs. of muscle. My cholesterol dropped 9 points as of September, and I am looking forwards to another large drop this year. The amount of energy I have is unreal. I can put a laser focus on my job, because part of my mind is not constantly watching the clock waiting for my next cigarette or cup of coffee. I'm not constantly in and out of the bathroom. Thanks to my heavy lifting regime, my back and forearm muscles are much stronger, which has eliminated the pain I used to get from sitting at my desk, and has severely reduced the pain from typing/mousing that I used to experience. When I put my head down at night, I fall asleep and stay asleep. And I am now longer a pain in the neck to deal with.

My experiences may be a bit more extreme that others. But let's get real. Having a quiet area to work in will do more for your concentration that any amount of caffeine or nicotine.

J.Ja

Awesome. I really need to work on getting a quiet area to work.
Yar
wow. never heard it from that perspective before.
eviljack
+3  A: 

I occasionally need to read mathematics journal articles for programming work that I do, and I find there are often things I simply cannot understand without enough caffeine in my system. The level of abstraction required to understand a mathematical proof is sometimes just too high for me to cope with otherwise.

Sidebar: I think everyone has a natural "resting" level of abstraction that they are comfortable with; a programmer's resting abstraction level is on average above that of a non-programmer's, but professional mathematicians are another level above that. (The worst part is that some of them are additionally normal, friendly people who can socialise and play sports... Not that I'm jealous, of course.)

j_random_hacker