The single greatest strength of a skilled software engineer is to know when to make it someone else's problem.
you come from web dev doing HTML like that and you see XML and think "hey, that looks the same, i'll do it in the same way".
XML is a programmatic data exchange format like JSON or YAML, which most people would never think of outputting as templates or printed text, but it looks and feels like HTML, which most people deal with first and where that's the standard approach.
Don't tell the Ansible folks!
Ansible does use YAML as a configuration language though—something for which it's perfectly suited.
That said the templating is usually trivial, just maybe write some string values.
If I'm trying to output straight to a user sitting in front of a terminal, they are going to be very unhappy if I output XML at them. And if my program only outputs machine-readable and requires another layer to turn it into something human-readable, that seems overcomplicated for most applications.
Have I missed the point, or is this advice intended for more specific scenarios than I imagined?
Print and friends are appropriate when not attempting to produce data that conforms to any particular structured format.
It's much easier to understand what's happening later.
> Use an isolated serializer
Some old reference material (XML isn't as common as JSON anymore), but still worthwhile learning: don't output data formats directly. Directly = echo, print, printf,println...whatever your syntax suggests. I see this happen a lot with my junior engineers, and I have this same conversation with them.
Prefer to use data serializers that encapsulate all the syntactical rules that go along with XML, CSV, JSON, YAML, etc. Let the serializers do the grunt work of writing output in correct format.
Some serializers aren't always ideal - correctness and speed can be an issue. Nonetheless, prefer to use those mechanisms over writing your own output.