Can an integer $n$ be represented as a sum of two squares $n=x^2+y^2$? If so, how many different representations are there? We begin with the answers to these classical questions due to Fermat and Jacobi and put it in the modern perspective of the Siegel-Weil formula. After illustrating Kudla's influential program on geometric and arithmetic generalizations using the example of modular curves, we discuss recent development on arithmetic Siegel-Weil formulas and applications.