Shane Meadows, Advice on Screenwriting:
Any advice for writing effective comedy?
Comedy is impossible to write. If you've seen something that makes you laugh, this is probably the most important link to comedy. People can't help laughing at something that somebody else is laughing at. It's infectious, especially if that person is creasing up. If you have seen something funny, you should try to emulate that with your writing, or filmmaking. The chances are that you are showing people how you see it, and if it's funny to you, it is likely to be making people laugh at the other end.
Whereas, if you are trying to write a comedy that does not even make you laugh, then you are never going to make anybody laugh. So I think the secret to writing comedy is putting it across in a way which you find funny yourself. It sounds simple but a lot of people do not do it.