There are lots of hysterical complains in the social media gutters, like /g/
, about Leetcode and apparent uselessness of such math-based drills.. Nothing can be further from the truth.
First of all, every remarkable programming achievements of the past, be it of NASA missions, or of Bell Labs, or of Ericsson, or some academic breakthroughs like ML or Scheme or Haskell – they all are due to the fact that the only way to have access to a computer used to be through mathematics, applied and even purely theoretical. The early Computer Science was basically considered, and especially taught at good schools, as applied math. It should remain this way(but, unfortunately, everything has been ruined).
To really master [an understanding-based] programming (which has almost nothing to do with so-called “coding”) one has to not just know some related mathematics, but to understand where that matematics “came from” – what exactly this or that mathematical notion has been generalized from, in other words one has to actually realize what mathematics Is.
So called concrete mathematics (and the best parts of an abstract one) study the properties of captured and properly generalized into abstract concepts recurring (frequently emerging at all levels) patterns in What Is. It is indeed just properly captured generalized observations (of an external observer).
Knowing (or rather realizing) this, one understands mathematics, and through it, one understands programming and could zoom back and forth from What Is, through math, to program abstractions and specifications and then, and only then to the implementation details.
As long as you are able to trace you problem domain to some aspect of What Is, to build a simplest mathematical theory of the domain (by naming and defining the entities, their attributes, relations among them and maybe even some “laws”) using familiar and well-understood mathematics, all the data-structures suddenly match one or another algebraic data type, and the rest of the code almost entirely “writes itself”.
One can see how this works “in practice” by reading any code by Peter Norvig, either in his books or in his Pytudes. This, by the way, used to be the only way to program, and this approach has been taught in MIT by Barbara Liskov and John Guttag, Abelson and Sussman and Eric Grimson (before they switched to Python and enshittified everything).
And proper, ground in What Is, mathematics is never hard, because the underlying patterns – the “basic building blocks from which What Is” arises – are never too complicated. Like combinatorics is boring but not hard to understand. Yes, the number of distinct ways some n
elements can be permuted (or arranged) is, indeed, n
times n-1
times n-2
and so on till we reach the unit. There is simply no other way.
Again, math is not “abstract” like in a pretentious bullshit abstractionism (a modern art form), it is abstract in the just right sense of stripping off the particulars in order to accurately capture the underlying essence (a commonality, a recurrent pattern, an isomorphism, or a symmetry), then name it and study its properties, which are “out there”.
The [only] royal road to programming is through mathematics. All the attempts to lower the entry barrier just resulted in enshittification of the field.
One more motivating example is of Andrew Ng and his wonderful and first-ever MOOC (Machine Learning). In order to write all that code easily and seemingly effortlessly, he has to do all the underlying mathematical derivations by himself, to prove (at least to himself) as everything is, indeed, true (and not mere just ideas) and that all the “underlying machinery” (the algorithms and data structures) is correct.
The fact that the whole “implementation” is reducible to a set of matrix operations is a deep one, maybe as deep as the Curry-Howard Isomorphism itself (yes, everything (all possible outcomes) can be seen just as weighted sums of causal factors in a partcicular locality, after all), but this is another story.
So, math is not optional but absolutely necessary, just as the sages of the past proclaimed. Without a proper mathematical foundation one ends up with C++ and all the suffering it causes.