In a defensive situation:
1. It is more about shot location than external ballistics.
2. Most people, even including trained law enforcement personnel, shoot very, very poorly under stress, . Accordingly, less recoil and faster follow-up is important. The 9mm has the edge.
3. For general fun and sport shooting, the 9mm is much, much less expensive per round.
4. A large number of police departments and the FBI, have switched back to 9mm from .40 SW. "This makes it easier to shoot and allows for faster follow-up shots. ... hence the FBI chose to make the change to the 9mm round, which usually offers a higher round count per magazine, faster and more accurate follow-up shots, less perceived recoil, and very similar physical bullet characteristics to the . 40 S&W."