At night, if I'm not expecting anyone, I just ignore the doorbell ringing. In this building, we all have pretty much the same doorbell sound, so I;m not even sure whose doorbell it is.
During the day, I look through the viewer which is part of the door. If I don't see anybody, I ask who it is. It's almost always a neighbor who is well-known to me.
The gun idea is part of what's wrong with America right now. Any trigger-happy would-be cowboy could easily shoot a kid selling Girl Scout cookies, a neighbor needing help, someone who accidentally got my mail delivered to them, or dozens of other innocent reasons they are there.
Middle of the night could mean they are drunk, mentally disturbed, or on drugs. Do they deserve to be murdered because they rang your doorbell?
I've written about this already, but it bears repeating. One time I was in the shower when I heard two men talking in my living room! Even if I had a gun, I doubt that I'd take it into the shower with me. And it was alarming, but totally innocent. It was our very nice building engineer who had gotten a call reporting that they thought there was a flood in my apartment, and the engineer and his assistant heard water running, rang the bell and got no answer, so they used their master key to get in. I just turned off the water and yelled, "Who's there?" and they apologetically ran out to the hallway.
I did learn from that to always bring my phone into the bathroom when I'm in the shower.