We provide a systematic study of the notion of duality of Markov processes with respect to a function. We discuss the relation of this notion with duality with respect to a measure as studied in Markov process theory and potential theory and give functional analytic results including existence and uniqueness criteria and a comparison of the spectra of dual semi-groups. The analytic framework builds on the notion of dual pairs, convex geometry, and Hilbert spaces. In addition, we formalize the notion of pathwise duality as it appears in population genetics and interacting particle systems. We discuss the relation of duality with rescalings, stochastic monotonicity, intertwining, symmetries, and quantum many-body theory, reviewing known results and establishing some new connections.