But Peter Farrelly (celebrated for virtually inventing, along with his brother Bobby, the modern gross-out movie: Dumb and Dumber, Kingpin, There's Something About Mary), is actually on his second novel - the first, Outside Providence, was completed a decade ago when Farrelly's Hollywood career was only just getting off the ground.

Unlike his book-writing peers, Farrelly has steered conspicuously clear of the brainy end of the film-making spectrum - the brothers' debut, Dumb and Dumber, was roundly accused of precipitating the intellectual decline of the entire western hemisphere. Here Farrelly shows that you have to be truly smart to appear that dumb. In stark contrast to his primary-colour, elbow-in-the-ribs, head-down-the-toilet film-making, Farrelly writes a low-key, melancholic prose, wandering from vignette to vignette with an oblique but assured narrative drive.

He has certainly taken to heart the dictum that you should write about what you know. Outside Providence fed directly from his experiences as a teenager in Rhode Island; The Comedy Writer details the uncertainties of an aspiring scriptwriter in Los Angeles. Chronicles of the Hollywood underbelly - both true and fictional - are meat and drink to the reading public these days, and Farrelly's contribution to the genre comes over like a cross between Rob Long's Conversations with My Agent and Bruce Wagner's sorely overlooked Force Majeure; a mix of couldn't-make-it-up powerplays and the wretchedness to which industry bottom-feeders inevitably succumb.

There is the genuine tang of authenticity in Farrelly's account of his protagonist, Henry Halloran, attempting to negotiate the prickly worlds of agency representation, production deals and TV pitch sessions. In real life, the Farrelly brothers offered a storyline for Seinfeld that later became the celebrated episode "The Virgin" (the one in which Jerry's girlfriend won't have sex with him). The whole sorry incident is reproduced here in all its ambiguous humiliations - with Larry David and Jerry Seinfeld mentioned by name.

Farrelly also recounts a particularly piquant incident which, whether true or not, perfectly distills the Faustian pact Hollywood demands of its inmates - Halloran is required, by a powerful producer with whom he has just lunched, to perjure himself in regard to a road-traffic accident in which his benefactor is clearly culpable. Morality, as ever, is the victim of showbiz aspirations.

Farrelly's novel is, however, considerably more than another unspooling of life in the Hollywood shark-tank. Lacing together the anecdotes about celebrity spotting and development meetings is a subtly observed, genuinely funny and cheerfully obscene study of a 33-year-old man in emotional crisis.

Halloran heads out west in the throes of a relationship breakdown (his "spec" script is called How I Won Her Back); once in LA, he has to contend with a stream of rejections from one cantilevered Hollywood woman after another, a rapidly burgeoning hypochondria ("I haven't had many men ask for mammograms recently") and, most significantly, an unwelcome entanglement with the sister of a woman he watches commit suicide three days after he arrives.

Halloran's reaction to this suicide - another item, apparently, from the Farrelly scrapbook - is the reader's way into his convoluted inner life. His is an uneasy participation in the Hollywood treadmill: he observes the unreflecting hedonism around him with an eager but appalled eye. And his scriptwriting, it seems, is his method of filtering his experience, of mediating his own web of human relationships.

There's also a gallery of hilarious modern grotesques - from the wannabe player who adopts a Jewish name ("Herb Silverman") to gain studio-executive credibility to the near-demented movie-maker who is hooked by Halloran's serial-killer pitch "The Ice Cream Man" (tagline: No More Mr Softee). The Comedy Writer is a comic achievement of considerable proportions; frighteningly confessional in places, but run through with remorselessly self-deprecating humour. In his unabashed recycling of his most intimate experiences, Farrelly offers himself as something of a West Coast Philip Roth.