a firearm is way better imo. you can prevent AND permanently solve the problem from happening again both at the same time.
And before you say deterrence doesn't work, just put a sign outside proudly proclaiming your residence to be a gun free zone. Go for it!
If I put that sign in front of my house, nothing would happen. The implication that somehow I would suddenly be robbed left and right I don’t think holds that much water to begin with but especially doesn’t make sense in many places people live, like a small town like mine. Just going to confuse the neighbors.
If they still continue to break in after seeing you are armed with a firearm, you can just simply just shoot them once they get inside as your life was in danger and you also solve that from ever happening again from that person.