I noticed that the "new" F-35 still has a GAU-22/A cannon installed in it -- albeit with only 182 rounds (more with ammo pods).
Why do fighters still have cannons? The day of dogfighting is long over, now it's just fire some missiles and forget. Even if they expended all their missiles, 182 cannon rounds is only 6 seconds of firing (I think the GAU is rated to 1800 rpm).
The only reason (and I'm not sure if I should answer my own question) is that they need something to shoot warning shots over the bow of another airplane. But that seems an awful amount of weight for this rare occasion. And it'd mean loading tracer rounds.
Or is just a vestigial organ, like the sabres on the side of full dress military uniforms?