Yes, a trained martial artist facing a loaded gun doesn't have a favorable slot in an actuarial table. While most styles spend some time training gun disarms and similar situations, those situations generally assume an untrained assailant using their weapon in fairly stupid ways, such as thrusting his pistol against your body or pointing it at you within arms reach. It is also assumes that the assailant isn't interested in immediately killing his victim, perhaps because he wants to collect money, or enjoy intimidating his victim. If any of these assumption proves false, it is unlikely that the unarmed martial artist will survive the encounter.
But it's a mistake to think that this situation is the result of "modern weapons", unless by "modern" you are referring to the last sixty-four thousand years (when we have the first evidence of bow and arrow technology). The Boxer Rebellion at the end of the nineteenth century contained people who believed that their martial arts would provide them with immunity to foreign guns. This assumption was rapidly disproved. Nor would a hypothetical unarmed karate practitioner have fared particularly well against a roman legionary in the second century, armed with two javelins, a short sword and dagger. There will always be extraordinary exceptions, such as when the swordsman Tesshu encountered an armed hunter. The hunter noted that Tesshu's skills were useless against a gun. Tesshu emitted a blood-curdling scream and charged straight at the hunter, who dropped his gun in fright and ran away. I like this story, and enjoy re-telling it. But I always remind myself that this is the exception, not the rule.
So if martial arts don't guarantee victory against the trained, armed assailant, why spend the time learning them? The first point to make is that many, possibly most, encounters are not against trained, armed assailants. They involve the guy in the bar who is angry at life and wants to pick a fight, the bully in high school trying to be macho, or even the drunken uncle at a wedding who acts out and needs to be subdued before he can hurt anybody, including himself.
More importantly, martial arts are about preparing for the little victories in life, that go unremarked, are never noticed by anybody else, and yet make all the difference in the world:
• A man, possibly a purse snatcher, walking down a sidewalk in New York City, collides with a woman, probably with the intent of knocking her down. She is knocked backwards in her surprise, but automatically lowers her center of gravity and lands in a defensive karate stance. The man hurries on his way, looking for an easier target.
• A project manager sits in a difficult business meeting. Tempers flare, accusations are made, pushing the line that separates appropriate from inappropriate behavior. The manager takes a deep breath, reminding himself that he spent all last evening with a group of martial artists trying to knock him to the ground, and he succeeded in staying upright only by staying calm and not wasting his energy. He proceeds to lay out an objective case for what he thinks needs to be done, and moves the focus of the meeting in a more productive direction.
• A student, studying for an important exam, gets tired and frustrated and thinks about calling it quits. But she remembers the discipline she learned doing kata non-stop for an entire evening, and finds the energy to stay focused for another hour.
We don't spend years studying martial arts in preparation for a brief moment that may or may not ever come. We spend that time becoming the person we wish to be, in every moment of every day.