In 1940, a British mathematician G. H. Hardy published a famous essay titled “A Mathematician’s Apology” discussing the notion that mathematics should be pursued for its own sake rather than for the sake of its applications.

Similar to mathematics, the various fields of computer science also form a spectrum, with mathematical logic and computability theory on one end and web programming and application development on the other. I assume that you, the reader, is more on the applied side: this book was written to show that there are way too few people working on practical algorithm design instead of theoretical computer science — and since you got to Chapter 7, you probably also believe in that statement.

But, regardless of the personal views on the matter, one can see where Hardy is coming from. Being 62 years old at the date of writing, he witnessed the devastation caused by the First and the ongoing Second World War — which was greatly amplified by the weaponization of science. As a number theorist, Hardy finds calm working in a “useless” field and not having to face any moral dilemmas, writing:

No one has yet discovered any warlike purpose to be served by the theory of numbers or relativity, and it seems unlikely that anyone will do so for many years.

Ironically, this statement was proved very wrong just 5 years later with the development of the atomic bomb, which would not have been possible without the understanding of relativity, and the inception of computer-era cryptography, which extensively builds on number theory — the computational aspect of which is the main topic of this chapter.