📜 ⬆️ ⬇️

Benefits of C ++ as a first language for learning programming

Good day to all!

This article is about why you should choose C ++ as the first programming language for teaching students, and a little about the problems of teaching in universities. Part of the judgment regarding the learning process is based on the personal experience of teaching (three years, while studying in graduate school), as well as on communication with teachers and students.
The advantages of the C ++ programming language for learning and from the point of view of a better understanding of the basic concepts are considered. The remaining candidates for the role of the first language (Pascal / Python / C # / Java) are not considered, so as not to incite holivar. Once again I will note: not for industrial development and not from the point of view of such a subjective criterion as convenience.
Written under the impression of a frankly advertising post “Delphi XE5 as a basis for learning programming” (at the time of writing, only the version “from Google” is available ).

0 Introduction


For a start, I would like to note that for students of non-core specialties the issue of choosing the first programming language is not considered. The basics of algorithmization (if necessary) can be mastered even in Python, even in C ++ (Java, C #, Pascal, etc.). In this case, the simpler the language, the better it is: people need to form at least some kind of culture of algorithmic thinking and understanding of basic structures. Students of some specialties (legal, economic, humanitarian), the study of PL is not required.
Despite the obviousness of the above, many first-year economics students are taught Pascal programming in practical computer science classes. Students who still do not really know how to work with MS Word. The benefits of such activities are very, very doubtful. Similarly, students of mathematics can teach programming in C ++ / C # / Java for a couple of years ... but why? It is much more useful for the subsequent application of their knowledge to study programs like Mathcad, Simulink, Surfer, etc.
Given the above, consider the process of choosing the first language exclusively for students of specialized specialties (for example, "Software Engineering") and mixed specialties with a bias towards IT (for example, "Applied Mathematics and Computer Science"). First, the curriculum of such specialties implies a sufficient number of lectures and practices (since the first language is considered, only the first course is taken into account): for two related disciplines (computer science and programming) about 230 hours, depending on the specialty. Secondly, the presence of interest and a certain mindset among students. Such students most often tried to program, and perhaps even wrote a website / toy. These two reasons, in aggregate, provide a good basis for the start of training and lower the threshold of entry for language learning. In addition, graduates of the specialties in question will continue to work in the software development industry. Therefore, the choice of the first language is especially important for them.
')

1 Why is C ++?


In the first year, a basis is laid for further study and a student’s approach to the further acquisition of knowledge is formed. The programming language plays an important role here.
There are four reasons for choosing C ++ as the first programming language:
  1. Compiled language with static typing.
  2. The combination of high-level and low-level tools.
  3. OOP implementation.
  4. Stl.

Consider these reasons in more detail.

Compiler Here C ++ appears in all its glory. Many compilers, console commands, program building steps ... Yes, the first program needs to be written in a simple text editor without syntax highlighting and autocomplete, find what and how you can run it. Such an approach forms in a person some understanding of how everything works:

The future expert realizes that the code itself does not run (in the future it may be and will be interested in how, for example, the Python interpreter or JIT compilation works). A person will ask himself questions: “Why?”, “What is the difference?”, “How?”. There will be no illusions that everything works by pressing two magic buttons or in an interactive command line. The student will know that the program build process can be customized and that the source code can be processed by third-party programs. In the future, when using IDE, a person will understand that this is just a convenient set of programs that performs most of the routine operations and in case of insufficient flexibility it can be abandoned or expanded.

Static typing. Using the example of a language with static typing, it is easier to understand what a data type is, why it is needed and what it depends on. You can see what is the declaration, definition and initialization. Using C ++ language makes it clear to see what contributes to further understanding how these mechanisms work in other languages. In addition, it is possible to understand with real examples, how unsigned integers differ from signed ones, how double and single precision numbers differ, how a character differs from a string, etc.

High-level and low-level tools. Using tools such as pointers and dynamic memory allocation allows you to understand (or further contribute to understanding) what a stack, heap, call stack, stack promotion, etc. are. In addition, the understanding of the concept of addresses and address arithmetic is consolidated in practice. The examples demonstrate that memory must be allocated, freed, because it is not infinite, that there are memory leaks. In the future, when learning languages ​​with GC, it will be easier to understand what it is.
We should also note a simple mechanism for passing values ​​by reference, value, pointer, and object transfer. What are mutable and non-mutable parameters. In the future, these concepts can be used in the study of other languages. The student will understand, for example, that an object in the N language is passed by reference, and if its value is changed in a member function, it will change everywhere.

OOP implementation. This is a relatively clean implementation of OOP without any syntactic sugar (relative to some other languages). Clearly differentiated levels of access to class members, the possibility of multiple inheritance and dynamic polymorphism make it possible to quickly master the basic concepts of OOP (abstraction, inheritance, encapsulation and polymorphism). Pointers and dynamic memory allocation allow you to visually understand such important mechanisms as upcasting and downcasting. Further, based on this knowledge, it is easy to understand all the syntactic sugar in other languages. The need to control resources (including the “rule of three” or already “rule of five”, taking into account C ++ 11), their capture in the constructor and the release in the destructor also contribute to a deeper understanding of the OOP.
It is worth noting such an important point as not forced OOP. That is, this approach to programming is applied when it is convenient, and it can be mixed, for example, with functional programming. This contributes to the understanding that the means of implementation are chosen on the basis of the task.

Stl . By itself, the concept of C ++ templates, code generation, and the application of a wide range of algorithms to different containers has a positive effect on the learning process. Here everything is on the surface and it is clear why you can create a vector of integers and a vector of custom objects based on a single container class. Why you can apply some operation to a sequence of objects or how to sort objects for which there is no built-in comparison operation. You can understand how to access elements, and learn about the categories of iterators. In addition, the understanding of generic programming is consolidated.

2 A bit about learning problems


The learning process is perhaps one of the most significant obstacles in order to realize all that is written in the previous paragraph. Probably, this question does not apply to top IT-universities, but if you take ordinary educational institutions, then there is a shortage of qualified personnel and low student motivation. For most practical disciplines, experts who are directly involved in software development are rarely involved. For example, a person who has not applied STL in real projects is unlikely to be able to explain how to do this, and most importantly, why. As well as the teacher, sincerely believing that Delphi programming with molds already have the real OOP, given that all the code (without a hint of your own classes, abstraction and encapsulation) is written in the button click handler with the very clear name “Button1” "Is not conducive to the learning process. There are also problems on the part of students who did not really understand where and why they entered. Many students do not have the motivation to further learning and understanding, as well as to self-education. Despite the fact that such students and teachers perfectly complement each other, at the end of the training there will be no specialist applying for a junior vacancy.

3 Conclusion


At the moment in the world of software development there is a situation that the price is knowledge of certain technologies and experience of their application, and not understanding. Modern society needs many programmers who can perform strictly defined functions. In part, this is facilitated by developing technology development. It is possible that most developers who can simply use a certain set of tools will never encounter the "law of holey abstractions." However, people applying for the positions of leading developers engaged in optimization and architecture issues need a deeper understanding of how things work. One of the factors leading to such an understanding can be refused and the correct choice of the first programming language. Based on this, the C ++ language, which is statically typed, compiled, supports low-level work with memory and does not overload the syntax sugar implementation of OOP, can be recommended as the first programming language.

Source: https://habr.com/ru/post/202466/


All Articles