After reviewing the studies that everyone cites for the effectiveness of bear spray versus handguns, I came to the following conclusions:
These studies are not really straight forward, and the narratives around them tend to be biased against firearms, for whatever reason. If you compare apples to apples, I think you'll agree that it's far less clear cut than many would have you believe.
A few differences I noticed are:
The most common studie(s) everyone cites are comparing apples and oranges, in which the bear spray group is measures only those people who successfully deployed (I mean, accessed, and used) their bear spray. The firearms group counts everyone carrying a gun, and includes those who were attacked but were unable to draw and aim under pressure. This is not a fair comparison, because neither is really "easier to do under pressure", and both can be overcome with training. Bear spray does of course have more of an area of affect, but it seems that a very large percentage of the failure of the firearms group was due to simply not being able to access their weapon under pressure, likely as a result of lack of training. There are similar cases among people who carry bear spray, of course, which, unless you've practiced accessing it and carry it somewhere accessible, will not be available under pressure. The lesson? No matter which you carry, make sure it's accessible, and that you have practiced accessing it under pressure, and whilst moving out offline and focusing on a threat. I've practiced this, and I can tell you: you learn a lot, very quickly. What you can do on the range while standing still and focusing on a non threatening target is totally different from something moving at you, and you yourself moving. Forget any kind of front pocket carry, as pockets will seal up the moment you sink your stance and move your feet, not to mention them being extremely hard to find by touch in the first place.
Two other impressions I was left with: It seems that bear spray is the better deterrent, but may not be as effective when the bear seriously intends / is committed to doing you harm. There are an alarming number of cases in which determined bears completely ignored the bear spray and killed their victims. Firearms, on the other hand, seem to be better in this situation, and, contrary to some opinion, have better stopping power. Even rather small handgun rounds have, in a very large number of cases, stopped Grizzly bears, provided the shots were well placed. The downside is mainly that handguns require more training and finesse, and if used incorrectly (where deterrents would be appropriate instead), may encourage a bear that could be deterred to kill you, and you really don't want that if it can be avoided.
So, which is better really isn't so clear cut to me. I'll try to find the studies that I'm mentioning later if I have time so people can compare the details and come to their own conclusions.
I do a lot of bushcrafting and hiking though, and carry neither. A hardwood walking stick and a hatchet are handy, serve other purposes, and in an absolute worse case scenario, give you a fighting chance. Avoidance and learning about bears, bear encounters, and how to avoid them, is probably much more important.
I'm not personally concerned so much with bears as I am wild boar, though -- especially here in Japan, where they are numerous. They're far more aggressive and unpredictable compared to bears, and are extremely dangerous.