It's not a perfect solution but it's also not believable that what's stopping people from committing violence is the law and not the violence itself. If you're willing to commit premeditated violence, you're already far beyond the influence of the law.
If someone carjacks a car they are willing to accept the risk that the person they're robbing may have a gun. They are literally willing to put their life at risk, something only someone with nothing to lose would do. Do think maybe getting caught by the police and spending 10 years in prison is as big of a threat to this person as being shot and killed (a risk they've already decided to take)?