Ab initio molecular dynamics is an irreplaceable technique for the realistic simulation of complex molecular systems and processes from first principles. This paper proposes a comprehensive and self-contained review of ab initio molecular dynamics from a computational perspective and from first principles. Quantum mechanics is presented from a molecular dynamics perspective. Various approximations and formulations are proposed, including the Ehrenfest, Born-Oppenheimer, and Hartree-Fock molecular dynamics. Subsequently, the Kohn-Sham formulation of molecular dynamics is introduced as well as the afferent concept of density functional. As a result, Car-Parrinello molecular dynamics is discussed, together with its extension to isothermal and isobaric processes. Car-Parrinello molecular dynamics is then reformulated in terms of path integrals. Finally, some implementation issues are analysed, namely, the pseudopotential, the orbital functional basis, and hybrid molecular dynamics.