Dope opens by showing the dictionary-style definitions of the movie’s title—essentially drugs, dumbass, and cool. But the real keyword for Rick Famuyiwa’s breakout Sundance comedy is on the posters: “It’s hard out here for a geek.” “Geek” is how the hero, Malcolm, is labeled by himself and the people around him. Which might prompt some skepticism. Are we still making movies about jocks vs. nerds? Didn’t dissing geeks go out in 1985? I remember arriving at high school a certified geek and being surprised that the coming-of-age movies I’d seen had greatly exaggerated the teenage caste system—no one was stuffing anyone in lockers for knowing the order of operations.

A few minutes into Dope, though, and you realize that the rules are slightly different for this particular entry into the high-school movies tradition. Yes, like so many other films, it’s about uncool kids falling in with the cool kids and then having their values tested. Yes, Malcolm and his best friends Diggy and Jib worry about bullies, prom dates, and getting into college. At first, it might seem like the movie’s novelty is merely because of racial transposition—maybe it’s a black Breakfast Club, where the geeks’ geekdom mostly comes from their love of ‘90s hip hop and “white shit.”

But the locker-lined hallways depicted in the film are fundamentally different from the ones populating John Hughes films, Superbad, and Mean Girls, less because of the color shift than because of what this particular color shift means in the real world. Being a geek here isn’t just about being obsessed with unpopular stuff; it’s about opting out from cultural expectations as a way to try and survive. Early in the film, it’s established that in the low-income neighborhood of “the Bottoms” in Inglewood, the drug trade is an inescapable part of the social scene, and anyone can be killed for being in the wrong place at the wrong time. This isn’t presented as a big, dramatic stakes-raiser, but rather as a simple fact, as it is for so many Americans. And as with so many simple, horrible facts, it becomes a source of grim humor. A student gets shot during a robbery at a burger shack, and the real tragedy, the narrator says, is that he was seconds away from defeating a level on his Game Boy.

Despite the armor of geekdom—which makes him either invisible or a joke to most of the people around him—Malcolm unwittingly ends up with a stash of molly and must figure out how to sell it, all the while trying to land the cute girl down the street and mail his application to Harvard. In the process, he tiptoes through gang war zones, allies with a rich white stoner who wants permission to use the N-word, nearly loses his virginity to a character played by the model Chanel Iman, and has the strangest college-admissions interview of all time. If that all sounds like mere hijinks, remember: The guys of 21 Jump Street might get chased by drug dealers or the kids of Dazed & Confused might get roughed up by upperclassmen, but you never really worry anyone’s going to die. Here, as is the case with the other cinematic traditions Dope pulls heavily from—the gangster-narratives of the ‘90s like Boys N the Hood and Juice—bloodshed’s plenty likely. This means you watch all the hijinks unfold with a heightened level of attention, a queasy and bracing mix of amusement and dread.

It helps that the writing is hilarious and dense, delivered with ace comic performances and energetic, fearless style. The 20-year-old Shameik Moore plays Malcolm, emanating natural charisma while also mumbling and stumbling as is appropriate for his character. His pal Diggy, played by Kiersey Clemons, nearly steals the movie as a clever but no-nonsense lesbian, and the rapper A$AP Rocky brings a surprising amount of easy wit as well as danger to his performance as the drug dealer Dom. The pacing’s uneven—contemplative one minute, frenetic the next—but deliberately so, and the effect is almost musical.

It should be obvious by now that in addition to revitalizing a genre, Dope has a social message about being true to yourself and about transcending one’s circumstances without leaving them behind or condemning them. And it joyfully humanizes a group of people too often left to grim stereotyping in pop culture. Forest Whitaker’s hammy narration, and a recitation of Malcolm’s college admission essay toward the end of the movie, puts too fine a point on the film’s politics. But whenever the energy starts to flag or it tempts preachiness, Dope quickly recovers, often with help the soundtrack—a mix of classic and contemporary hip hop plus catchy post-punk from the geeks’ band Awreeoh, whose songs are ghostwritten by the film’s co-executive producer Pharrell. One of Awreeoh’s earworms is called “Can’t Bring Me Down,” and if that title sounds trite, by the end of the film, in the context of these geeks’ lives and the reality they represent, it seems anything but.