Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options
 
PerlMonks  

Coding while drunk

by Gordy (Scribe)
on Sep 12, 2002 at 08:31 UTC ( #197168=perlmeditation: print w/ replies, xml ) Need Help??

I'm sure this topic has been covered before but, oh well. The thing is I'd spent most of Saturday afternoon working on a piece of code, a small sort routine which no matter what I did just didn't work. Saturday evening came and I decided to open a few beers, well it was the weekend plus I'd had a hard week and all that :). I carried on with my coding and after a while solved the problem... but now I'm sober I can't work out why it works, it's the strangest thing, it just doesn't look right and unless I can figure out why it works it may as-well be something someone else wrote :/.

So my bit of advice for what it's worth is don't code whilst intoxicated, it'll only lead to frustration.

Comment on Coding while drunk
Re: Coding while drunk
by Ryszard (Priest) on Sep 12, 2002 at 08:52 UTC
    You know, some of the best coding i've done (or best fun i've had coding), is on a friday arvo, sitting at my machine with a bit of [slayer|sepultura|biohazard et al] blasting out of my speakers (@ 108Db) with a beer in one hand, and a bowl of chips close to the other hand.. :-)

    Nothing beats that i reckon..

Re: Coding while drunk
by greenFox (Vicar) on Sep 12, 2002 at 09:00 UTC

    Show us the code already! :-)

    You never know the advice you get back could be "code drunk more often!" <grin>

    More seriously I sometimes find that a distraction from the problem at hand leads to ideas and approaches that weren't apparent when I was immersed in it. Usually I like to go for a walk or something active like that... if a few beers works for you, then my advice would be "don't run outside of a test environment until after you have reviewed thoroughly, sober" :)

    --
    Until you've lost your reputation, you never realize what a burden it was or what freedom really is. -Margaret Mitchell

Re: Coding while drunk
by kodo (Hermit) on Sep 12, 2002 at 09:51 UTC
    You should stop drinking once you are a monk but before it's okay...
    Oh but once you are higher than monk you may drink again of course! ;))

    giant
Re: Coding while drunk
by Beatnik (Parson) on Sep 12, 2002 at 09:58 UTC
    Try doing that while slurping Tim Hortons French Vanilla Flavoured Cappuccino... It works for me!
    Well ok, it works too with some of Belgiums best beers :)

    Greetz
    Beatnik
    ...Perl is like sex: if you're doing it wrong, there's no fun to it.

      Reason: Aristotle worthless

      For more information on this node visit: this

Re: Coding while drunk
by Preceptor (Chaplain) on Sep 12, 2002 at 10:10 UTC
    There are no _inherent_ problems with chemically enhanced perception when coding. Course, the usual caveat applies of always review when ... ermm ... not chemically enhanced. It's the old thing about a new view on a problem. Like sleeping on it.
    I tend to find my code and comments get distinctly silly when I do though, and so I _do_ have to go back and figure out how the heck I did that ... ;p
    --
    It's not pessimism if there is a worse option, it's not paranoia when they are and it's not cynicism when you're right.
Re: Coding while drunk
by RMGir (Prior) on Sep 12, 2002 at 12:21 UTC
    ROFL. Reminds me of a "Compilers and Interpreters" class project in university, to implement a simple compiler.

    A friend and I did the project over a few bottles of beer, and it worked fine, except all the operators associated right-to-left.

    We documented that as a feature, saying it was "in the spirit of APL". :)
    --
    Mike

Re: Coding while drunk
by tbone1 (Monsignor) on Sep 12, 2002 at 12:31 UTC
    I think it's called "state-dependent learning". I did some practical and applied research on this when I was at Indiana University. It wasn't for credit, but it was truly the best education I had.

    A friend from that time was alway drunk for his attendance-required Friday afternoon class, so he had to get drunk for his final. He aced it, but to this day he probably couldn't tell you the first thing about it, least of all what the subject was.

    --
    tbone1
    As God is my witness, I thought turkeys could fly.

      I had an idea: use different scents for studying different subjects. That will keep everything associated better.

      State-dependent learning is true for caffene, I think, too.

        I had an idea: use different scents for studying different subjects. That will keep everything associated better.

        That's more difficult than it sounds.

        "Okay, what scent do you associate most strongly with Bio 227?"

        "Hm... coffee. It's always first thing in the morning, so I always have a cup on my desk."

        "Okay, cool. How about Bio 210?"

        "Well, I generally have a coffee and a cigarette just before that class. All through the class I can still taste the coffee, so..."

        "Okay, okay, how about Chem 210?"

        "Oh, my late class. Yeah, by that time I'm exhausted. If I didn't bring a large coffee with me I'd fall asleep. So, coffee."

        et cetera.


        LAI
        :eof
      It is state-dependent learning, and it seems to work. It may also be the reason for mental blocks during an exam (you are stressed during the exam, but not when you are studying - harder to access the memories in another state).

      I put this to the test over the course of my degree, and it does seem to work. You see, I never could get into studying until I had a few... :)

      I have eyewitnesses to the fact that I used to drink during exams... some of the highlights were:

      • Got so drunk in my number theory exam I couldn't follow my own working, passed the course (maybe my lecturer was drinking while marking!).
      • Got tipsy in Wave theory, teased the examiner in my answers, got credit in course, examiner still remembers my paper as one of the most enjoyable to mark :)
      • Realised I wasn't going to pass thermodynamics, drank until I passed out(on my exam paper). Woke up in an empty exam room, with my lecturer shaking my shoulder and telling me it was all over, and I could go home now.

      I always seemed to enjoy exams:)

      ____________________
      Jeremy
      I didn't believe in evil until I dated it.

