Live data from Hacker News

Is there evidence that drugs can help programmers produce “better” code?

programmers.stackexchange.com

11–20 of 77 posts

Re: Is there evidence that drugs can help programmers produce “better” code?

#11
This question is basically a medical question, so it is best answered with the principles of science-based medicine in mind.

http://www.sciencebasedmedicine.org/index.php/about-science-...

First of all, do we have a clear evaluation criterion for "better" outcomes? If the question is about writing better code, is there agreement at the start of an experiment about what "better" means? I'm not experienced in evaluating software code (I'm much more experienced in evaluating psychological and medical research), but it seems to me, from reading HN, that better code could be code

a) that is able to pass all the unit tests with an earlier deadline,

b) that has a smaller total bug count when subjected to code review,

c) that solves a problem that other programmers in the same workplace didn't solve until later,

d) that works around an intellectual property claim by a competing company more convincingly,

e) that meets company stylesheet requirements more exactly,

f) that can be maintained by less skilled subsequent programmers,

and perhaps other criteria.

Any sound experimental study has to meet a lot of other criteria

http://norvig.com/experiment-design.html

to be worthy of believing, and in human drug studies the criteria include

1) sufficiently large sample size (n = 1 just doesn't do the job)

2) treatment-control design (so that some subjects of the experiment get the drug, and some subjects do not)

3) double-blind administration (the subjects of the experiment should not know if they are getting the drug, nor should the experimenters know which subjects are getting the drug)

and many more, especially

4) rigorous statistical analysis afterward.

As Richard Feynman said, "The first principle is that you must not fool yourself--and you are the easiest person to fool. So you have to be very careful about that."

http://www.lhup.edu/~DSIMANEK/cargocul.htm

So anecdotes along the lines of "I took this drug, and I wrote much better code" can be completely discounted, because we don't have access to the coder's before-and-after work product (nor to the coder's detailed dosage history) to know what really happened.

Re: Is there evidence that drugs can help programmers produce “better” code?

#12
post #8

That reminds me of the time I was taking pot while in college. During one class I was completely zoned into the cursor and moved it back and forth 5-6 pixels across the screen. My experience though it is anecdotal seems to rule out at least cannabinoids.

Dosage is an important consideration, though. I know someone who used to use pot as a programming aid, but he had to be very careful with the dosage. By using very small amounts spread out over the day, he could maintain a flow state that let him churn out code for hours and hours. He didn't find it all that helpful for design and planning, but for large projects that involved an overwhelming amount of fairly boring work, he found it to be a helpful tool.

The problem was that if he used too much, he'd be pretty much useless until it wore off some. Smoking a plant is not exactly what you would call "precise dosage administration", so this was a fairly significant issue.

Re: Is there evidence that drugs can help programmers produce “better” code?

#14
Define drugs. I know Ritalin is an invaluable tool when it comes time for me to sit down and hack, but can also be counter-productive in limiting my creativity.

I think it would be self-evidently false to suggest that no mind-altering substance could lead to a state of consciousness more conducive than the baseline for a given activity, but I would stop short of recommending any particular drug for programming. If it works for you, do it. If not, don't.

Re: Is there evidence that drugs can help programmers produce “better” code?

#16
Which drugs? I've been writing an application for 4-5 years. It's my "learn a new language" project and it's pretty complex and I recently rewrote it and exclusively worked on it under an influence of one or another of things, but nothing like Adderall or Ritalin. I just finished the final version of this project in Go and it is far and away the most readable, performant version I've written. It's also the first version to properly protect against all types of races.

Re: Is there evidence that drugs can help programmers produce “better” code?

#17
post #9

You tend to use the very specific phrase "nootropic drugs" to talk about drugs which help with productivity or creativity or some other aspect of working life. Asking whether there is evidence on nootropics, is just asking whether there are any heavily-tested nootropics. Asking anything else--to lex it out, whether "drugs that have no productivity-enhancing aspect, enhance productivity" is just playing the fool to in…

I'm not an expert, but I'd like to comment on your statement that discussing non-nootropics in this context is pointless. I think it is not, and my argument goes like this: you code better when in mood to do so. Certain psychoactive substances make it easier to fall in certain moods, easier to change your mood or even forcibly change your mood for you (like some of benzodiazepines or MDM, MDMA). Their working is not "nootropic" (as in it does not necessarily improve any mental functions) but you're in generally better disposition to code after using them. This is true even for coffee, and even without developed dependence - if you're feeling sleepy, your code will be worse than when you're feeling wide awake, and coffee, being a stimulant that it is, can give you that feeling.

So, what I want to say is that not only measurable enchancement of "cognition, memory, intelligence, motivation, attention" (as with nootropics) can result in you doing better job. For example, while benzodiazepines generally lower cognitive ability, they enable people with depression to actually do something (to code, for example :)). Of course, when overdosed or just not fit for your particular brain, the same psychoactive substance can lower mental function so much, that no amount of optimistic thoughts is going to help you.

