Doug Stanhope is a mess. A thrilling and beautiful mess, that is – a maelstrom of vitriol, fury and alcohol that represents, depending on your perspective, either the high or low point of standup's grimy and dangerous outer fringes.

As part of a global expedition to explore what makes things funny, professor Peter McGraw and writer Joel Warner are grilling humorists about the science behind scoring laughs. The Humor Code chronicles their adventures, scientific experiments and unintentional comedy along the way. Learn more about McGraw, Warner and their escapades at HumorCode.com.

Stanhope's coarse, unapologetic and shockingly candid brand of comedy has won him rabid fans, as well as a few foes. Ricky Gervais said Stanhope "might be the most important standup working today." Jón Gnarr, the comedian-mayor of Reykjavik, recently welcomed Stanhope to Iceland so he could perform in the country's only maximum-security prison. (For this, Stanhope invented the "Stanhope Defense," the legal argument that you committed a crime just to see the show.)

At the same time, Stanhope's cracks about the attractiveness of Irish women and the redundancy of the royal family have incensed an impressively large fraction of the British Isles.

Whether you love or hate him, there's more to Stanhope than just his drunken, in-your-face comedy routines. That's clear from his critically lauded portrayal of a suicidal comic in the hit show Louie, not to mention his media-savvy web ventures, including Doug Stanhope's Celebrity Death Pool. In the lead-up to Tuesday's release of his new live CD/DVD, Before Turning the Gun on Himself, Wired caught up with Stanhope and tried to temper his raging comedy fury with cold, hard science. The results were far less messy than expected.

Wired: Would you say there is a science to what you do? Is there a formula behind how you come up with and perform your comedy? Or would you say it's pure "art"?

Stanhope: There are techniques like basic misdirection that you might call science or "tricks" that, say, make prepared material sound completely spontaneous. Whether that's science or part of the art ... I think the word "art" is bullshit to begin with.

Wired: Humor is lauded for all sorts of positive effects, but it can also have a dark side. Research into what's called the "prejudiced norm theory" suggests that derogatory jokes can actually increase tolerance of discrimination among those listening by suggesting that it's OK to not take issues like racism and sexism seriously. Do you ever worry that you've gone over the line, that your humor will hurt people?

Stanhope: Actually I oftentimes hope that my comedy hurts people when I believe those people should be hurt. If my bits about Dr. Drew and the junk science of Alcoholics Anonymous were to put them both out of business, I would be quite content with myself. That isn't going to happen, but there is nothing wrong with the idea that it could. Comedy can always be taken the wrong way. If I do a bit that is meant to diffuse racism or sexism, I'm not going to avoid it on the chance that a small portion of the audience might take it the wrong way. Then the only way to address sensitive subjects would be to remove the jokes and just make statements and now you're no longer a comedian.

Wired: You are known for your apparent onstage inebriation. Studies show that alcohol can boost humor appreciation, since it lowers inhibition, decreases anxiety and increases positive mood. But we've done research on the other side, and found that booze might inhibit humorists' ability to be funny. How and why does alcohol fuel your work?

Stanhope: There's a fraudulent root element of comedy in that we say things night after night as though they are rolling effortlessly from the brain and off the tongue when in fact they are crafted over weeks and months and years. Alcohol allows me to get past this sense of trickery and focus on the original passion in the material even when it's old to me. God knows how much I'd have to drink to be able to live with myself if I were a magician.

Wired: You were lauded for your performance on Louie, where you played "Eddie," a comedian who was planning on killing himself. There is empirical evidence that comedy is a fairly dangerous occupation: On average, comics don't live as long as those in the general population. Why do you think that is? Is it just because of the wild lifestyle, or are there other forces at work?

Stanhope: Maybe it's because we get to live our lives doing all of those things that other can't wait to get to retirement age so they can do, too. It's sad that it takes some people 70 or 80 years to live out one simple life. Slackers.

Wired: You identify as a libertarian. While there hasn't been much research on libertarianism and humor, studies comparing whether Democrats or Republicans are funnier have so far proven inconclusive. How does libertarianism inform your comedy style, and has this election season been a good one for comedy fodder?

Stanhope: I think it's probably much easier to do political comedy from a two-party point of view, in that the majority have some sense of what it means to be one or the other. Most people have no idea what libertarian even means and it's probably why people like Dennis Miller or Bill Maher jumped ship from the label of libertarian. It doesn't sell nearly as many tickets.

Wired: You've had all sorts of fun with websites like Saving Bristol.com and now Celebrity Death Pool. Plus, when you released your new album Before Turning the Gun on Himself digitally in March, it hit the top of the comedy charts. Do you think the internet has helped or hurt your unique brand of comedy?

>'The internet has done nothing but good for comedy.'

Stanhope: The internet has done nothing but good for comedy all around. Comedians no longer have to rely on TV execs and club owners deciding if they are funny or not. There's the problem of piracy if you think it's a problem. I credit piracy with getting my name known enough to have a decent career. People bootlegging shows on cellphones and putting material out before it's finished is a problem for every comic, but compared to all the upsides of what the internet has done, it's a fact of life that we'll learn to adapt to even if it means finding these people and killing their families in front of them.

Read more of the Doug Stanhope interview, and learn more about McGraw, Warner and their escapades, on the Humor Code website.