I agree with all 4 posts above. G17 and M&P9 are my top 2 choices for 9mm pistols and as 3 others have said, shoot both and decide based on that. Hopefully shooting both will make one jump out at you. If you shoot both and like both equally, then we have the real dilemma lol. I would give a slight edge to the G17 if you shoot both and like both equally, and this is coming from someone who has owned a couple M&Ps over the years, though I recently also got a G19.
Here are a few subjective points on the 2 based on my PERSONAL preferences. The stock Glock sights are worse than useless to me. ~$100-150 will set you up with a quality set (if necessary for you). A lot of people (not me) have issues with the M&P trigger. I think $150-200 or so will get you set up with the APEX parts required for a much better trigger. Keep in mind aftermarket sights are fine for IPSC Production division but aftermarket trigger parts will pull you out of Production. The M&P is inherently less accurate than the G17 due to the design of the barrel (twist rate and lockup time). "My M&P is uber accurate!!!!1" That's great, this is a scientific fact though. Hilton Yam has an article on it somewhere on the 10-8 blog site.
The biggest one for me is the grip angle. It doesn't bother some people and your skill level will also determine how much of an issue it is. I'm good enough that it makes no difference when slow firing but when shooting at speed, my index is set to the 1911/M&P angle so shooting my relatively new Glock does slow me down or cost me a bit of accuracy. I expect further training to correct this issue and I have adopted more of a pinch grip (Ayoob style) when shooting the Glock which I think may have fixed this problem for me.
Or as the poster above says, you may very well end up getting both eventually so it doesn't really matter which you buy first