Every golfer who has ever played golf long enough has hit their golf ball into a water hazard -- known these days as a penalty area. It's an inevitable part of playing golf anywhere outside of a desert, and even then, a whole lot of desert golf courses manage to create ponds and watery areas.
Often times, when a golfer hits their ball into a pond, stream or ocean, the ball will never be seen again. It's going to sink to the bottom, and the water is going to be deep enough such that the ball will be totally submerged. The relief process is simple: identify where it went in, add a stroke and take a drop based on whether it being a red-stake lateral hazard or yellow-stake hazard.
However, there is the rare occasion when a golfer hits their ball into a water hazard and the ball winds up right on the edge of the water. It's in the water, but the ball is not full submerged. Maybe half of it or more is sitting out of the water, just waiting to be hit.
Some golfers, like me, get into that situation and wonder if it's worth it to save the penalty stroke and try to advance the ball toward the hole by hitting it out of the water. Under the Rules of Golf, that is totally legal and allowed. Golfers can now ground their club in a penalty area, so there's not even an issue with your club touching the water during the swing and up until contact.
The biggest questions in this situation are how much of the ball is submerged and how far you need to advance the ball to get out of the water. In situations like this, the distance to advance the ball isn't particularly far -- maybe a few yards. However, if the ball is almost fully submerged, it's going to take even more effort than a bunker shot to extricate it from the water. If the ball is barely submerged, though, then a golfer will have a good chance to advance the ball quite far with the right club and quality contact.
Of course, there's a big risk of getting wet in this situation, so golfers will often consider taking off their shoes and socks to hit such a shot. However, if the water isn't too deep, keep them on and hit the ball like a fairway bunker shot: leaning the weight forward at address and hitting the ball first.