Isn't code signing just digital signature on code? I have been trying to understand why code signing is treated or discussed differently from digital signature. 

Digital signature is signing a hashed BLOB with a private key. When the BLOB is code/software, it is code signing.

So, isn't code signing just digital signature in the true sense? Why is it carved out based on the BLOB?
Indeed, code signing is a special case of digital signature, and there is no imperious reason to distinguish the two from the standpoint of defining a cryptographic signature primitive.

There are however reasons to special-case code signature from an IT security perspective, by a having a "code signing" attribute in a digital certificate. It is a useful distinction for a certificate wether it's a code-signing or data-signing certificate; that is, if the signature of a piece of data checking against the public key introduced by the certificate should be considered, or not, as and indication that said piece of data is safe to run as executable code. In a Unix file system context, the distinction might correspond to a rule: allow setting the Execute flag or not on the piece of data received.

A similar useful distinction for a certificate is wether it's a certification authority certificate or not; that is, if the signature of a piece of data checking against the public key introduced by the certificate should be considered, or not, as an indication that said piece of data is a certificate. The distinction might correspond to a rule: entering that piece of data, or not, in the list of certificates that can validate a digital signature.

In both cases, the distinction is made with an attribute in the digital certificate, typically with different rules for certificate issuance according to this attribute.



There are efficiency considerations to account for when selecting a signature algorithm according to context, and that has some degree of relevance when choosing such algorithm for code signature:


Simplicity of the signature verification: especially for early boot code, it might be essential that the signature verification code is short and fully auditable (e.g. because it stands in a special, prohibitively-expensive-to-change memory, and much of the rest of the security sandcastle chain depends on that). That's a reason to use RSA, or Rabin signature. That also applies to digital certificate signature.
Speed of the signature verification: especially for low-power embedded systems, it might be essential that code signature verification is fast. That's another reason to use RSA, or Rabin signature. That also applies to digital certificate signature.
Speed of signature generation. That's seldom a consideration for code, which is typically orders of magnitude harder to write or compile than it is to sign.
Size overhead. That's seldom a consideration for code, which nowadays is typically much larger than a signature.