As mentioned already, of the two choices, with no context of "best for WHAT?"... there is little to choose between them.
.40 is very fashionable in law enforcement as a defensive round, since the FBI "proved" that 9mm is pointless. Apparently all the people who have died from 9mm wounds should come back to life now. Oh, and Glock gets to sell a bunch of new pistols throughout the 1990s to government agencies....
Are you shooting paper for fun? Then go .22LR.
I like centrefire, and I am set up to reload, so I choose .45ACP for my pistols... The brass lasts longer in the lower pressure round.
If we are actually talking about putting handgun projectiles into nasty people, then either 9 or 40 are fine - Bullet placement matters most, but there is also the absolute random possibility of a bullet in a body doing all sorts of weird things, including NOT stopping the bad guy. Regardless of caliber: Fire, then evaluate, then fire again if necessary, then again, if necessary.
.40, IMHO, was an unnecessary marketing item, like WSSM rifle cartridges, and Iphones - Somebody just wants to sell you something new!