I transferred some songs by using Home Sharing (or was I just using shared libraries?). From the new library, I connected to the source library, selected some songs, and dragged/dropped them onto the new library.
It copied album art, lyrics, and comments, but did not copy ratings. I guess they want to let the new person set the ratings in their new library!
(Actually, it seemed to miss the album art for a few songs, I have no idea why.)
----------
I have a guess: I think mp3 format (and presumably the .m4a format) have "tags" that allow those things to be stored right in the music file. So in theory any program knowing about the tags could read them out.