.40 S&W does have an energy advantage over 9mmP. That advantage comes at the cost of increased recoil and reduced capacity.
My take on the subject is that 9mmP offers enough performance in pistols that most users think it's adequate for what they are asking pistols to do, stop the action of the bad guy.
Would .40 theoretically stop a bigger or tougher bad guy? Probably, but humans come in the size range humans come in. A cartridge that usually incapacitates the shootee and gets the job done is good enough. Plus it's easier to shoot and has more capacity, or that smaller size can be traded off for a smaller, lighter pistol.
It sounds like I'm totally knocking the .40 S&W. I'm not, I like my USP and find it to be pleasant shooting, even if it costs more to keep fed. But I don't feel undergunned carrying a 9mmP either.
BSW