In addition to what srizbf said, a differentiator detects transitions of the input signal. It produces a spike at the output when the input transitions.
The comparator output switches from low to high as the input signal increases and equals the reference and from high to low as the input signal decreases and equals the reference. Usually, there is a hysteresis implemented around the reference voltage.