it doesn't mater both are same things..Which cable is better to use for a soundbar? HDMI or Digital Optical Cable
optical digital can do 7.1 not just 5.1Depends on where you getting the sound from and the capability of the soundbar.
toslink has a maximum capability of 6 channels (5.1 Dolby Digital Audio).
HDMI extends this to lossless HD audio (as found on bluray disks). and to Dolby Atmos if the sound bar has atmos capability.
They certainly aren't the same thing. Its true if you only want up to 5.1 then they should work the same.