There're many computer magics. One of my favorite is data compression. When I first meet a compression tool, I found I loved it too much. I tried every settings to compress different files for fun. Nowadays, many open source compression libraries are available. So why not add some compression to your program?
There're many well-known compression libraries, like zlib (my favorite!), bzip2, lzo, lzma. I'll compare some of them here.
Functionality:
zlib and lzma provide the most complete functions, even read/write data within an archive. bzip2 provides file compression and memory compression, but has no archive functions. lzo provides only memory compression.
Compression:
lzma compresses best, followed by bzip2, and zlib, and lzo.
Memory Consume:
lzo uses merely no memory, zlib uses very little memory, bzip2 uses more, and lzma consumes a lot!
Speed:
lzo is the fastest due to its lesser compression. zlib is faster then bzip2. lzma is the slowest. However, lzma supports using multi-thread, which boosts its speed. (But I don't think it's a good idea for embedded devices like iPhone...)
Code overhead:
lzo < zlib < bzip2 < lzma
License:
lzo is GPL, that means if you use this code, you have to open source. You can use rest of three without open source.
To me, zlib is my favorite, because it's fast enough, its compression is good enough, the functions are easy to use, and its code overhead is really small. The zlib's sdk pack also contains some useful third-party code, very useful. We'll discuss them later.