Almost all software schools (including my school) use C language (hereinafter referred to as C) to teach C syntax and usage. This means:
1. c is the first programming language most students have learned;
2. When most students are involved in programming at school, they initially focus on programming languages.
So there are two questions:
1. Is it appropriate to use C to teach beginners?
2. should I start with a programming language?
My answer to the first question is clear, which is inappropriate. For the second question, I think Beginners should focus on programming methods in their early stages, rather than programming languages.
Dead master DennisRitchie designed C to implement (accurately rewrite) Unix. In other words, C was designed to write the operating system. The result is that it almost reaches the goal perfectly. C is concise and efficient, and the machine is abstracted just right: the continuous memory block is abstracted into an array, and a single (or several) continuous memory unit is abstracted into a variable and a struct, the memory address is changed to a pointer. It maintains consistency with the computer structure and is easy to be controlled by programmers. Therefore, C is the best choice for writing efficient and practical operating systems: Unix, Linux, windows, MacXOS, Minix is all written by C (and some compilations. C is called advanced assembly. I think it is impossible to thoroughly understand C without Assembly knowledge.
Ritchie leaves the maximum degree of freedom to programmers, but it is not intended for beginners, and the truth is exactly the opposite.
C For Beginners, the most valuable content is procedural programming methods and functions.
Functions cannot be avoided by beginners, but in addition, C has a lot of details that will distract beginners:
- Before using variables and functions, you must declare them. Once declared, they cannot be used, and must be defined! What are the differences between declarations and definitions? When declaring variables and functions, you must write the type, but you do not need to call them. As a result, the call form is very different from the declaration form.
- A major difference between a pointer and other types of variables is that its declaration form is different from the usage form! Variables can be directly input during output, but &;
- When defining an array, you must determine the number of elements. When using the array, you cannot cross the array boundary. Otherwise, an error is reported. The one-dimensional array and pointer are the same when passing in the function; but most of the time there is an obvious difference!
- Poor luck may also result in integer overflow;
- And the complicated prototype of a function that is absolutely maddening ......
All these points seem to be taken for granted now, but who dares to say that they were not troubled by these problems when they learned C?
Of course, these are not the defects of C. Many features of Ritchie are intentionally intended to maintain C's conciseness and control over machines, but it has become a trap and obstacle for beginners to get involved. It does not mean that new students cannot suffer a little bit, but should not be entangled in language details and lose their grasp of programming ideas. This not only disperses attention, but also kills imagination! C is a machine-oriented rather than human-oriented programming language. However, programmers can focus on solving problems without worrying about these details. Such a language is more suitable for beginners.
To sum up, I think C is not suitable for beginners. Even C ++ is not suitable because the above unfavorable factors also exist. For Java, JoelSpolsky has long said that Java language schools are dangerous.
Now let's talk about the second question: the focus of learning programming should be on programming methods rather than programming languages. The term "Programming Method" is similar to "programming ideology", "programming style", "Programming Paradigm", and "programming technology, so I will mix these terms below.
The so-called programming method, programming paradigm, or programming ideology refers to a typical programming style that provides a programmer with a perspective on the problem and program, it also determines the programmer's views on program execution. The programming method can also be understood as a solution to the actual problem through programming. Generally, one programming language supports one or more programming paradigms. Different programming paradigms can effectively deal with different problems, and some programming paradigms can handle a large number of problem domains, so they are widely used (such as structured programming ).
It is impractical to talk about programming methods from programming languages, while ignoring programming methods cannot be used to design programs that can effectively solve problems. Although programming methods are restricted by the representation of programming languages, they can span the boundaries of programming languages. Therefore, the abstraction level of programming methods is higher than that of programming languages. Beginners should start their learning career at a relatively high level, because they can get in touch with the core of programming as soon as possible: solve practical problems with computers. Since it is the core knowledge, why not let the students grasp it earlier? On the other hand, most of the current courses only make students struggle in language details, but ignore more important knowledge.
My idea is that the school should design such an introductory Programming Course for first-year students: To teach programming methods based on a programming language. This language should be very simple and can be used by students with no basic knowledge in only two to three lessons. However, this language must also be powerful enough to present various programming methods, most of the time in this course, students will learn the programming method.
With so much said, it is not only good to take the programming ideology first, but more importantly: this is feasible. As mentioned above, scheme is a language that allows programmers to concentrate on solving problems. It is simple and powerful enough. How simple is scheme? There is a programbydesign program in the United States, teaching programming in more than 600 high school students, right, high school. There are many simple scheme tutorials on the Internet (Mr Song Guowei's scheme language summary (I) is very good, and m people also have good tutorials ), the content of these tutorials will not exceed 2 to 3 lessons, but it is sufficient for students to use these simple language elements to learn and master programming methods.
-- TT