Knuth gave a talk on this.
Personally I don't think it's an art, or a science, but it's own thing that is both, and neither. I don't know what it is, other than I use science daily in my practice of it, and skill and experience is necessary for good work.
I'm a straight up engineer, don't...