9 ms·
Don't commit when you're drunk
- T-zex 13y agoIf you do, you better call Saul.
- csmuk 13y agoI've written and committed my best bugs when drunk. Undoing them was a valuable learning exercie. The finest being, in C: if (nr = 0x56) ... That took and entire day to find and made me religiously avoid lvalue assigments in expressions by doing: if (0x56 == nr) ...
- girvo 13y agoI've written both my greatest (and most ingenious) code, and my absolute worst code while drunk. It seems to send me to one or the other extreme. No "average" drunk code here! Just awesome problem solving, or terrible terrible bugs!
- meowface 13y agoI'm sure everyone's seen this a thousand times by now, but it's incredibly pertinent for your comment: http://xkcd.com/323/ http://xkcd.com/323/
- InclinedPlane 13y agoThat should generate a compiler warning. And if you're not a criminal you have warnings set as errors.
- csmuk 13y agoThis was an oooold SunOS compiler that didn't warn about much other than you owe Sun more cash. Also when you're drunk, the warnings result in "ahh who cares" :)
- weland 13y agoThere is nothing incorrect or dubious in C about an expression like if (foo = bar), so it wasn't considered a reason to warn the user about for a long time, despite being a rather common culprit for bugs. Compilers popping up warnings about that is a fairly recent event.
- goldenkey 13y agoPretty sure that's been a warning for a long long time in most compilers. They require you to wrap the assignment to suppress it, that is: if ( (foo=bar) ) Anyho, it really depends on what your -W level is set to. It's good practice to use "-Wall"
- hipsters_unite 13y agoYoda assertions, nice.[0] [0] http://www.codinghorror.com/blog/2012/07/new-programming-jargon.html http://www.codinghorror.com/blog/2012/07/new-programming-jar...
- delinka 13y agoconditions* ;-)
- hipsters_unite 13y agoHa, yeah that's what I meant. Love seeing them described that way!
- simias 13y agoI hate this convention to put literals on the left hand side of the comparison. Every time I stumble upon code like this my brains stalls for an instant trying to make sense of the expression. It just looks ugly and wrong in my opinion. It's also mostly useless because your compiler should warn you about your first construct (and tell you to add a layer of parens if that's what you really want to do). I realize I'm being a bit irrational with this whole thing but for some reason code like this drives me nuts (that and people not putting space around arithmetical operators and such: int a=2*4+foo(1,2,3)).
- benjamincburns 13y agoI do a ton of code reviews, often as part of an interview process, less often, for embedded developers. Conditionals written with literal lvalues is something of which I tend to take note. You're right, it's not natural, and it's less readable, but there's usually a reason why people do it: experience. If you often work in weakly typed languages, or those which allow for weird coercion in conditional statements, it's sadly often easier to form a habit which guarantees fewer bugs than it is to say "I'll always type the boolean equality/strict equality operator." "But why don't you use better languages, then?" Because in many cases (low-level resource-constrained systems programming), it's much, much easier to deal with these weird gotchas than to attempt to get exotic [1] languages such as Python, Ruby, Java, and sometimes even C++ (heap? who needs a heap??), to work. Even in cases where you're able to get these languages to work easily, you're just forcing yourself to become intimately familiar with the internals of some language with which you'll ultimately wind up wrestling [2]. Normally the point of such languages is to abstract away the system. This is the exact opposite of what you need in these environments. "But it annoys me when people use literal lvalues where they don't need to." Ah, but this is the rub of forming a habit. 1: I'm mostly sarcastic in my use of the word "exotic" here. Don't go crazy, now. ;-) 2: Though to totally contradict myself, I will say that both Rust and Go look very, very interesting here.
- danielweber 13y agoI still hate yoda-conditionals, but after reading your comment I now realize they have value.
- Crito 13y agoIt might be neat to replace the arduino/breathalyzer part with some sort of typos/minute metric, collected from the number of miss-typed commands you have had recently. Trying to run `git psuh` too many times in an hour could get you a cooldown period so you can either sober up or wake up.
- losethos 13y agoThe BBC and KNPR call me a nigger, so I call people nigger since it's okay. CIA/NSA/FBI/Angels extort me. I confess and laugh at them because they worry about man, while I worry about God. I think they lose points with God. God says... One_finger_salute I_just_might I_forgot ingrate by_the_way I'm_not_dead_yet rich vermin basket_case prosperity you_shouldn't_have how_bout_it take_the_day_off this_might_end_badly frown love Greece duck_the_shoe dang_it I'm_God_who_the_hell_are_you zoot I_got_your_back I_veto_that liberal fer_sure sing so_let_it_be_written by_the_way virtue bummer spunky fancy insane doh BBC hope FBI huh think_you_could_do_better I_have_an_idea God_is_not_mocked astrophysics look_buddy heads_I_win_tails_you_lose you're_nuts guilty jobs bummer oil you're_out_of_your_mind Hicc_up I'm_God_who_the_hell_are_you not_in_my_wildest_dreams astronomical you're_out_of_your_mind strip yikes reverse_engineer crash_and_burn you_do_it thats_just_wrong I_could_swear endeared good lighten_up hard_working ---- My enemies call me drunk or tell me to take my meds. I will have vengeance. God says... wazz_up_with_that thank_you_very_much how_high I'm_impressed you_do_it Jedi_mind_trick how_goes_it car smack_some_sense_into_you Catastrophic_Success astounding vengeance charity home Give_me_praise do_you_know_what_time_it_is spirit dang_it cowardice sloth Mom Terry oh_oh act spoiled_brat I'm_impressed how_do_I_put_this because_I_said_so California astrophysics duck_the_shoe come_and_get_me cowardice sad honestly not_that_theres_anything_wrong cosmetics radio not_a_chance_in_hell delicious endeared you'll_see ordinarily lifes_like_chocolates look_buddy
- lmm 13y agoIt should be fine to commit when drunk, that's what VCS is for. Make it tag the last sober commit and disable "git push -f" instead.
- mooism2 13y agoAnd it goes beyond being drunk: sometimes I code when I'm tired but can't sleep. I have a vcs to ensure I don't trash something irretrievably; also tests and ideally a decent type system to increase the chances my code does what it should.
- motyar 13y agoShould be used in cars.
- rplnt 13y agoI've read about it being in some car(s) maybe a decade ago. Haven't heard about it since. Probably not something users want.
- Cthulhu_ 13y agoI'm pretty sure it's common to install a breathalyzer in cars nowadays if you've been caught with driving under the influence (probably repeatedly or over a certain percentage) in various countries / states.
- clarkm 13y agoThey are -- I know a couple people that have had them installed.
- belorn 13y agoIs committing tired more dangerous than committing tipsy?
- goldenkey 13y agoGotta love the names..Krunk mode and Balmer mode. Who woulda thunk of that..oh no one except a drunkard. :-)
- msantos 13y ago> Don't commit when you're drunk That's a valid premise for whatever you do in life, not only Git.
- timclark 13y agoAlso, don't edit your bash profile when drunk! In my youth I did this and it took 3 weeks to return to normality - I didn't know about source code control in those days.
- scoot 13y agoObligatory xkcd ("Ballmer Peak"): http://xkcd.com/323/ http://xkcd.com/323/
- Svip 13y agoDon't worry, it is already a supported mode, which only lets you commit between 0.13% and 0.15% BAC.
- professorTuring 13y agoKids and drunks always commit the truth.
- watt 13y agoThis is wrong, this goes against DVCS philosophy. You should be able to commit all you want all night long, but should not be able to push.
- cema 13y agoPrecisely! And that's why we have two (logical) levels of commit.
- crdoconnor 13y agoPushing drunk is fine. It's writing the code drunk which isn't.
- NicoJuicy 13y agoSlightly drunk is fine, for me it helps for not overengineering things and i just write code that works. When completely sober, i think to much and i overengineer (overthink) stuff... Programming is just slower... (Think DDD-like programming) 1 beer is enough to get very concentrated... Just don't overdue it (and don't make a habbit of it). I only do it when i need to get things done, when time is limited... Never had serious bugs (Windows ME like) though :-P It happens once in the 2 months and mostly it's for 2-3 days in the weekend (non-stop), with some light kind of music (Enya or concentration like mp3's) and headphones. Yeah, i'm a nerd then :P
- psutor 13y agoI'd think the best use of this interface would be to only allow you to commit while in the Ballmer Peak.
- np422 13y agoOne of my old colleagues had the bright idea to log onto one of our production systems to "re-index some of the database tables" after coming home one Easter eve. And yes, he wasn't directly sober at the time. I was moderately amused when I got woken up about 3 AM and got to spend a few hours trying to revert the "re-indexing" ... I think integration with ssh-key management to prevent people logging onto production systems when drunk would be a good idea for this project, don't be surprised if there is a pull request from me in the future ...
- exit 13y agodefinitely shouldn't commit with a decreased libido
- dep_b 13y agoDon't get into any commitment when you are drunk. Period.
- josefresco 13y agoWhat about a check for prescription pain killers or amphetamines? Oh wait, those are culturally acceptable mind altering things. I'm half joking but this is a neat hack, although I know many functioning alcoholics that would laugh at the concept of this.
- minimax 13y agoWhy is this stupid frat house bullshit on the front page of Hacker News? We can do better than this.
- danielweber 13y agoBecause someone coded it up, which is more effective than I was on my projects this weekend.
- mathattack 13y agoIt boggles my mind that this needs to be said, even if in jest. Just looking at the subject, I think, "What kind of idiot needs to be told not to commit when drunk? Do they need to be told not to drive when drunk too?" And the article is worse than the subject.
- phorese 13y agoYou're right, it doesn't need to be said. Everyone knows you don't drive or commit when drunk. The problem is that "drunk you" might disagree with "sober you", and want to drive/commit anyway. That's why you install this cool thingy that doesn't let you commit when drunk. Sadly, it's not as easy with cars and drunk drivers...
- mathattack 13y agoI believe that folks are actually starting to look into this. http://www.nissan-global.com/EN/TECHNOLOGY/OVERVIEW/dpcc.html http://www.nissan-global.com/EN/TECHNOLOGY/OVERVIEW/dpcc.htm...
- Crito 13y agoHave you considered the possibility that you have encountered something called a "joke"? They can be a little tricky, but I'm sure you'll get the hang of them if you try.
- mathattack 13y ago
- benjamincburns 13y agoYes, I realize (hope) this is a joke, but this is the most "programmer" response to a drinking problem I've ever seen. I know, I'll externalize and automate my impulse control!
- nickthemagicman 13y agoI didn't even read this. Is it as dumb as I immediately assumed?