There are certain autos on which this practice of letting the slide slam shut on am empty chamber can cause serious damage to the engagement surfaces of the hammer and sear. Whether this it true with the modern striker fired autos like the Glock or the M&P is not certain, but it is something that you "just don't do." Doing it marks you as a neophyte or duffer, and will subject you to ridicule, at a minimum and much worse if you do it to someone else's firearm.
The administrative handling of handguns is a study in itself. It is customary to go through certain motions and rituals when handling a gun.
For example, always check for loaded condition if it is in your hand, never hand a loaded pistol to another, check one for loaded or not when receiving from another person, NEVER, ever dry fire, run the action or spin the cylinder without the express consent of the owner; don't slam the cylinder open or closed by just swinging the revolver to the side, don't let the slide slam shut on an empty chamber, etc. It is just generally hard on the parts, and it is something you "just don't do."
Again, if you want to do this to your own pistol, have at it. Doing it to someone else's pistol is considered bad form, rude behavior, marks you as an idiot, will result in no one trusting you to handle or inspect their pistols, and if you cause damage to someone's fine target pistol by damaging the sear engagement in such manner, which is a very real possibility, YOU will pay the repair bill, possibly hundreds of dollars.