Mathematics and Programming

Mathematics and Programming

Many people have written to me and asked me, what level of math foundation do I need to have to become a good programmer? Eighteen years ago, when I was a freshman in the computer science department of college, I was also troubled by the same question. Facing classmates who studied mathematics, physics and other subjects, I felt inferior. People often say that the knowledge of those majors is more refined and more difficult, and if people from those majors do programming work after graduation, their level is actually higher than that of computer science graduates. It was not until a few years ago that I deeply studied programming languages ​​that I got the answer and relief for this question. Since many new programmers encounter the same problem, I would like to elaborate on this issue in detail here.

Mathematics is not the basis of computer science

Many people mistakenly believe that computer science is a branch of mathematics, mathematics is the foundation of computer science, and mathematics is a more profound science. These people think that as long as they learn mathematics, programming will be a piece of cake, but this is not the case.

The truth is this:

  • Computer science is not actually mathematics at all, it just borrows very little, very basic mathematics, which is a little easier than high school mathematics. The so-called "advanced mathematics" is basically not used in computer science.
  • Computers are more basic tools than mathematics, just like paper and pen. Computers can be used to solve mathematical problems, as well as non-mathematical problems, such as engineering problems, art problems, economic problems, social problems, etc.
  • Computer science is a completely independent subject. Learning mathematics and physics cannot replace learning computer science. You must study computer science to become a good programmer.
  • The languages ​​used by mathematicians are actually very backward and poorly designed compared to common programming languages ​​(such as C++ and Java). The so-called "aesthetics of mathematics" is actually mostly arrogance.
  • 99% of mathematicians can't write decent code.

Mathematics is a terrible language

This is not an exaggeration. If you delve into the theory of programming languages, you will find that the symbols used by mathematicians are just a very bad programming language. Some mathematical theories are useful, but the languages ​​used by mathematicians to describe these theories are complicated and lack consistency, composability, simplicity, and usability. This is why most people get a headache when they see mathematics. It's not that they are not smart enough, but that there is a problem with the "design" of mathematical languages. When people learn mathematics, they actually only spend a small part of their time thinking about its essence, and most of the time they are struggling with its syntax.

Let's take a very simple example. If you say x-1 means x raised to the power of -1 (the inverse of x), then what does f-1 mean? f raised to the power of -1, the inverse of f? Don't be fooled by the dogma and excuses of math teachers. They always tell you: "You should remember these!" But have you ever thought: "Why!" x-1 means x raised to the power of -1, while f-1, which is exactly the same, means the inverse function of function f. One is for exponentiation, the other is for inverse function, they are completely different, but they are written in the same way. Such language design is extremely confusing, but they like to use "convention" as an excuse.

If you read more math books, you will find that this is just the tip of the iceberg of the dregs that have accumulated over hundreds of years in the mathematical language. Mathematical books are full of superscripts and subscripts, superscripts and subscripts with brackets, x, y, z, a, b, c, f, g, h, all kinds of twisted Greek letters, Hebrew letters... italics, bold, cursive, double shadow,... different fonts are used to represent different "types". The meanings of many symbols are different in different subfields. Some people take a math class and still don't understand what those symbols mean until the end.

Many people find it difficult to learn calculus. In fact, the problem is not with them, but with Leibniz. The language designed by Leibniz to describe calculus (∫, dx, dy, ...) is actually very bad from the perspective of modern language design. It can be said to be a mess. I can't blame Leibniz. After all, he lived hundreds of years ago. He didn't know many things we know now. However, the design of the ancients is not considered for improvement now, but is instilled into students as dogma. That is a lack of ambition.

The language of mathematics is not like programming languages. It has a long history and has not been systematically, thoroughly, and uniformly designed. The emergence of various mathematical symbols is often that a mathematician in history casually drew some weird symbols on the blackboard one day, saying this means something, that means something else, and so on, and then it was settled. Many mathematicians only care about their own narrow subfields and design a set of symbols for their own theories at random, without caring whether these conflict with symbols from other subfields. This is why the same symbols written in different mathematical subfields can represent completely different meanings. In this sense, the language of mathematics is somewhat similar to Perl (a very bad programming language). Perl indiscriminately added various functions needed by various people into the language, making the language extremely complicated, and even the creator of Perl himself cannot understand all its functions.

Mathematical proofs actually use an extremely loose language - weird symbols, coupled with ambiguous and easily misunderstood human language. If you know what Curry-Howard Correspondence is, you will understand that every mathematical proof is just a piece of code. The same theorem can have many different versions of proofs (codes). Some of these proofs are short and elegant, while others are long and complicated, winding around like noodles and impossible to understand. You often see "undefined variables" in mathematical proofs, and the logic of the proof also contains various implicit knowledge, and the thinking jumps, which is very difficult to understand. From the perspective of programming, many mathematical proofs will not even pass compilation, let alone running.

Mathematicians often don't care about the elegance of proofs. They think that as long as they can prove the theorem, who cares whether my proof is simple or easy to understand. The more you don't understand, the more you think I am unfathomable! This trend of thought shows its disadvantages when it comes to programming. When mathematicians write code, they often ignore important factors such as elegance, simplicity, modularity, readability, performance, and data structure of the code, and think that the code is fine as long as it can calculate the result. They treat the code as a one-time thing like a proof, so their code often cannot meet the strict requirements of actual engineering.

Programming is an art

From the above, you may have understood that the programming languages ​​used by ordinary programmers, even languages ​​like C++ with many flaws, are actually much better than the languages ​​used by mathematicians. Computer science is not a branch of mathematics. It is superior to mathematics to a large extent. Some basic theories of mathematics can be used by computer science, but computer science is not a part of mathematics. Mathematics has too many historical legacy in terms of language. It is actually a clay Buddha crossing the river, unable to save itself. It cannot solve the practical problems encountered in programming at all.

Programming is really an art, because it meets all the characteristics of art. Art can use the tools provided by science, but it is not part of science, and its status is not lower than science. Like all arts, programming can solve problems that science cannot solve, meet people's new needs, and open up a new world. So dear programmers, don't worry about not understanding a lot of mathematics. Mathematics cannot help you write good programs, but people who can write good programs can better understand mathematics. I suggest you learn programming first, and then look at mathematics.

<<:  Six things you need to know before developing your first app

>>:  Hybrid APPS Why I am optimistic about you - a tribute to front-end engineers

Recommend

iQIYI VIP price increases again, why?

iQiyi has raised its prices again. From 0:00 on D...

How to analyze live streaming traffic!

There are two topics today. The first one is &quo...

What? You need to "urinate" when cooking lobsters? How do you do it?

Lobster is a high-end seafood ingredient, and man...

How to choose a good domain name from an SEO perspective?

Now that we have learned how to choose a good dom...

Solid info! Six aspects that a complete operation plan should include

Anyone who does operations will know that there a...

What new challenges can machine learning bring to 5G communication technology?

Wireless communication now plays an important rol...

5 common techniques and strategies for live streaming traffic generation!

Nowadays, live streaming is imperative to attract...