Is there something funny about science? Audiences at Robin Ince's seasonal slice of rationalist revelry, Nine Carols and Songs for Godless People, seemed to think so. This annual event, at the Bloomsbury Theatre in London, is far more a celebration of the wonders of science than an exercise in atheistic God-baiting. In fact, God gets a rather easy ride: the bad science of tabloids, fundamentalists, quacks and climate-change sceptics provides richer comic fodder.

Time was when London theatre audiences preferred to laugh at science rather than with it, most famously with Thomas Shadwell's satire on the Royal Society, The Virtuoso, in 1676. Samuel Butler and Jonathan Swift followed suit in showering the Enlightenment rationalists with ridicule. In modern times, scientists (usually mad) remained the butt of such jokes as came their way.

They haven't helped matters with a formerly rather feeble line in laughs. Even now there are popularizing scientists who imagine another repetition of the 'joke' about the physicist who claims to have solved a dairy farmer's milk-production problem (his theory only works for spherical cows) will prove them all to be jolly japers. And while allowing that much humour lies in the delivery, there are scant laughs still to be wrung from formulaic juxtapositions of the exotic with the mundane ("imagine looking for the yoghurt in an eleven-dimensional supermarket!").

Meanwhile, science has its in-jokes, just like any other profession. A typical example: A neutron goes into a bar and orders a drink. "How much?", he asks the bartender, who replies: "For you, no charge". Occasionally the humour is so rarefied that its solipsism becomes part of the joke. Thomas Pynchon, for instance, provides a rare example of an equation gag, which I risk straining the Guardian's typography to repeat: ∫ 1/cabin d(cabin) = log cabin + c = houseboat. This was the only calculus joke I'd ever seen until Matt Parker produced a better one at Nine Carols. Speaking of rates of flow (OK, it was flow of poo, d(poo)/dt – some things never fail), he admitted that this part of his material was a little derivative.

The rise of standup has changed everything. Not only do we now have standups who specialize in science, but several, such as Timandra Harkness and Helen Keen, are women, diluting the relentless blokeishness of much science humour. Some aim to be informative as well as funny. At the Bloomsbury you could watch Dr Hula (Richard Vranch) and his assistant demonstrate atomic theory and chemical bonding with hula hoops (more fun than it might sound).

As Ben Goldacre's readers know, good jokes often have serious intent. Perhaps the most notorious scientific example was not exactly a joke at all. Certainly, when in 1996 the physicist Alan Sokal got a spurious paper on "quantum hermeneutics" published in the journal of postmodern criticism, Social Text, the postmodernists weren't laughing. And Sokal himself was more intent on proving a point than making us giggle. Arguably funnier was the epilogue: in the early 2000s, a group of papers on quantum cosmology published in physics journals by the French brothers Igor and Grichka Bogdanov was so incomprehensible that this was rumoured to be the postmodernists' revenge – until the indignant Bogdanovs protested that they were perfectly serious.

But my favourite example of this sort of prank was a paper submitted by computer scientists David Mazières and Eddie Kohler to one of the "junk science" conferences that plague their field with spammed solicitations. The paper had a title, abstract, text, figures and captions that all consisted solely of the phrase "Get me off your fucking email list". Mazières was keen to present the paper at the conference, but was never told if it was accepted or not. Reporting the incident made me probably the first and only person to say "fucking" in the august pages of Nature – not, I admit, the most distinguished achievement, but we must take our glory where we can find it.