This is part of a challenge issued to me by my friend Matt. I'm writing with the lens of the Swift developer, but a lot of these things apply in principle to other languages, such as Java, C-based languages, and more. The syntax is really the differing factor.
Don't act surprised. You knew this one was coming. We all do it, even if the 10x engineers look down upon us for it. But in all seriousness, it's a useful tool nonetheless, and it's almost instinctively within reach for even the newest developers. When you use a print(...) statement, you can expect to see output in the console. You can use it to see if your code reached a certain path without halting execution, which could come in handy if you're checking multiple things. It's also handy for checking what the value of a variable is at any given time. Print statements are also commonly used to evaluate what's happening at different points in your app's life cycle. The great thing about these statements is that they don't stop our code's execution, and we can basically read a continual story about what's going on. Now, it's not a perfect solution for several reasons. First, if you're on a team, leaving print statements in your code is really easy to do by mistake, and it can cause an extra round of reviews for you just to remove them. Second, as things get more complicated, so does your console. Third, they don't truly enforce correctness because we're reading things and mostly accounting for our minds to evaluate whether or not things are going well. So to sum it up, print statements are useful, yes, but they're not necessarily great to leave in your codebases, especially for teams. Taking them out can be a hassle, and often times we quickly scribble them in ways that make sense only to us. Use them however you see fit!