"what is more effective, a gun or bear spray?"
Do you want to kill or just discourage the bear? The answer to that question determines which instrument you must use. Spray does not kill; a bullet does not discourage a Grizzly - quite the contrary.
Whichever you use, you first have to know WHEN to use it and when not to. You also must be able to HIT the bear, and in the right spot, with it.
Assuming you can do both of the above while maintaining your cool as 600 pounds of furred fury with 4 inch claws and teeth is closing the distance between you two at 30 mph, it boils down to how close do you want to let the bear get before you take action.
Bear spray is limited to about 20 feet - assuming the wind direction and speed is optimal.
The gun reaches a lot further. This is a good thing because once you shoot a Grizzly, he'll keep coming until one of you is dead, so assume a comfortable firing position and just keep shooting until one of you goes down. You really do NOT want to shoot at a Grizzly unless you absolutely have to do so, because you WILL get his undivided attention. Note that if shooting a Black Bear, the odds are about 50:50 that he'll charge vs. run away.
After 2 years of ranching in Grizzly country, I would respectfully submit that a gun of proper caliber is far more effective than any bear spray.
Even more effective is knowing bear habits, signs, and their way of life. Then you can arrange your schedule to limit your potential exposure. Knowledge weighs nothing; bear spray is 17 ounces; a gun of sufficient caliber can easily weigh ten pounds. Which would you rather carry for several days or weeks?