Among the self defense weapons stun gun is one that does not rely on inflicting pains or injuries to the attacker. Rather it performs its task basing on the muscular and neural systems of the intruder. Just three to five seconds contact with the stun gun can completely take control of the muscular and neural systems of the attacker and immobilize him for several minutes. The contact causes loss of muscular balance and disorientation. By the time the attacker recovers from the impact, that would be five to ten minutes depending on the period of contact, you will be well placed to take other defensive actions like tying him with ropes, calling the police or seeking help from others.
Stun guns may be considered better than the pepper foam or traditional weapons like the hand held spanner or the folding knives because it gives result on immediate contact unlike the other weapons. True, the pepper spray will also immobilize the intruder for some time but it gives pain and the man may be writhing making it impossible taking other precautionary measure like tying him up.
When you are using a mace pepper spray you may have to be concerned about the quantity of spray available and the device may dry up. This is not the case with stun guns since repeated firing will not damage it.