Sex addiction is certainly the topic of the day among filmmakers, but they’ve taken notably different approaches to it. Steve McQueen gave it arty, explicit treatment in “Shame.” More recently, Stuart Blumberg chose the earnest, didactic route in “Thanks for Sharing.” And now Joseph Gordon-Levitt, in his first stint as writer and director as well as star, gives it a Judd Apatow-ish spin. As it turns out, though, that’s not a bad way to go; “Don Jon” is undoubtedly raunchy, but it’s also pretty funny.

Gordon-Levitt, so pumped up from his early days as scrawny Tommy on “Third Rock from the Sun” that you have to admit he’d make a perfectly credible Dick Grayson, casts himself as Jon Martello, a studly fellow constantly on the make who spends his nights in clubs debating with his pals Bobby (Rob Brown) and Danny (Jeremy Luke) which is the best girl in the room, and then taking home the one he’s set his eye on for a ride in the sack. But even after a satisfying encounter—he grades his conquests as they go—he admits that he prefers online porn and self-satisfaction to the real thing. He is, in fact, an addict, though he’ll protest that he’s only doing what every guy does. His only other interests, he admits, are his physique, his muscle car, and keeping his apartment clean and tidy. Jon, it appears, is hardly the brightest bulb on the block.

Jon’s failure to find a girl to settle down with irks his mother Angela (Glenne Headley) to no end, but doesn’t particularly surprise his father Jon Sr. (Tony Danza), a macho boor who has little room in his brain except for football games. The sessions Jon spends with them over Sunday dinner, while his bored sister Monica (Brie Larson) doodles incessantly on her smart phone, are examples of familial hell writ comically large.

Things change for Jon, though, when he goes head over heels for Barbara (Scarlett Johansson), who demands something more serious. The two may not have much in common—he has difficulty tolerating it when she drags him to a chick flick (a cheeky send-up of the genre called “Special Someone,” from which we see clips with Channing Tatum and Anne Hathaway)—but they finally wind up at his place. Unfortunately, she catches him at his laptop after they spend the night together and explodes. But he defuses the situation by lying that the porn video he was watching was a joke e-mailed by one of his boys. That placates her.

Of course, Jon hasn’t actually given up his pastime, which he confesses each week to his parish priest after Sunday Mass and receives hilariously nonchalant absolution. He does make other concessions to Barbara, however, like attending a night class to improve him as husband material, and he even takes her to meet his folks—Angela falls in love with her as a prospective daughter-in-law, and Jon Sr. is amazed that his son has landed such a luscious-looking catch. But at school he meets a peculiar older classmate, Esther (Julianne Moore), a highly emotional woman he gradually develops an oddball bond with. It turns out that there’s a reason behind her obvious emotional fragility, and Jon begins to learn from her about genuine human relationships just as Barbara discovers that his porn-centered practices have continued unabated.

“Don Jon” doesn’t wind up anywhere you wouldn’t expect: Jon matures, at least a bit, and moves past both his womanizing and his dependence on self-gratification. But it has considerable fun getting there, and offers some quirky twists, especially in the material with Moore. As a writer Gordon-Levitt plays it pretty safe by situating the story in “Jersey Shore” territory where the characters are mostly stereotypes we can laugh at even before they do anything remarkable. But he compensates with amusing sidelines to the plot—Catholics will find Jon’s periodic sessions in the confessional only slightly over-the-top, with a capper that’s hilarious—and by directing with a confidence and brashness that mirror the swaggering character he’s playing. There’s nothing cinematically timid about the movie—it rushes ahead with excited montages, explicit sex scenes, raucous dialogue and a general air of abandon. That doesn’t mean it’s not all carefully calculated, of course, for which not only Gordon-Levitt but also cinematographer Thomas Kloss and editor Lauren Zuckerman must be given credit. And the high-energy feel is abetted by Nathan Johnson’s background score.

The writer-director also anchors the movie with a charismatic star turn as Jon. But he also draws broad but effective turns from Johansson and Danza, who get their share of laughs, and a touchingly fragile one from Moore. The rest of the cast add some nice grace touches to their characters, with Larson in particular copping an especially important, if brief, moment of wisdom toward the close.

“Don Jon” may offend some viewers with its in-your-face comic attitude toward a pretty explosive subject, but in the end it’s far more mature and insightful than the frat-boy gross-out farces that come down the pike every week or so nowadays. With this movie Gordon-Levitt has shown himself a triple threat, and it makes one look forward to more multi-hyphenate efforts from him.