Would fitting a deck gun to a modern submarine be useful?
Short answerGenerally no: using it would reveal the submarine and force an underwater-optimized hull to fight from its most vulnerable position.
NotesOlder cruiser submarines were shaped for substantial surface running, but modern nuclear and diesel-electric boats are designed to spend their patrols underwater. Surfacing to use a gun exposes the submarine at the moment its hull and tactics are least suited to survive. The mounting, ammunition, crew procedures, and pressure-hull compromises also consume space for a mission that should be rare. Weapons that preserve concealment therefore offer far more value than a gun whose use announces the boat's position.