This reminds me of the effort by Sussman to teach physics by programming : Functional differential geometry [1] was discussed on hacker news before [2].
[1] https://mitpress.mit.edu/books/functional-differential-geome... [2] https://news.ycombinator.com/item?id=7884551