Compression

Lossless

Lossless compression reduces the size of an audio file without losing information.
If you compress a WAV to a format like FLAC (lossless compression) and convert it back to WAV the result is bit-identical.

Lossy compression

Lossless compression is limited (depending on the complexity of the signal) to approximate 40%.
If you need smaller files, lossy compression is the answer. It throws away information according to the psychoacoustic model.
Signals that are masked (if a bird whistles and a train passes by it might still be whistling but you won’t hear it) are removed. If an even smaller file is needed, rolling of the heights is a next step as there isn’t much musical information there.
However, the more severe the compression, the less transparent it will sound.
Technically a lossy compressed format can be converted into a lossless format but what is lost in the lossy compression is lost forever.

MP3 is an example of a popular lossy codec.

Dynamic compression

This is sometimes mixed up with lossy compression but has nothing to do with reducing file size.
This is simply limiting the dynamic range of a recording so the differences between the loudest and the softest passage become smaller.
This is nice if you listen to music in a car (lots of background noise drowning the soft passages) but it deprives music of its “natural” character.
Dynamic compression has become infamous as being part of the loudness war.

 

More about audio formats can be found here.

References
  1. MP3 and other HiRes formats - Jörn Druhmann