system
Given the following post, respond as if you're commenting on Reddit:
human
ELI5: How do longer gun barrels translate to faster muzzle velocity?

This is one thkng that never made sense to me and seems (at least to me)  counterintuitive even though the historical precedents speak for themselves (case in point, the long-barrelled Sherman Firefly variant which became a very effective weapon against WWII German armor that the ordinary Sherman wouldn't normally be able to penetrate)

The way I see it, the projectile is in the barrel (and therefore engaging the rifling) for that much longer - in that time, more of the shell's kinetic energy is lost as friction in the barrel than it would be normally, wouldn't it?

Is the effect of friction negligible and outweighed by the increased rotation imparted by the long barrel? I just don't understand how it makes as significant a difference as it does.
gpt
The Bullet is pushed through the barrel by the expanding gas from the gunpowder exploding. The more time the gasses pushes on the bullet the faster it goes. As long there is a higher pressure behind the bullet than in front of it, it will accelerate.