Matthew Broderick is now teetering on the verge of being dangerously typecast. Though he remains fitfully amiable as an actor, the 47-year-old thespian seems condemned, at this point, to playing the sad-sack, slightly corpulent, whiny middle-aged loser. It worked triumphantly in Election, impressively in You Can Count on Me -- and somewhat less memorably in Helen Hunt's Then She Found Me. In tyro director/scribe Josh Goldin's drama Wonderful World, a variation on this stock character returns -- this time, as in the Hunt movie, to satisfactory but not spectacular results. Wonderful World is a two-and-a-half-dimensional message movie, a gentle but kindly parable about the importance of selflessness and optimism in an increasingly dour and mean-spirited universe, hence the irony of the title. Broderick helps give the movie its extra half-dimension. He stars as Ben Singer, a gifted musician who once sustained a healthy career as a Raffi-like singer-songwriter-guitarist of children's tunes, but gave up that stock and trade to focus exclusively on instrumental guitar recordings. When his album flopped, he wound up supporting himself by proofreading documents for a large corporation. As the movie opens, his life is fairly miserable. Still reeling from a divorce and granted occasional visitation with his preteen daughter, who resents his glass-half-empty perspective, he clings to some semblance of pleasure via regular morning tokes. Then things begin to fall apart -- first when his daughter begins refusing to see him, then when a medical emergency arises involving the hospitalization of his Senegalese roommate and a crisis happens at work. And an additional subplot develops when the roommate's gorgeous sister, Khadi (Sanaa Lathan), flies in from Dakar to tend to her brother and ends up rooming with and romancing Ben. The question lingers: will Ben -- who has never stopped being a generally good and sweet-natured soul, but suffers from an oppressive pessimism and a sardonic, mordant attitude that draws little assaults from the world -- gain a sunny outlook and extend his gaze outside of himself? Any film with this sort of a trajectory is heading straight for trouble -- it risks falling into the dangerous trap of pedanticism. Goldin apparently underestimated this risk, because he compounds it with the inclusion of the gifted Philip Baker Hall, completely wasted here as a strange character called The Man -- a kind of amalgam of God and Ben Singer's conscience, who turns up during marijuana highs to recite stale platitudes to Ben in the form of little lectures. "It is easier to keep people in line by appealing to their worst impulses than to their best," The Man cautions. "How much of your life is your fault, and how much is the world's? That is your big question." As welcome as it is to see Hall in a film, the inclusion of The Man was a terribly disadvantageous idea; the story is strong enough that we can surmise Ben's "big question" from the surrounding events without being whacked on the head with it. Likewise, it was a poor idea to utilize Ben's ex-wife as an outlet for on-the-nose criticism of the character's weaknesses -- imperfections that we can easily infer without being told. Surprisingly, although those flaws work against the film, they don't quite destroy it. It bounces back -- just barely -- thanks to the persuasiveness of Broderick and the exotic, sensual Lathan. The offbeat humor that emerges from Ben's take-no-prisoners pessimism also helps tremendously, by giving the movie toughness and grit. Ben, for example, delivers a short but marvelous tell-off to another driver -- an obnoxious, gel-haired corporate type -- on what will happen when people like him overrun the world. On a similar note, later in the movie Ben puts a satirical spin on a Mr. Smith Goes to Washington-like speech in a courtroom that, as overloaded as it is with pessimistic observations and self-righteous indignation, is both desperate and dryly funny. One even senses that Goldin may have realized the benefit of this sort of ruefulness in Ben, for one of the final scenes has him telling The Man to "f--k off," even as the entire movie lunges toward a sunny, upbeat conclusion that threatens to completely negate its darker impulses. We might be tempted to sigh or gag as the film heads in this direction in lieu of going for the jugular with a dark and cynical ending, but it ekes out its optimism with a surprising amount of grace and restraint. To Goldin's credit, one of the chief sources of Ben's spiritual rebound emerges not from one of the stock sources of movie redemption that we might expect, but from an unusual, almost metaphysical occurrence in the third act, which lends the movie a much-needed dose of visual magic and wonder. It might stretch the film's logic just a bit, but it works because it stands opposed to the preachy, grandstanding conclusion that we have dreaded for the prior 70 minutes. We aren't told of the subsequent change in Ben by peripheral characters, but shown: the event prompts a magical transformation that we can directly witness in Ben's eyes and countenance -- he seems slightly newer, fresher, more vibrant, and the movie takes on a brighter tone overall. One only wishes that the entire film had been this subtle.