Both are safer, depends on what predators are around at the time. Most of us learn to swim either off the beach or in pools. The beach offers lessons in when not to go in, rip tides, etc. We often swim off the boat and off the dinghy
, sometimes taking it a long way from the boat.
, some beaches have "shark nets" off the beaches. Some of them are baited. In Oz, people tend to swim off the beach, but parallel to it. Not like in So Cal
, where we used to go out beyond the break and hang out, with never a thought about who might be hungry nearby, albeit, it was midday swimming.
One time, in the late afternoon (first mistake, it was getting on towards shark feeding time), I dove in the water somewhere in the Marquesas
. Sorry, memory fails, I think it was a little east of Taiohae at Nuku Hiva. In any event, near dusk, Ann dives in to cool off, and comes face to face with a small black tip reef shark. To herself, Ann says something that might be translated as "golly!" and in the dinghy
I go! I tell this story that that poor little black tip went back to Mom and said," I just saw this horrible big pink thing!" However, I learned to swim midday, when they're less interested.
Then you learn a little about shark habits, and we often swim when they're around, if they're calm, disinterested in us. We've done drift dives in passes hanging onto the dinghy, but if there are too many or they are interested, we get out of the water, full stop.
Crocs are a whole 'nother story, in that they like to observe prey, and can stay submerged an hour and a half. So they demand a different type of vigilance, or attention, or staying out of the water.