A firearm that can shoot pistol cartridges in full-automatic mode, the submachine gun can be a devastating weapon at short ranges, but has largely been replaced, in regular military use, with assault rifles that fire a more energetic, intermediate-power rifle cartridge. Submachine guns have large magazines ranging from 20 to 100 rounds. They tend to be inaccurate, but, at close range, the rate of fire compensates for the inaccuracy.
Some weapons used by police may appear to be submachine guns, but are actually variants of submachine guns that only can fire in semi-automatic mode. This design gives a more controllable weapon, a larger magazine than is practical on a pistol, and has the advantage of a low-powered cartridge that is less likely to penetrate walls and hit bystanders.
No movie about prohibition-era crime, of course, is complete without a substantial number of Thompson submachine guns. The Thompson was well machined and physically attractive, but heavy and expensive. It was later equipped with the Cutts Compensator, a device originally for shotgun use, but reduced the tendency of a submachine gun muzzle to rise during automatic fire.
In World War II, submachine guns such as the British Sten were useful with insurgent groups such as the French Resistance, as they were inexpensive, and a relatively untrained person could spray the general area of the target rather than require the accurate marksmanship required for a rifle.
Submachine guns such as the M3 were issued to soldiers who did not need a rifle as a primary weapon, such as tank crews, but wanted something more robust than a pistol. Alternatively, they might be issued carbines, which looked more like a rifle and fired a round between pistol and rifle power. The M1 carbine was semiautomatic but the M2 was full automatic, making it more similar to an assault rifle.
The WWII Germans built some of the best submachine guns, such as the MP38 and MP40, but, had resources not been a constraint, probably would have migrated to an assault rifle such as the StG44. When Soviet troops were not rifle-armed, they often had submachine guns such as the PPSh41, but, again, the trend in design led first to the SKS carbine, and then to the AK-47 assault rifle.
Some special operations forces, who have a choice of weapons, will select modern submachine guns for situations where they expect combat to be at short range, and where a weapon shorter than a rifle will be more convenient. Even so, these tend not to have true full automatic fire, but an option to fire 3-round bursts with each pull of the trigger. Burst fire is a reasonable compromise, as the most experienced and accurate submachine gunners would manually control fire into 2-5 round bursts.