I just want to point out that there is more to productivity than memory, intelligence and concentration and that this means that when discussing productivity there is a place for not-strictly-nootropic drugs in the discussion. Although, I have to admit, that place is rather marginal due to very, very varied responses to such a substances among individuals.

Re: Is there evidence that drugs can help programmers produce “better” code?

#18
Drugs in programming, as well as other occupations, play an emotional role as much, or more so, than a cognitive role.

If Habit A helps a programmer who'd otherwise be sidelined by emotional problems stay in the chair, it may help that programmer be more productive than they would be otherwise. Of course, addictions don't help us face those problems in the long term, and often let them get worse.

All sorts of drug-related behaviors exist among programmers. Many shops full of brogrammers celebrate beer o' clock at 4pm. Other programmers sneak out alone or with friends at lunchtime to a bar or convience store to enjoy some alcoholic drink.

Many programmers abstain from intoxicants at work, except for the common stimulant caffeine. Others are hooked on opiates after being perscribed them for chronic or acute pain.

LSD, even the weak stuff common in North America from 1970 to 2001, is profoundly distracting. Years ago I ate a pinch of mushroom dust and found that 25 minutes later, I couldn't keep my eyes straight to even look at a computer screen. On the other hand, it's the only sacrament that's clinically proven to more create spirtual experiences than a placebo -- the ability of hallucinogens to create profound changes is practically unlimited.

Long before the statute of limitations, I once received a gift of several dexedrine pills from a friend diagnosed with ADHD. I took one on the the first day of a new project and felt euphoric. I wrote several hundred lines of beautiful code that would serve the nucleus of a system that was planned to replace critical functions of a production system that tens of thousands of people depend on every day.

A week later I had a more sobering experience. I was tasked with upgrading another production system, and with the dexedrine tab in me I felt cocky and by 9:08 am I'd deleted the master instance of the production system.

I got forbearance from my co-workers because we had a backup ready, and a tested restore procedure, so we had the system back in 13 minutes and soon proceeded with the upgrade.

That was a portent of things to come. The project I was working on had no project manager and a group of stakeholders that hated each other. I tried to code my way of a difficult interpersonal problem and ultimately it all came apart. A year later I deployed the new system with hardly any testing and of course it didn't work. After a week of month of daily patches, each bug fix breaking something else and spreading database corruption, we threw in the towel and reverted to the old system.

My contract didn't get renewed at that employer the next year, and that was the beginning of my being a "journeyman" as a mercenary maintenance programmer.

Perhaps I shouldn't blame two amphetamine pills for something that was so much bigger; but I like the story that the pills started the project out in a state of spiritual misalignment. Had I listened to people instead of coding, things might have worked out differently. I might even have quit and had an easier time getting my next job.

Some programmers adocate nootropic drugs like Piracetam but I think those are just as bad as speed. They mess up your reward pathways and make you feel like you're Tony Stark but they don't really make you a genius.

I for one am addicted to caffeine and find it quite difficult to stop, even though it screws up my digestion almost to the point where I throw up. It's terrible, but at least I'm better off than the alcoholic and dope addicts I've met.

Re: Is there evidence that drugs can help programmers produce “better” code?

#19
post #3
post #2

Posted on HN 49 minutes ago, closed as "not a real question" 48 minutes ago. Wow.

> It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, see the FAQ. It seems pretty specific to me. If you have evidence, present it. I can see an argument for it being too broad, but it saddens me that a question such as this is cl…

Honestly I'm not a huge fan of programmers -- in the beginning I thought it would be a good place where we could have these debates and talk about general programming/programmer issues. Stack Overflow was the place for specific technical questions, "how can I do X?" -- programmers could be a good site to have a Socratic debate on the virtues of various programming methodologies - "Why should I do X over Y?". Honestly we need a good forum for debunking the various cargo-cult ideas or at least presenting all sides in a debate in one location.

I understand the stack overflow format may not be the most appropriate -- after all these questions may not have a "best" answer, or that best answer may change over time. To counter that, perhaps the person asking the question could just pick the answer they went with and offer some context why it worked for them.

If all the questions must have a specific answer, then I fail to see what the difference is between SO and Programmers -- I would follow the DRY principle and remove the duplicate code.

Re: Is there evidence that drugs can help programmers produce “better” code?

#20

Drugs in programming, as well as other occupations, play an emotional role as much, or more so, than a cognitive role. If Habit A helps a programmer who'd otherwise be sidelined by emotional problems stay in the chair, it may help that programmer be more productive than they would be otherwise. Of course, addictions don't help us face those problems in the long term, and often let them get worse. All sorts of drug-re…

> Perhaps I shouldn't blame two amphetamine pills for something that was so much bigger;

No, you shouldn't. IIRC there was not even slightest trace of the substance in your body after a few days. Please, don't attribute to the drug things that can be equally well explained by inexperience in social interactions, emotional immaturity or any number of other reasons, inluding bad luck. Have you been using the drug for half of that year - maybe. But it's obvious that whatever made you "code and not listen to people" was not the drug. I mean no offence, and I guess it is, maybe, somewhat, possible that using a drug twice changed your character and way of thinking for a year, but I find it really hard to believe.

Post reply on HN