It’s not a lack of gravity that poses the biggest problem. Instead, environmental factors might prevent a space shooting.
The most interesting part is, of course, the cannon, and while it was never used in an offensive manner against an enemy target, it remains the only gun we know about that has been fired in space.
Conservation of momentum explains why a gun or cannon recoils backwards when it is fired. When a cannon is fired, the cannon ball gains forward momentum and the cannon gains backward momentum.