John Scalzi is an unrepentant four-hankie sentimentalist, but at least he's funny when he's doing it. Redshirts shows the popular internet raconteur diving about as deeply as he can into his metacomedy phase, which he began in earnest with his uproarious short story, "The Shadow War of the Night Dragons," an epic fantasy parody that became its own punch line in awesome fashion by landing a Hugo nomination. There are times I wonder how Scalzi might have handled a second career, say, as a senator or a hostage negotiator. The world might still be a roiling pit of chaos and disorder, but we'd be chuckling a little more as it burned.

Redshirts explores the same premise, roughly, as Joss Whedon and Drew Goddard's 2011 film The Cabin in the Woods: a thoroughly self-aware dismantling of genre tropes, bitingly funny but not without considerable affection for all it skewers. In Scalzi's case, it's those of Star Trek and the legacy of television SF Trek bequeathed. But the book is also very much a love letter to the craft of writing itself. True, there's little on Earth more self-indulgent than writers writing about writers and writing. But if you know better than to take yourself all that seriously ("Filled with existential ennui about your place in the universe?" asks Scalzi's screenwriter Nick Weinstein. "Get over yourself."), then such stories can be a rich vein to plunder.

We open in the 24th century as Ensign Andrew Dahl is beginning his assignment aboard the USS Intrepid, the flagship of the Universal Union fleet. Almost immediately he notices that it's a very peculiar ship indeed. The crew do everything in their power to duck the attention of the bridge crew: Captain Abernathy, the science officer, the chief engineer... indeed, the very officers who lead away teams. For some reason, on away teams, someone usually always dies. And it's never the officers.

Dahl and his fellow ensigns soon learn the impossible: that they and their ship are fictional characters, the product of an early 21st century television show, and things happen that make no sense because everyone's actions are dictated by a Narrative. It would be unfortunate enough that they are living in a television show, but it would appear theirs is an especially bad show. Knowing that their insignificant characters are sure to be "written out" fairly soon, Dahl and the others must find a way into the universe where the show is actually produced, to convince the writers and producer to spare their lives.

There are other writers and stories that have gone meta in similar ways, exploring the blurring of lines between fantasy and reality, or the relationships between creator and created, or creator and audience. The novels of Jasper Fforde are an example, as are such films as 8½, Stranger Than Fiction, The Truman Show, and In the Mouth of Madness. Scalzi returns to his favorite standbys, love and family, to which he brings a degree of sentimentality that (depending on your tastes) either stops just short of the line of mawkishness and bathos, or gleefully does a running long jump right over it and keeps going.

For my money, he stays well within acceptable boundaries, again, because his self-effacing humor comes first. Redshirts features some of the funniest passages he's written (particularly those blasting lazy writing and plot devices on bad SF TV shows). The book's heartfelt moments come in three unusual codas to the main story, that on first blush seem like nothing more than the purest gratuitous self-indulgence. As you read them, it becomes clearer why Scalzi felt he had to write them. The biggest epiphany experienced by Nick Weinstein, head writer for the awful show The Chronicles of the Intrepid (one strike for plausibility: I don't see a show with a title that unwieldy and clunky running six seasons), is that the minor characters he thoughtlessly kills are, in their own universe, real people with lives and hopes and loves. To a writer deeply passionate about the worlds he or she creates, the characters who move through that world should be almost achingly real to you. They will certainly become that real to your world's most dedicated fans. This is where the most impassioned subcultures of fandom — fanfic, cosplay and such — are born. And so in ending his novel, Scalzi takes three of its own most minor characters and acknowledges them as fully realized people, allowing us to witness the impact of his story on their lives in a way that brings touching closure to the whole affair.

SF might not be the genre you think of when it comes to "you'll laugh, you'll cry" entertainment. But if we must have stories like that, I'm happy to have John Scalzi be the guy writing them. Just as long as he remembers to throw in a few ice sharks and Borgovian Land Worms.