system
Given the following post, respond as if you're commenting on Reddit:
human
ELI5: Why do submarines have to surface at all? Can't they just operate underwater for the entire length of the mission, especially if they are nuclear-powered?

I have heard that diesel engines cannot remain submerged for a long time, so they have to surface very frequently. But what is it they actually do by surfacing?

Also, I understand that nuclear submarines can stay underwater for a long time, but even they do surface once in a while. My question is - why? Why do they have to do that? Can't they remain submerged during the entire mission?
gpt
A diesel engine needs a source of oxygen, to burn with the diesel to power the engine. They can't store enough oxygen for long term running. Indeed, most diesel subs only use the diesel engines when at the surface or at periscope depth, pulling air down to run the engine to power the craft and to charge batteries, and when submerged they run solely on battery power.

But nuclear subs can stay submerged for as long as they can keep the crew fed (and sane). They can generate water by desalination, oxygen by electrolysis of water, and the CO₂ is removed by scrubbers that are regenerated using heat - all driven by the power output of the reactor.