Between the 2 calibers you suggested, I'd opt for the 40 S&W for a few reasons. Mainly availability, price, and choices of ammo. I have been a devout 40 S&W carrier for about 15 years now. Mainly because back then, the 9mm was still lacking in the stopping power dept. I was left a few choices as I saw it: Carry a pistol with 17+ rounds of 9mm and risk having to use a bunch of them to put and keep an assailant down, or maybe go 45 ACP and only have 8 rounds, in a big heavy single stack package that was hard to conceal well. The 40 S&W bridged the gap between the two, in both stopping power and ammo capacity.
My first CCW was a Glock 23 with tritium sights. I have since carried others as CCW's, but have settled in with a Springfield XD 40 SC. I am quite partial to the latest generation of XD pistols, and I highly recommend them. You may also want to reconsider today's 9mm as an option, as now they are being loaded much more effectively and in a broader range of stopping power options. Heck, even the 38 special is now a serious CCW option, if used with +P ammo. I also agree with being effective with the intended caliber. It all means NOTHING, if you can't hit what you need to with it. The 45 ACP in some of the smaller pistols, is a bit too much recoil for some. The same can be said of the 40 S&W in a sub compact, shooting 180 gr bullets....for some, it's just a bit too "snappy."
I guess it all boils down to need, experience, and relying on others' experiences. Some people are recoil shy, and that effects how they shoot in general, let alone under duress. On the other hand, some people can carry and effectively shoot 357 snubs, titanium 38 snubbie's with +P ammo, and some headcases even pack a 44 mag snubbie for concealed carry. (I'm guilty of that...lol) Seriously though...many gun ranges will now rent you guns to shoot. Perhaps you should try a few calibers out first, and see what suits you best. You are ALWAYS going to be better off with the caliber you are most confident and comfortable shooting. Good luck!