Re: Coding while drunk
by IOrdy (Friar) on Sep 12, 2002 at 13:52 UTC
    Some of the most complex problems I have dealt with have been solved either a)In my sleep, or b)While drunk.

    It's odd but I often wake up in the middle of the night (or afternoon depending if I have turned nocturnal or not) and scribble down a solution so I can recall when I next wake up.

    Sometimes I donít remember even writing the solution until I see the 'note to self'.
Ganja for software design
by Anonymous Monk on Sep 12, 2002 at 16:14 UTC
    I work on software when I'm a little stoned pretty frequently. It helps me to look at the problem from new perspectives and it really helps me to come up with simple and elegant top-level designs. My architecture really does benefit from lighting up every once in a while and then sitting back and thinking really hard about whether I'm taking the design in the right direction or not.

    I also like to get a little stoned and then test my code for usability. If I can use it when I'm stoned then that's a pretty good indication that the interface is clear and simple and usable. Smoking pot kind of brings me down to the level of an end-user and it makes me more likely to go off clicking on things that I subconsciously don't do when I'm sober. I open up a "notes.txt" file in Emacs on one monitor and then I go off and try to break my code on another, and I normally have pages and pages of notes on things that need to be fixed after an hour or two. Throw a little acid jazz into the process and it's actually a lot of fun.

    I don't really recommend trying to actually write code when you're stoned. It's a great state for sitting back and thinking about top-level stuff or examining your application for beauty, but it impairs concentration in the worst way and your code suffers. Espresso will always be my favorite substance for coding assistance.

      Yeah right.
      New perspectives, solving problems in a new way, blablabla.
      In a few years you'll realize you were just fucked. :-)

      Acid and assembler though, now /that/ is something :o)

      -- 
      ash/asksh <ask@unixmonks.net>

      sooooo true. i figured out how to solve just about all of my CS assignements after a spliff or two, but the amount of typos and syntax errors skyrockets. combining with dangerous amounts of energy drinks or mild amphetamines helped me speed up the recognition and correction of my mistakes but it also led to all-nighters bent over my laptop typing furiously while listening to gabber and speedcore, neurotically counting down the seconds till the due date...

      DRUGS ARE BAD, KIDS


      "Everything is true." "Even false things?" "Even false things are true" "How can that be?" "I dunno man, I didn't do it."
Re: Coding while drunk
by reyjrar (Hermit) on Sep 12, 2002 at 16:25 UTC
    I'm not a drinker by choice. But I have found that sleep deprivation serves the same purpose. I used to work the graveyard shift at my old job. Only, no one respects the fact that you sleep while they play and work, resulting in a somewhat chaotic sleep patterns. I found that the less sleep I got, the more interesting problem resolution tended to be.

    all hail perl's TIMTOWTDI and DWIMing! I remember countless nites where I'd go "now, I know C will never let me do this, but this is perl, and it might let me. HOLY MONKEYS IT WORKED." It was like falling in love with perl all over everytime something like that happened. These revelations continue through today, especially when my mind is functioning irrationally. ;)

    -brad..
Re: Coding while drunk
by SpritusMaximus (Sexton) on Sep 12, 2002 at 17:00 UTC
    A few years back, I was working on an inventory system I was writing in C++. I had many an enjoyable night, after 2-3 glasses of Merlot, coding and debugging. As the previous posters said, be sure to test while sober... and also to review your code. It may be hard to explain code fragments like:
    $LeafySQL->prepare("select car from inventory..."); $LeafySQL->execute; $Lettuce = $LeafySQL->rows; $BigMac = $Lettuce + $Tomato + $DeadCow; # chomp($BigMac); # Oops, that didn't compile, $BigMac isn't a string... # but maybe in an alternate universe, oh just maybe...
