10,000: 1 kill shot with a charging bear with a 9mm. Feel lucky? Bear spray is your best option
If you're in a developed campground, sure, bear spray is fine - you're usually going to have some warning, either from other campers or just by looking around - the bear wants what's in your cooler or on the grill, not you. But in that case, unless it's an exceptionally hungry bear, a crowd of people banging on pots and pans will usually suffice (otherwise known as the sweet serenade of a Yosemite Valley evening). In the bush? Hell no, especially not if you're traveling alone or in a pair, in August/September when bear are eating everything they can put their paws on to fatten up for winter. That's when and how most predatory bear attacks occur.
Bear spray has the potential to incapacitate you and not the bear if deployed incorrectly, and may be utterly ineffective if there's more than a mild breeze blowing the wrong way when the bear charges. If you've ever been in the military and had the good fortune to experience tear gas in the course of chemical warfare training, let me just say it makes touching your wee-wee after cutting up habanero's feel like happy fun time, but tear gas wears off faster because pepper spray is oil-based and doesn't wash off easily with water. If you accidentally get a face full of bear spray while he's coming right at you, you'll be one spicy meatball for Mr. Bear.
Good friends of mine were bluff charged twice by a young Grizz feeding on berries in Glacier NP - the second time, the friend of mine carrying the bear spray deployed his spray, but the wind took the spray stream away from the bear and some of the finer mist blew back in his girlfriend's face. It was enough to sting and make all of her facial orifices run like a faucet, but she could hike out. The rangers told them they see more injuries due to bear spray than they see bears deterred by it - canisters being activated inside a tent by accident, people clipping them to their packs by the safety ring like a grenade pin and then knocking it off, and accidentally pulling the trigger when they retrieve it, etc. Sure, a firearm has the potential to cause unintended injury or death as well, but a firearm in trained hands is less prone to wind effects at ranges under 20 yards, which is where either will be deployed against a threatening bear.
Large caliber, short-barreled firearms do the trick. Anything less than a .454 is for 2-legged predators or hunting things with antlers.