Microelectromechanical systems (MEMS) and optics are a natural match. There are several reasons: MEMS devices have dimensions and achievable actuation distances comparable to the wavelength of light; smooth-surfaced dielectrics, semiconductors, and metals can be used in various combinations; and, since redirection of photons does not require large forces, the relatively feeble MEMS actuators can easily manipulate them. Micro-optical-electromechanical systems (MOEMS) are those where optics merge with MEMS. Many MOEMS devices are based on mirror arrays that can be tilted using electrostatic actuation. This work, however, focuses on programmable diffraction gratings and their uses for projection displays, spectroscopy, and wavelength management in modern optical telecommunication systems.