How did the sails on a square-rigged ship work compared to a sloop dinghy?

Posted by RoboJ1M@reddit | sailing | View on Reddit | 30 comments

My wife and I learned to sail 1 hander dinghies about 15 years ago, single mast, a mainsail and a jib.
I understand the physics of converting wind energy into motive force for the boat, depending on what point you're sailing.
What I don't get is square rigged ships, as far as I know there is no aerofoil comment of a square sail, it's you typical "bed sheet on a mast, winds behind you" type affair.
Never mind hauling, how do you even reach with a square sail? And hauling, just looks impossible.
But I'm guessing I'm wrong and lacking knowledge because if it didn't work it wouldn't have been used for so many ships for so long all across the globe.
So yeah, that's the question, how did they get useful work across the points of sail from square-rigged ships?
A second sub question, were large square-rigged ocean-going ships ever obsoleted by large fully sloop-rigged ocean-going ships?