Charlize Theron in Tully

When fledgling screenwriter Diablo Cody was nominated for an Academy Award in 2008, feature writers across the U.S. clicked their heels to learn that she’d once worked as a pole dancer. Her 2005 memoir Candy Girl: A Year in the Life of an Unlikely Stripper provided an easy angle on Cody and, combined with her irreverent sense of humor, helped turn her into a media darling. Inevitably she’s become an object of fun, parodied as an empty vessel on Saturday Night Live and skewered in Bobcat Goldthwait’s movie God Bless America as “the only stripper with too much self-esteem.” Very few screenwriters become even minor celebrities, and one might argue that Cody’s experience has colored her writing; two of her lesser screenplays, for Young Adult (2011) and Ricki and the Flash (2015), deal with women boxed in by their wild reputations.

Despite Cody’s image as a libertine, her two smartest movies—Juno (2007), which won her the Oscar, and Tully, which opened last weekend—both focus on a decidedly more conservative topic, the emotional journey of motherhood. Directed by Jason Reitman, Juno (2007) told the story of a pregnant 16-year-old (Ellen Page) who agrees to give her child up for adoption to a wealthy thirtysomething couple but then gets too intimately involved in their lives for her own good. Tully, also directed by Reitman, unfolds from the perspective of a wife and mother (Charlize Theron) whose postpartum depression following the birth of her third child is alleviated by her growing friendship with a free-spirited, 26-year-old night nanny. In addition to the films’ common concerns, each is driven by a generation gap between the characters, which seems only natural for a writer so concerned with the waning of youth.

When Juno was released, conservatives attacked it for normalizing teen pregnancy, yet over the course of the movie, the cocky title character (Page) learns how messy and challenging adulthood can be. Pregnant by a classmate and unwilling to abort the baby, she answers an adoption ad and strikes up a legal agreement with Vanessa (Jennifer Garner), a professional woman who longs for a child, and her husband, Mark (Jason Bateman), a frustrated rock musician now writing commercial jingles. At one point Juno thoughtlessly tells Vanessa how lucky she is not to be pregnant, and the pained expression on the older woman’s face could be Garner’s single best screen moment. Juno bonds with Mark—an overgrown adolescent with his guitars, comic books, and horror videos—and begins dropping in at the couple’s home. Eventually she discovers that their picture-perfect marriage isn’t as stable as it appears, and Mark stuns them both with his decision to divorce Vanessa and give his performing career one last shot. As it turns out, he envies Juno’s youth as badly as Vanessa envies her pregnancy.

Tully also involves a young woman sharing a baby with an older one, though in this case the older woman is the protagonist. Once an aspiring writer, Marlo (Theron) is now hugely pregnant with her third child and exasperated beyond endurance by her second, Jonah, whose kindergarten teachers are complaining about his neurotic meltdowns in class. The birth wipes Marlo out, and her wealthy brother (Mark Duplass), alluding to an earlier episode of postpartum depression, insists on hiring her a highly credentialed night nanny who will mind the baby and bring it to mom only to nurse. Expecting an older woman, Marlo is startled by the arrival of Tully (Mackenzie Davis), a skinny, beatific young woman in a belly T-shirt. When Marlo asks Tully her age, she replies, “I’m older than I look.” But she turns out to be well schooled in infant care, and her cooing attention to the baby allows Marlo, who looks like a train wreck, to begin sleeping more peacefully through the night.

Tully explains that her job is to care for the mother as well as the child, and as the story progresses, she becomes Marlo’s friend, comforter, and life coach. She cleans the house while the family is asleep, and after Marlo makes a chance remark that good mothers send their children to school with cupcakes, Tully leaves a batch for her to find in the morning. The two women begin drinking and chatting together in the wee hours, and Tully treats Marlo to a makeup party. “You can’t be a good mother unless you practice self-care,” reasons Tully. Eventually the nanny persuades Marlo to leave her infant with her steady-Eddie husband, Drew (Ron Livingston), and embark on a wild night out to her old neighborhood in Brooklyn, where the two women get hammered at a club and rock out to a deafening band.

Like the husband in Juno, Marlo sees in her lithe young friend a sense of freedom and possibility she has lost. “If I had a dream that didn’t come true, at least I could be pissed off at the world,” she tells Tully. “I’m pissed off at myself.” One of the most humbling scenes in a movie full of them shows the tubby Marlo (Theron gained 50 pounds to play the role) huffing and puffing along a footpath as a fit college student passes her by; incensed, Marlo steps up her pace and manages to pass the student before tumbling to the ground. “It’s milk,” she explains to the student, who stares in disgust at the twin wet spots on her shirt. Marlo’s nocturnal adventure with Tully provides a temporary thrill, but as it wears on into morning, Marlo realizes she can’t be young again. “Your 20s are great,” she warns Tully, “but then your 30s come around the corner like a garbage truck at 5 AM.”

Tully may not win Cody another Oscar, but it’s much better written than Juno, reflecting a decade of practical experience in the screenwriting trade. As a character, Juno functions mainly as a one-liner machine, unloading every comic idea Cody can think up, and Juno’s father (J.K. Simmons) and stepmother (Allison Janney) have a way with words too. Even the shopkeeper who sells Juno pregnancy tests (Rainn Wilson) dispenses such well-polished quips as “What’s the prognosis, fertile Myrtle?” After a while the whole movie begins to feel a little arch. Tully has just as many laughs or more, but they tend to grow out of the action, particularly the physical punishment Marlo endures in bearing a child and caring for it afterward. The story has a philosophical dimension, but fewer things need to be spoken out loud. This stylistic maturity is typical of writers, who tend to improve well into old age and long after most rock stars and strippers.