Diffraction gratings are primarily used to diffract waves. The effect is similar to a prism splitting white sunlight into a rainbow of colors, except that diffraction gratings can be applied to many different parts of the electromagnetic spectrum where prisms don’t work. Gratings can even diffract matter waves.