lots of guys say start with a .22, i say start with a 9mm if you want to get really good. but the fact that you want a .40 is good to. its a big cal but if thats what you want then get it, just remember its costly and has more recoil that other choices.
with that being said i have a s&w m&p in 9mm and i love it. i have never had a single problem with it that wasnt due to my own reloads being underpowered. i put a new front site on it and a new apex competition sear set in it. the only complaint i have about that now is that the trigger is really long, but at least its crisp and smooth.
the last time i cleaned it was a few thousand rounds ago and it still works great. like i said, i havnt had a single issue with it yet.
as for the glock, i used to hate them, just because the feel and the cool aid factor but im now starting to warm up to them. ive even thought about getting a 17.
go try them both out and fondle them. go with whatever feels best to you.