Very general question. I'm sure that someone here is going to give you hell for not stating what you are gonna use the gun for. CCW, duty weapon, home defense, Zombie Apocalypse? What size gun are you looking to get?
Anyhow. Despite what some will tell you in, 9mm is a great round. It's been around for a while, so it's easy to find and comparitivly cheap. Lot's of penetration. Some consider it the "minimum" for a self-defense round. However, it is not a gun only fit for Sissys and Girls. You'll hear lots of folks tell you about all the "issues" the military has had with the 9mm round. Just remember that the military is restricted to using FMJ ammo.
40cal is great too lot's of LEO's use it. Very popular, not too expensive. Bigger round, so 40 cal guns usually hold less rounds than similar 9mm's. Some folks don't like the recoil of the 40cal, but I've never had an issue with it.
Both are great rounds, in fact they are two of THE great rounds avaliable today. Just depends what you want. There are lots of other differences, but i'm sure others will chime in with those. Just so you are ready, someone is going to get on here and tell you that they both suck, and that you need to get a 50AE, or such.