In recent years, technological advances in nanofabrication have opened up new applications in the field of nanophotonics. To engineer and develop novel functionalities, rigorous and efficient numerical methods are required. In parallel, tremendous advances in algorithmic differentiation, in part pushed by the intensive development of machine learning and artificial intelligence, has made possible large-scale optimization of devices with a few extra modifications of the underlying code. We present here our development of three different software libraries for solving Maxwell’s equations in various contexts: a finite element code with a high-level interface for problems commonly encountered in photonics, an implementation of the Fourier modal method for multilayered bi-periodic metasurfaces and a plane wave expansion method for the calculation of band diagrams in two-dimensional photonic crystals. All of them are endowed with automatic differentiation capabilities and we present typical inverse design examples.