A dog is an audible warning before the fact and may scare off thieves/robbers before an attempt. A gun is in the best of all cases helpful once the thief or robber has already decided to act.
That's why I have a solenoid triggered rifle in my backyard that shoots off a round every two minutes. It used to be full auto 24/7, but ammo got expensive :(