While neither would be my first choice for a side arm, between the two I would have to choose the 9mm Glock. While the 9mm will never be as effective as the .40 S&W it has been my experience that Glocks chambered in the high pressure .40 round don't live up to their full potential. Given the exact same shooting circumstances and variables (shot placement, target, target mindset, etc.) the .40 round will always excel because of it's larger diameter. When discussing handgun cartridges the only measurements that effect wounding are penetration depth and projectile diameter. Energy in handgun bullets is nominal and does not contribute to successful wounding due to the amazing elasticity of the human body. Simply put, handgun cartridges do not achieve high enough muzzle velocities to reliably wound and effect a human target through the transfer of energy. So even though the .40, by the numbers, is a superior cartridge why would I choose the 9mm Glock?
When Glock introduced the models 22 and 23 these guns were basically their 9mm counter parts (17 and 19) rechambered for the larger caliber. The barrels and ejectors were changed as well as the addition of second pin through the locking block in the frame. What Glock did not do, to the best of my knowledge, is respring the lager caliber guns. That's right, the 17 and the 22 share the same weight recoil spring just like the 19 and the 23 do. Not good for the .40 caliber this leads to accelerated battering on the guns.
When the gun recoils and the slide reciprocates the barrel acts as a sort of 'pry bar' lifting upwards on the locking block inside the frame. This causes the front of the locking block to lift up and rub the underside of the slide as it is reciprocating. In four guns, three of which I have had extensive experience with, I have seen this cause fairly large burrs and marks where metal has actually been removed from the slide. The marks occur just below the slide raceways forward of the breech face. On one, a G22, gun the burrs were so jagged and sharp they had to be field flat. This, IMO, is not something that should be happening. I saw similar marks occur in another G22, G23, and G27. Once again, to the best of my knowledge Glock never increased the recoil spring weight in the .40 caliber guns and that is what I believe largely contributes the unusual wear that I observed.
However, the G23 that was once my friends daily carry gun had the stock recoil assembly replaced with an increased weight recoil spring after about 200 rounds but the wear still persisted. Out of the three guns I was familiar with this gun seemed to have the least amount of wear even though it has a couple thousand rounds through it. Neither of the G22s had more than 5000 rounds through them and the round count on the G27 was unknown, as I only inspected that gun. The G27 did look relatively new so one could assume the gun has been well cared for. If increased weight recoil springs are used the guns may fair better, but not in the 23 I referenced.
Once again this just what I have observed and I am not a gunsmith so my conclusions are certain amount of conjecture. This may not happen in all .40 caliber Glocks but this has defiantly swayed me from purchasing another Glock in that caliber. YMMV