Code and Music

Is there a method to the beauty?

Is there a mathematical theory associated with Code as with Music?

Is code written to be as visually digestible as possible?

Or was it written to be as efficient as possible to the creator?

Example: Why in CSS does it “Cascade” vs flow linear as in a book and follow basic white space rules?

Have people tested various layouts to see which can be parsed quickest?

Thanks in advance,

I ain’t an expert on the math of code, but I can say that what ever you type in whatever code language always gets broken down by the computer into something it can directly read.
A computer can’t make sense on its own of the English words in python css or javascript, so what it has to do is translate them into the only two values it can read, 1 and 0

These are equal to on and off, and billions of them run through the computers processor every second in order tell which calculations to make, or which individual pixels on your monitor to light up.