Quoted from adol75:They all carry 1’s and 0’s so it doesn’t matter
This but to be more specific:
Optical is limited to 20 bits depth in most cases where as coaxial and HDMI have 24 bit depth. Additionally some technologies are encrypted and they are only allowed to run over HDMI. So if you have a 5.1 (or anything more than 2.1) sound system you should use HDMI for audio for movies to get the best support for the various Dolby standards. For music it doesn't matter.