wildfowl said:
Target shooters like the longer barrels because of the extended sighting plane and the increased weight soaks up recoil.
Some hunters like the shorter barrels because they are easier to carry and lighter.
Everyone has their own preferences though.
"Sighting plane" is a non-issue for shotgun sports. You either have a nice cheek weld and good form and followthrough, or you don't. If you focus on the barrel, you miss, so the barrel really only appears in your peripheral vision.
Gas-operated semiautos (and rarer gas-operated recoil compensators like the discontinued 870 Competition model) do a lot more to soak up recoil than slightly heavier gun, as do fancy buttstocks and mercury recoil reducers used by recoil-sensitive target shooters. Trap loads tend to be light, anyway.
The reason a long barrel (30" on a gun with an action, 32-34" on a break-open) is superior for trap is that clay pigeons fly at a predictable time in a smooth arc, so you want a gun that naturally swings in a smooth arc. This means relatively heavy and long. The added weight is not a disadvantage because the gun sits on a rack when not in use, and because the gun is shouldered before the shooter calls for the pull. It's nice for recoil, but if a short, light gun worked better, the good shooters would find other ways to deal with recoil!
The reason a shorter barrel can be superior for upland hunting is that birds do not usually fly in a smooth arc anyway, and the gun is usually shouldered as quickly as possible in response to the unpredictable and sudden appearance of flying birds. You don't want a smooth arc; you want a gun that comes up quickly, points and shoots, like an old-West gunslinger's. Carry weight is an added bonus.
Note that pass-shooting of waterfowl also involves more "setup" time and a smooth arc. Pass-shooters also prefer a longer gun.
All of that said, modern shotguns can do a pretty good job at many tasks. They just might not be the BEST at all of them.