I'm studying information theory by myself.


I'm confused about that since we already have Huffman code, which is the optimal code method, why are Shannon code and some other code still useful?


I think maybe in some specific industrial area, Shannon code is more useful.


Can someone give me an explanation?



With Huffman code, why do we still need Shannon code?
I have to say that I know almost nothing about Shannon coding, which is different from, for example, Shannon-Fano coding. Shannon-Fano coding is in some sense a precursor of Huffman coding, it works in a similar way, and while it does not produce the smallest expected code word lengths, the code word lengths are within one bit of their theoretical ideal (see
<http://en.wikipedia.org/wiki/Shannon-Fano_coding>). (But see Martin Leslie's comment below.) Apparently Shannon-Fano coding is still used, even though admittedly it is hard to see a reason for this.


On the other hand, Huffman coding is not optimal because it codes only characters. You can improve the coding by coding longer words instead. This is done in arithmetic coding. Huffman coding is still useful because it is easier to compute (or you can rely on a table, for instance using the frequency of characters in the English language).


Finally there are many codes that serve a different purpose than Huffman coding: error detecting and error correcting codes, for example. Such codes are very important in various areas, in particular in industrial applications.


Finally, even if the goal is lossless compression, depending on the data, Huffman code might not be suitable: music, images, movies, and so on. 


