Often there are articles of the form "Do the programmer need algorithms," and they all have about the same pattern. The author of the article usually writes: “I have been writing websites / scripts for 1C in NC, and have never used algorithms or data structures. Red-black trees or some other exotic structures, which in the region in which the author works, are not often seen, if you see at all, are given here. Such articles are reduced to the fact that in a specific field programmers do not use complex data structures and do not solve NP problems.
The very posing of such a question is fundamentally wrong. The number of specialties in the industry is constantly growing, and a person who writes websites on .net will do very different things than a person writing drivers for sensors on ARM architecture under an exotic OS. Let's first define what the algorithm is. Informally,
Kormen defines an algorithm as a well-defined procedure that takes one or more values ​​as input and returns one or more values ​​as a result. Formally, the algorithm is defined in different models of calculations: operations that can be performed on a Turing machine or using lambda calculus. Thus, virtually any code that does something is an algorithm. It turns out that the question “whether the programmer needs algorithms” can be translated as “whether the programmer needs to know how to write code”. Correctly such a question should sound something like: “does a programmer in industry X need to know advanced algorithms and details of the theory of computation”.
If you look at all these articles, you can see that the people who write them are actually offended by the universities for having been forced to learn a lot of complex material - in the form of algorithmic analysis, complex algorithms and data structures - which they didn’t seem to be useful to. . In fact, the authors of the articles are offended by universities because they could not predict the future area of ​​work of the authors and give them only the minimum necessary set of skills. Indeed, to write simple websites and scripts, you do not need a special knowledge of algorithms and data structures. Or is it necessary?
Let's think about what you need to teach a programmer at the university in order to acquire the necessary skills for a successful career. Libraries? Frameworks? They become obsolete, the interfaces to them change, they are all written most often under one language, which students may never use in the industry. All learn to write websites? Or learn to write all the OS? Education should reach as large an audience as possible and offer the highest possible set of skills. The programmer must first be able to analyze and solve problems - this is the main skill that graduates of computer science departments should acquire. Writing code is simply a necessary tool that is used to solve problems. Who can know what skills you will need in the future? Thus, learning the theory is the most optimal from the point of view of education. These skills can be applied in any field, and learning a library or framework with a good knowledge base will not be difficult. Paradoxically, people asking questions about the need for algorithms, as a rule, have some knowledge in this area. I do not remember a single person who did not have knowledge of the theory of computing, and shouted with pride about it, claiming that he did not need them.
')
So, you are an abstract programmer in a vacuum, you have been working for more than ten years, riveting websites and solving simple, one-type tasks of clients / companies. You are well and comfortable in your niche, and only painfully painful for aimlessly wasted time in class on the theory of computation and algorithmic analysis, which gave you nothing. In the morning, lighting a cigarette over a cup of coffee, in the depths of philosophical reflections on the frailty of life, you wonder: why programmers who do not solve complex problems, know the algorithms and the basics of analysis. The short answer is: to be a qualified professional and to effectively use the available tools, including the language in which you write. The theory of algorithms and analysis teaches not only exotic algorithms and data structures in the form of AVL and red-black trees. It also gives an idea of ​​how to efficiently organize data, how to write code with maximum performance, where a bottleneck is possible in the system and how to deal with it. You are familiarized with ready-made solutions, so that you do not write bicycles, and do not run to Google every time you need to do something non-trivial.
Knowledge of the theory of analysis and algorithms is used by all programmers in fact every day, we just got used to these things so much that we don’t even think about it. Whatever task you decide on - whether it is a simple website with a sample of data from a database, or a bash script on a server, you will use some kind of data structure. At least a primitive array, and most likely something more complicated. Languages ​​give us many different structures, many of which are interchangeable. Often we have several variations of the same abstract type with different implementations. For example, in C ++ there are vector and list data structures. How do they differ, and what will be the advantages and disadvantages of using one or the other? How is a map implemented in C ++, and how is it different from multimap? How is a list implemented in Python - through an array or a linked list and how best to work with it? Why is it not recommended to use ArrayList in C # and use List instead of it? How is SortedDictionary implemented and how will it affect program execution if it is used instead of a Dictionary? How does continuation work, when should it be used, and will there be any side effects when using it? When was the last time you used curried functions in almost every language? If you think that the map in C ++ is implemented as a hash table, you are mistaken. It is implemented on red-black trees, and the hash table is implemented unordered_map. We should also mention dynamic programming. Understanding what it is, how to optimally rewrite recursive functions, and what memoization is, will often help to avoid shooting yourself in the foot. Thus, in order to fully and effectively use the language in which you write, you need to have at least superficial knowledge of the data structures, what they are, and how they can affect the execution of your program.
What about libraries? After all, they solve so many problems! To rationally use the library, they also need to be understood. First, functions in libraries can have side effects or behavior that you will not know without understanding the algorithms. Having received a bug in this case, you can long and hard to try to catch it and decide when to avoid it. Secondly, various tools and libraries often need to be “customized” - telling them which algorithms, data structures, and technologies to use inside. Without basic knowledge you will have to either go to read mana, or choose at random. Thirdly, there are many tasks that cannot be solved by simply calling the library or framework API. What will you do in this case? Spending hours looking for possible solutions and asking for help from a friend? Fourth, the set of problems is solved very simply with a few lines of code or with the built-in means of the language. If to solve every sneeze, you pull the library, then your programs will be giant monsters, taking up hundreds of megabytes and more on the disk, eating all the memory on the server, and having a rather poor functionality. In addition, the presence of heaps of connected libraries entails compatibility problems, and the program may fall randomly due to the strange behavior of several libraries in one project. Thoughtless use of libraries can lead to rather disastrous consequences, and developers who can only use libraries but are not able to solve even a simple problem on their own will never be appreciated because their solutions will be uncompetitive.
I worked with one programmer with experience of more than ten years. Once we needed a function that the library we used at that time did not support: a primitive text-wrap in one of the visual components. This “programmer” looked that it was impossible to do this using standard tools, and immediately declared that the implementation of such a function was impossible. The task was solved by a third-year intern with an analytical brain, who in two hours wrote a simple algorithm and implemented it into the necessary component. Another project in the form of a site on .net was inherited by me. The main page consisted of several small graphs, and it took almost 10 seconds to load. It turned out that the person who originally did this project piled up a bunch of terrible constructs from triple nested loops, which for a long time and sadly took data from the database, and then tied them to charts. After a little refactoring, the page began to load almost instantly.
Can a programmer do without the knowledge of algorithms and analysis theory? Maybe there are a lot of such “programmers”. Only to call them programmers can be unless with a big stretch. A lot of programmers come to me for an interview, with the experience of ten to fifteen years, and really do not understand what they are doing and why. They have their own niche, they go from company to company without staying in them for more than a year. As a rule, they have a small set of tasks that they can solve, and if you take a step aside, the person is lost and he needs to train himself with new skills. Such people are invited to the project, and get rid of them as quickly as possible, because they lose a lot of time inventing bicycles and reading mana to find out what they should have known from the university. They usually have no particular career and unstable earnings.
In the end, why do you need to know the algorithms and analysis theory, if you can do the work without this knowledge? To be a qualified specialist in your profession, to have career growth and respect of colleagues. To effectively solve the tasks and not reinvent the wheel. In order not to write monsters with a huge number of third-party libraries, which occupy hundreds of megabytes on a disk, they erase a lot of memory on the server and regularly fall for a random reason depending on the phase of the moon. To effectively and with maximum opportunities to use the language in which you write. To make informed and meaningful decisions on choosing a library and technology to solve a problem. If your job is to write the SQL query and drive the command into the console, then I want to upset you: you are not a programmer, you are a user, you really do not need algorithms and others like him, and you have wasted time at the university because for such work just finish the courses or read a couple of introductory books yourself.