This video has been posted in here before and it's an hour and seventeen minutes of straight talk about going into bear country.
[video=youtube;PExlT-5VU-Y]https://www.youtube.com/watch?v=PExlT-5VU-Y&feature=youtu.be[/video]
Yeah, that's a good video. These people have tested a lot of this stuff. In terms of physics, well, a gun shoots a very small projectile along a linear path while the spray puts up a very large area of effect. Sure, the bullet does huge damage, but unless you are extremely precise during that intense situation you may only anger the bear.
Of course, you need quick access to whichever weapon you choose. Best case would be to deploy the spray at range, 50 yards or so, and then have a shotgun backup if for some reason the spray does not work and the bear gets in close range. In a surprise scenario you may not have time for either, or it may simply escalate the situation. Then your experience and ability to react properly is best, along with a road/bear flare as backup.
Some will laugh, but the most effective in tests with grizzlies was actually a large piece of plywood. This acts much the same way as an umbrella against a running dog, all but the trained dogs will back off or become scared by an opening umbrella (dogs and bears are closely related). I mention this because it is very similar to how the spray works, it is unexpected and very confusing to animals who never see other animals fight in this way. In a group situation where you cannot carry weapons, having one person with an umbrella may actually be one of the most effective defenses, as counterintuitive and absurd as some will see this suggestion (I wouldn't recommend it on your own, carry spray, a flare, and a bear bat if you're in an area which prohibits weapons. In a group you are best off with a combination of spray and bear/shotguns, along with the ability to stay calm.).
Another reason why the spray works is that the bear most likely responds to it as he would a skunk, 'Sure, I may win the fight but I may lose substantial food or be attacked in the coming months.' Flares also work, and there is a company selling 'bear flares' now.
A smudge pot with punky wood and tinder fungus will essentially act like a long-burning flare or spray. Could be very useful in berry country.