Math for the programmer
Does a programmer need math?
I need it. And besides it, you need spherical geometry, geography, music and banking. And I'm not joking right now.
The fact is that programmers rarely solve problems for themselves: we work in banking services, hotel reservation services, map services and other Yandex.Mail. It turns out that we solve the problems of our users.
To solve purely programmatic problems, we have algorithms and patterns: if you look at the code of an online flower shop and a banking site, it will be very similar. The same conditions will be used, the same cycles, and even the MVC pattern will be the same.
More importantly, what is behind these things: understanding how the system as a whole works. If you look at things from this perspective, it will become clear that the programmer is a junior specialist in the field in which the site operates.
Five years ago, Artyom Polikarpov proved that each front-end is a little designer. We need to understand how fonts are arranged: what is grotesque, how does it differ from antiqua, what is leading, kerning, discharge, capital. Understand what grids are and what composition is. In addition, to understand UX - we need to know what an optimistic UI is, where to put the preloader and why the user needs it all.
But to be only a designer is not enough. The fact is that users interact with our sites: in online stores they enter data of their bank cards, on map services they plot routes and measure distances, on music sites they transpose the tone of songs and tune the guitar according to the tuner. And all this someone has to program. It turns out that the programmer must have special knowledge.
For example, the correctness of a bank card number is determined by the Moon algorithm - this is the coding theory.
To find the distance between two points on the map given by latitude and longitude, you need to use the large circle arc formula - this is spherical geometry. This formula is also often used in marine navigation.
With cards, in general, a lot of interesting things are connected. For example, Yandex.Maps use the Mercator elliptical projection , and all other geographical services use a spherical one, so if you want to overlay Yandex.Cork layers on any other map, the streets will not converge and you will need to know how to transform one projection into another.
Speaking of transformations. Remember the CSS filter matrix
? Those same numbers in a strange order, which is unclear how they affect the behavior of your block? These are transition matrices from linear algebra. If you understand what matrices are and how to multiply them among themselves, then you can write transformations very efficiently without using aliases.
.neo {
transform: matrix(0, -1, 1, 0, 50px, 50px);
}
With horizons it’s clear - study everything you want, because in any case it will come in handy. But is there any common area that all programmers need? Yes, there is such an area, it is called "discrete mathematics." The science that underlies computer science.
I am not saying that you need to thoroughly teach dixret. For a programmer, a breadth of views and an understanding of where to look are more important than narrow knowledge in a particular area. But remembering a few key topics does not hurt.
First, learn Boolean logic. You write the conditions every day and it would be nice to understand how they work, for example, in order to simplify them effectively.
Another good topic from the discretion is graphs. A lot of programming tasks are solved with the help of graphs. Even the boring and familiar DOM is a tree, a special case of a graph. And here it would be nice to understand at least how you can walk on trees.
For example, do you know that querySelector
uses in-depth search? This means that when he visits the node of the DOM tree, he tries to look at its child nodes first and only then the neighboring ones. This means if you search with the querySelector
first element on the page, then it will not necessarily be a top-level element, the element found can be on any nesting.
const firstDiv = document.querySelector('div');
firstDiv.id === 'underdog';
Another topic from discrete mathematics is algorithms. Algorithm theory studies what algorithms are and an assessment of their effectiveness. Imagine you have a list of people for whom you need to calculate average height. The list is specified as an array of objects.
const people = [
{ name: 'Иван', height: 183 },
{ name: 'Марья', height: 155 },
];
The first solution that may come to mind is using the method map
to collect another array, an array of the growths of these people, and then using the method to reduce
calculate their amount and divide by the number.
const averageHeight = people
.map(it => it.height)
.reduce((acc, it) => acc + it) / people.length;
But this solution will be ineffective, because you will use two passes through the array, instead of one. You could immediately use reduce
it to add up all the growth indicators at once.
const averageHeight = people
.reduce((acc, it) => acc + it.height) / people.length;
In fact, evaluating the effectiveness of algorithms is a slightly more complicated topic, it takes into account which algorithm you use and the amount of input data, but you understand the direction of thought. The ability to evaluate the effectiveness of algorithms will help you write code that will work well on older phones and computers, or that will not slow down when working with complex algorithms, for example, with large visualizations.
Total: learn everything that comes to your hand. First, study discretization, because it will be your main tool in your work, and then focus on the tasks of your business and you will discover a lot of new things in business, mathematics, construction and medicine.
Video version
Questions can be asked here .