Oh you guys come on. You don't need all these cannons. Just always hike with someone else and carry a .22. You don't have to out run the bear, only your companion. And they won't be moving fast with a .22 in their foot.
The best thing to have is a gun. And to have that gun when you need it.
I mostly carry a .45 1911 in grizzly country, loaded with Buffalo Bore. I have a .44 mag and probably will continue carrying it on planned hikes. But it's getting heavier every year. The only time I've been really concerned was a grizzly that stalked us a little over a quarter mile back to our car near Big Fork, MT 4 summers ago. All I had was my Glock 19 with HST and my wife's key chain OC spray. We were only about a mile outside of town. I won't be complacent like that again.
Shotguns or rifles are the wise choice, but in many places social issues of hunting laws preclude long guns. Like Yellowstone, home to several attacks. Try walking around with a .44 on your chest or a shotgun in hand. The tourists will be calling 911 every two minutes. There you need a concealed handgun and spray.
I think bear spray should be the first line in most cases. But most actual attacks seem to occur without enough warning to get spray out and in use. And bears tend to run right through it or have a delayed reaction that provides time to attack.