← Back to context

Comment by colejohnson66

4 years ago

How do you even define “entropy” of a program? It’s a byte stream where each byte is important.

Shannon entropy. https://github.com/jart/cosmopolitan/blob/master/libc/rand/m... You can even measure a program in terms of physics constants too.

  • Not trying to be rude here; Just trying to understand…

    My issue is: sure, you can measure it, but does the result even make sense? Like, OK, we can compute how “random” an instruction stream is, but what purpose does it serve?

    ISAs aren’t designed in a random manner, so what’s the point in comparing the entropy values of two different programs? The only thing I can think of is determining how compressible a given program is. But, that doesn’t tell us anything about performance/instruction (or byte).[a]

    [a] For example, AES-512 can pack massive amounts of functionality into 5 or so bytes

    • It's useful to be able to calculate the density of information. For example, redbean uses it to determine whether or not it's profitable to apply gzip. It has nothing to do with isa. That's kind of the point. For example, I could have written a routine that said, don't bother compressing files with the extension jpeg, jpg, png, gz, zip, etc. or I could have used information theory like I did. Another cool example is I've never seen any code that has higher information density than biology.