Understanding the phenomenon of rogue wave formation, often called extreme waves, in diverse branches of nonlinear science has become one of the most attractive domains. Given the great richness of the new results and the increasing number of disciplines involved, we are focusing here on two pioneering fields: hydrodynamics and nonlinear optics. This tutorial aims to provide basic background and the recent developments on the formation of rogue waves in various systems in nonlinear optics, including laser physics and fiber optics. For this purpose we first discuss their formation in conservative systems, because most of the theoretical and analytical results have been realized in this context. By using a multiple space–time scale analysis, we review the derivation of the nonlinear Schrödinger equation from Maxwell’s equations supplemented by constitutive equations for Kerr materials. This fundamental equation describes the evolution of a slowly varying envelope of dispersive waves. This approximation has been widely used in the majority of systems, including plasma physics, fluid mechanics, and nonlinear fiber optics. The basic property of this generic model that governs the dynamics of many conservative systems is its integrability. In particular, we concentrate on a nonlinear regime where classical prototypes of rogue wave solutions, such as Akhmediev breathers, Peregrine, and Ma solitons are discussed as well as their experimental evidence in optics and hydrodynamics. The second part focuses on the generation of rogue waves in one- and two-dimensional dissipative optical systems. Specifically, we consider Kerr-based resonators for which we present a detailed derivation of the Lugiato–Lefever equation, assuming that the resonator length is shorter than the space scales of diffraction (or the time scale of the dispersion) and the nonlinearity. In addition, the system possesses a large Fresnel number, i.e., a large aspect ratio so that the resonator boundary conditions do not alter the central part of the beam. Dissipative structures such as solitons and modulational instability and their relation to frequency comb generation are discussed. The formation of rogue waves and the control employing time-delayed feedback are presented for both Kerr and semiconductor-based devices. The last part presents future perspectives on rogue waves to three-dimensional dispersive and diffractive nonlinear resonators.