Re: Coding while drunk
by dws (Chancellor) on Sep 12, 2002 at 17:56 UTC
    ... and I decided to open a few beers ...I carried on with my coding and after a while solved the problem... but now I'm sober I can't work out why it works

    You're using a dangerous definition of "solved".

    What you did was stumble across a combination of stuff that "works", but which you don't understand. That's not solving, that's hiding a problem somewhere else.

    Set what you have aside, and rewrite. Unless you can get to something you can understand while sober, you're either not done, or you're in over your head.

      What you did was stumble across a combination of stuff that "works", but which you don't understand. That's not solving, that's hiding a problem somewhere else.

      He may have understood it fine when he wrote it. Just because he can't seem to recall that understanding doesn't mean he didn't solve it. We all run into that sooner or later, drunk or not.

      I do agree that he should regain his understanding, test it, fix it if necessary, and probably comment the code. That's the same advice I'd give anyone that had written some code and forgotten how it worked.

      -sauoq
      "My two cents aren't worth a dime.";
      
        Programming languages are meant to communicate a solution to another human through a conversation that a computer is barely smart enough to understand. If you can't even understand your own code, then it doesn't communicate a solution. It may as well have been a bunch of raw hex digits, which would at least be convenient for the computer. I agree with the earlier poster - toss and rewrite. But this time imagine that a sociopathic homicidal maniac who knows where you live will be the next one to have to understand your code.
Re: Coding while drunk
by jepri (Parson) on Sep 13, 2002 at 02:54 UTC
    It is clear that the problem is not with your code, but with your mental abilities while sober. Try getting drunk again, and I'm sure that you will be able to clearly understand the code again.

    Some dull people may point out that the code is not much use if you can't understand it while you are sober, but they are solving the wrong problem. The real problem is your lack of alcohol. Put in a good supply of grog, and stay drunk. Then you will always be able to understand your code.

    And remember, you don't get a hangover if you don't stop drinking.

    ____________________
    Jeremy
    I didn't believe in evil until I dated it.

Re: Coding while drunk
by Gordy (Scribe) on Sep 13, 2002 at 06:10 UTC
    Thanks for the replies, I've now got an excuse to get drunk more often :) (just kidding there btw).

    With regard to being out of my depth and my dubious use of the word 'solved', as I said unless I can figure out why it works it may as-well be something someone else wrote .

    So until I get a good grip on this it may be wise for me to turn off the PC if I decide to have a drink, I'd hate to code something 'truly wondrous' and not understand it the next day :p

Re: Coding while drunk (why god created the universe)
by Preceptor (Chaplain) on Sep 13, 2002 at 08:26 UTC
    (To put it all in context, there's a reason why code works whilst under the influence. Plagiarised from elsewhere, but worth repeating)

    I don't need to scratch my head and search my soul to figure out whether God created the universe. I was there. I saw the whole thing.

    God didn't create the universe. Well, He did, but not intentionally. God just wanted a beer. But you can't just create a beer floating in the middle of the void -- there's nothing satisfying about it. It would be like a book written by an illiterate person -- sure, he could put lots of black squiggles onto a bundle of pages that would vaguely look like a book, but it wouldn't mean anything.

    So for a proper beer, God pretty much had to make up physics. I'm not just talking about the refinements needed to get it to foam just right -- I'm talking about the whole deal. After you drink some, there should be less left over, not more. Drinking a beer should not make you turn into beer yourself. Beers should not be smarter than the drinker. Well, not the first few, at least. The state of drinking beer needs to contrast with something, so the state of not drinking beer must also exist. In fact, that's where most of the world came from, because having the world exist in only two states (currently drinking beer/currently not drinking beer) just seemed too lame to a clever guy like God. Same idea for water and other liquids -- if He can drink beer, He really ought to be able to drink not-beer, just so He can say He chose the beer instead.

    And then there's the whole question of origins. A beer is so much less interesting if it creates itself or just spontaneously comes into existence. A truly full-bodied beer needs a background, a character, a story. God went a little crazy with that, inventing those 'human' things with enough cleverness to invent stuff, curiousity to try things out, and a desperate need to get sloshed, smashed, trashed, and basically totally drucking funk. And all that cleverness and curiousity necessitated science. And dinosaur fossils. And religion. (God got a real kick when he realized he'd have to invent religion, I remember. Of course, he wasn't exactly sober by that time...)

    Oh, and you know that bit about "...and on the 7th day He rested?" Purely an excuse to keep us from bothering Him during His hangover. We're still on the 7th day, see. I'm not even sure if He thought far enough ahead to make an 8th day. He was having some trouble with the notion of Time, and I recall Him saying something like "aw, screw it. Nobody's going to be drinking any beer at the speed of light anyway. I'll see you later -- I'm gonna go get wasted."
    --
    It's not pessimism if there is a worse option, it's not paranoia when they are and it's not cynicism when you're right.
Coding while intoxicated
by Your Mother (Canon) on May 03, 2003 at 03:57 UTC
    Brian May was having a really bad time finishing the guitar solo on "Dragon Attack." Been knocking away forever in the studio; still sucked. Stepped out to the pub and drank to the gills. Went back to the studio and banged out in one take what I think is one of the most original and interesting solos ever committed to tape.

    Intoxicants passify the inner editor. That little voice that makes you hesitate before trying a novel solution b/c it seems like it might be stupid or lead to embarrassment. Having leverage to at least have the voice leave you alone for an evening can sometimes be a tremendous tool.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlmeditation [id://197168]
Approved by ignatz
Front-paged by rob_au
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others lurking in the Monastery: (9)
As of 2014-12-26 04:44 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Is guessing a good strategy for surviving in the IT business?





    Results (165 votes), past polls