They are both good defense calibers. The 9 is a little more controlable and cheaper to shoot. The 40 has a bit more punch but less mag capacity. Both of them will get the job done with a good hollowpoint. The 9 is chambered in some very compact guns too.
Either one is fine. It all comes down to personal preference. I like the 9 better.