It must be difficult to make a quirky, bittersweet high-school black comedy while standing in the shadow of “Juno” — one of the most successful (and rightfully so!) examples of the genre ever made. Had “Charlie Bartlett” been released a year, or even six months ago, perhaps it would have smaller shoes to fill. Or maybe it just wouldn’t be getting any attention at all.

The film centers on the title character (superbly played by Anton Yelchin), a troubled but idealistic teenager who has gotten kicked out of every private school he has ever attended. His mother (Hope Davis) is too absorbed with new-age psychobabble to figure out how to raise him, his father is out of the picture for reasons that slowly become evident and Charlie is left to the whims of public school and his own almost dangerously entrepreneurial spirit.

At first, Charlie is ridiculed by his public school peers for wearing a blazer and carrying an attaché — offenses that end in those standard-fare issues of high school torture that movies love to portray but that no one has actually witnessed. (Have you or anyone you know ever gotten a swirlie? And if Stanford kids aren’t the picked-on poindexters of high school movie lore, I don’t know who is.) But Charlie finally achieves the popularity he seeks by doling out psychotropic drugs to the lonely, alienated teens around him. Which, in high school, is just about everybody.

He also runs afoul of substance-abusing Principal Gardner (Robert Downey, Jr., brilliant as always) — in no small part by dating his daughter, Susan (the luminous Kat Dennings).

But don’t go thinking that “Bartlett” is just “Rushmore” on Ritalin: it straddles the line between comedy and drama, and it deals with serious issues — substance abuse, family dynamics, clinical depression — reasonably well before dashing to its inevitably hey-guys-life-is-awesome-because-high-school-doesn’t-last-forever last act.

“Charlie Bartlett” is a smart movie, but it isn’t a smart comedy. The movie makes a big deal of chronicling our flippant, pill-popping, highly insecure generation, then tries to fool our modern sushi-and-Red-Bull psyches with clunky, heavy, pot-roast comedy. It preaches that young people are lonely and more sophisticated than they are given credit for, then expects us to laugh at predictable nuggets of dramatic irony, menstrual blood and, not one, but two sequences of naked Ritalin dancing. The lowest point of the film’s humor comes with a character who plays Down’s Syndrome for comedy — did I miss something, or is this still in incredibly bad taste? — in a series of scenes that grow increasingly strained and unpleasant.

But for every questionable joke, there is a moment of quiet drama that works supremely well. Yelchin is impossible to take your eyes off of. His physical comedy is delightfully high-energy, and his every gesture contributes to a character who is likeable and authentic. If nothing else, this movie is a staggering recommendation for checking his complete filmography out of Green. (Start with “Alpha Dog.”)

The best scenes in the movie feature Yelchin squaring off against Robert Downey, Jr.: both men are dramatic powerhouses, and their rapport is tense and stunning. Their final stand-off at the movie’s climax manages to be both funny and deeply moving.

The other standout performance is Charlie’s bully-turned-business-partner Murphey Bivens (Tyler Hilton — not that Hilton, though), who begins the film as a rather one-note character but rapidly evolves to show surprising roundedness. He will steal your heart like he stole your bike.

This is a movie that leaves you thinking of other, better movies. The idea of a naïve teen struggling to find his place with a substance-abusing authority figure is compelling — but why not just watch “Wonder Boys,” which does all that with better writing? And still features Robert Downey, Jr. to boot.

But the superb ensemble performances are what ultimately save “Charlie Bartlett” from its clumsy, sometimes trite construction and comedic misfires. Although I didn’t walk out of the theatre with a satisfying, unified view of “Charlie” as a film, it is impossible not to leave a little in love with Charlie as character.