Joseph Gordon-Levitt and Seth Rogen play to their strengths in the comedic story of a twentysomething stricken with cancer that rings true despite the odds.

As its title unintentionally indicates, "50/50" walks a very tricky line. As a comedy about a young man with cancer, it needs to be serious enough to be real as well as light enough to be funny. Though it falls off the wagon at times, it maintains its balance remarkably well.

But the key element in "50/50" is the screenplay by Will Reiser, a young writer who, as has been widely reported, was inspired by his own experience as a twentysomething diagnosed with a rare type of cancer.

Reiser discourages viewing the result as autobiographical (unlike character Adam Lerner, the writer did not undergo chemotherapy before his complex surgery), but the texture of his experience ensures that the film will have as much reality as the genre can handle.

Though he was a last-minute replacement for a departing James McAvoy, Gordon-Levitt could not be a better choice to play protagonist Adam. Known for roles in films as diverse as "Inception" and "(500) Days of Summer," the actor can play sensitive without drifting into needy, has an easy way with humor and is expert at getting audiences to identify with his predicament.

When the 27-year-old Adam, a nervous type who works for public radio in Seattle, finds out that the mysterious pains in his back come from a malignant tumor growing by his spinal column, he is understandably disbelieving. When he's told his chances of surviving are 50-50, he is aghast, but best friend and co-worker Kyle sees things differently. "If you were a casino game," he insists, "you'd have the best odds."

Kyle is played by Rogen (a real-life friend of screenwriter Reiser) and, in typical profane Rogen fashion, his character is always going to be brasher, louder and more out of control than polite society would like. Who else, for instance, would think of using his friend's cancer as a way to pick up women? Yet there is finally a guilelessness about Kyle, a kind of crackpot innocence, that makes us happy he is around.

The actresses playing the key women in Adam's life (casting was done by Francine Maisler, who did "Moneyball") also hit the right notes.

Met first is Rachael, an ambitious artist who is Adam's girlfriend. Beautifully portrayed by Howard (who similarly devoured the part of the evil Hilly Holbrook in "The Help"), Rachael does not seem the "through sickness and health" type, but she insists she is, and even presents Adam with a canine companion (a greyhound named Skeletor who looks like death warmed over) as a sign that she has his best interests at heart.

Also on Adam's team, though he doesn't always think so, is Katherine (Kendrick), his hospital-assigned supportive care therapist. So newly minted at the job that Adam is but her third client, Katherine wants to do the right thing, but her inexperience is not her friend. Kendrick, Oscar-nominated for "Up in the Air," brings a combination of precise intelligence and sweet-natured screwball wackiness to a part that benefits from all of her abilities.

Because it is a comedy, "50/50" isn't intent on showing all the bad sides of a serious illness: Hospital personnel are invariably pleasant here and no one has to wait too long in an uncomfortable waiting room.

But, unusual for a comedy, "50/50" doesn't allow the humor to stray too far from the pain. We see the damage that fear, rage and chemotherapy do to Adam's life, and we are not allowed to forget that cancer is not just the disease-of-the-week but something that actually kills people.

Not everything in "50/50" is as successful as its best moments. Anjelica Huston overdoes it as Adam's mother, and making his father an Alzheimer's sufferer seems excessive as well. But though its mixing of tones and intentions may sound cloying on paper, having all members of the creative team on the same page about what they were after and how they were going to get it has helped enormously.