It’s easy to see why “The Perks of Being a Wallflower,” Stephen Chbosky’s 1999 coming-of-age novel about a troubled high school freshman, was a massive hit with adolescent readers (and more than a few adults). Without condescending or relying on trite platitudes, the story reassures teens that regardless of the flaws they have or the mistakes they’ve made, they have unlimited potential. Everybody is messed up somehow, but we can all still love and be loved.

That sweet message, wrapped in a package that’s funny, melancholy, and oh-so-relatable, comes across vividly in the movie version — as well it should, since Chbosky adapted and directed it himself. Set in 1991, when mixtapes were still an important means of communication, the story concerns a quiet, intelligent Pittsburgh boy named Charlie (Logan Lerman) who enters high school nervous about his future because of his past. He had some emotional problems a while back, the result of some prior traumas, and he feels isolated, awkward. He connects with his English teacher (Paul Rudd) on the first day of school, but also realizes that if your only friend is your English teacher, well…

Soon Charlie is befriended by two seniors: Patrick (Ezra Miller), a free-spirited mischief-maker, and Sam (Emma Watson), his likeminded stepsister. Between “Rocky Horror Picture Show” screenings and the usual teen parties and many nights of driving around listening to the radio, Patrick and Sam integrate Charlie into their circle of friends, which includes belligerent Buddhist Mary Elizabeth (Mae Whitman) and others. These aren’t the “popular” kids, but they’re not outcasts either. They’re the ones who have found their kindred spirits and are comfortable with who they are — or as comfortable as any high school student is, anyway.

Which is sorta the point. Charlie admires his new friends for being so adept at navigating adolescence, but of course it’s not as easy for them as it looks, and it has taken some work to get where they are. “Do you ever think that if people really knew how crazy you were, they would never talk to you?” Charlie asks Sam, fearing he’s the only one. Her reply, delivered by Emma Watson with heart-wrenching tenderness and sympathy: “All the time.” Sam has a reputation, not entirely undeserved, for being slutty. Patrick is gay — an emotional minefield unto itself, complicated by his relationship with a closeted football player (Johnny Simmons). What Charlie learns over the course of the school year is that if his friends can survive, so can he. To use an already overused but no less comforting expression: it gets better.

The cherubic Logan Lerman, who is 20 and looks 15, has an unassuming innocence about him that probably makes it scientifically impossible not to root for Charlie. (Aw, who could ever pick on a kid like this? He’s adorable!) Watson, in her first major post-“Harry Potter” role, proves there’s more to her than Hermione, bringing heart and compassion to Sam. Perhaps best of all, though, is Ezra Miller, who was in danger of being typecast as Creepy Teenager (“We Need to Talk About Kevin,”“City Island”) but is marvelously engaging and authentic here as the likable, smart-mouthed Patrick.

Certain elements of Charlie’s backstory aren’t explored as fully as they might have been, and the narrative device of having him tell his tale through a series of letters to an unnamed person, which worked in the book, feels precious onscreen. But for the most part, and despite some bumps, Chbosky expertly brings his heartfelt novel to life. It’s been a while since a movie captured so colorfully the comedy, tragedy, angst, and exuberance of adolescence.