Programming Language Level View - Targeting C ++ Taro

zhaozj2021-02-08  502

A few months ago, I published a short message on the CBS, called "style choice." In that article, I present a point of view: Faced with different applications and environments, C developers should take the initiative to tailor the language, choose the most suitable C subset of the most suitable field for specific development. This is the idea that summed up from my actual work, which is always just an empirical thing. I think this is the right choice, but if someone asks me why, I am deeply confused and I can't answer. In recent time, because of the adjustment of the direction of work, I gradually biased the low-level technology. For the computer architecture, the operating system has been put into considerable energy learning, gradually, the problem that has made me confused above. Some ideas, and have further expansion of my previous point. I want to take it here again, and discuss it with everyone.

The first thing to explain is that the language is definitely not an insignificant problem. Many people like to quote a sentence: programming language is just tools, the key is the algorithm and ideas behind. This statement originated from some of the granted granted information. It should be said that for the algorithm description, the difference between the language is irrelevant, but the modern programming language is not only the tool used to express an algorithm, more importantly, as a component unit to construct the system. The ability, expression style, characteristics, and habitual use of the language will determine the system's architecture, functionality and basic characteristics of the system, determine how people design and production software. Therefore, we must always always pay attention to the development of the programming language. According to my friends, the programming language is always one of the most essential things in the computer field, especially in the computer engineering (rather than scientific), "What form to control the machine" is always a core problem.

To be honest, this topic is very big, I also thought of a lot of things. But I don't have enough time to explain in detail, there is no time to organize these views. Therefore, in this article, I just simply column and elaborate my basic view. I believe that friends who are interested in this topic will not mind in this form. Li Ze has said that he does not like German writing methods, writing a thick two volumes, millions of words, but only a "introduction", he likes a simple "outline". I found that when I was not enough time, Mr. Li's point of view was quite tempting.

[Basic view] 1. The programming language is the same as the software system, in different levels. The higher the hierarchy, the worse the ability to control the machine; the lower the level, the stronger the ability to control the machine. It is very necessary when choosing a language, selecting a suitable language level as needed. Here is the level I divided by the common language:

Low-level language: assembly, c, forth

Applications: Control System, Operating System, Virtual Machine, Interpreter, High Speed ​​Data Processing, Core Computing Engine

Medium Language: Java, C #, VB.NET, Delphi (Object Pascal), Eiffel, Oberon-2, ...

Applications: Most of the general and dedicated software

High-level language: Perl, Python, Ruby, HTML, SQL, JavaScript, Shellscript, VB, ...

Application: Mainly for the development of special software

General Language: ADA, C Applications: All

Special language: COBOL, FORTRAN applications: large machines, business and numerical operations

If the programming language is selected during development, at least it is not economical, complicated, and severe words, will result in a complete loss of the entire project. 2. What is a low-level language? There are usually a lot of different answers to this issue. I personally have the following descriptions for low-level languages: 1) directly reflect the machine behavior, not human behavior; 2) emphasize the ability to control the machine, weapons can utilize this control capability to maximize operation; 3) exist to machine language Clear mapping relationship; 4) Can meet the needs of system programming.

The so-called system programming, in my opinion, it is worthwhile to optimize performance (not only speed performance). One of the Germans is more direct as: "The so-called system programming is more important than the CPU time than the programmer's time." Obviously this is not a very academic description, or even a very pleasant Speaking, but it is indeed a good description. In the low-level language, C is a language worthy of loudly praising. C is a great masterpiece, which constructs a "portable optimized assembly code generator" in the form of a high-level language, which is efficient, flexible and complete. However, there are too many people and organizations to use a large amount of energy to become a higher-level language, such as a variety of strange macros to give it an object-oriented property. Although this proved is possible, it has never been widely used. The reason is very simple - this is from the level of C, neither economical or intuitive.

3. The middle-level language is the best choice for general programmers. The middle language may be a vocabulary that I have "created". I think the current most popular languages ​​belong to the middle layer. Their common feature is that both strong control capabilities have emphasized the friendship to programmers. Production efficiency has several times or even ten times even more than ten times higher than that of the low layer language. In general, the intermediate language follows a certain kind of programming idea, providing a relatively strong but simple abstract mechanism, providing high-level and low-level control capabilities through a complete library. In the future, intermediate languages ​​will continue to be the most popular development language. The intermediate language has its limitations, on the one hand, it is limited to the machine's control capacity and cannot be optimized. On the other hand, the guiding ideology behind it is relatively simple, so many compromises need to be complete. In addition, the intermediate language is usually changed soon, not stable.

In the intermediate language, Java and C #, etc. run on virtual machines written in C / C , Eiffel compiles to generate C language code, which indicates that they are not directly facing the hardware. At the same time, these languages ​​have been used to construct the Foundation Library, the runtime environment and even control systems are traditionally considered to be "system programming", so they have achieved good fold between productivity and control. in. For ordinary programmers, it is the best learning choice. For general projects, it is also a preferred development tool.

4. Universal Purpose. General languages ​​such as C , ADA, actually trying to get rid of the above language, hoping to accommodate the needs of each layer in a single language, facing each of the applications. Therefore, they must be based on a level, improved by some form, or lower their hierarchy. For example, C is based on low-layer language C, through class, template, inheritance, etc., improve its level; and ADA, based on "object-based", the high-level idea is relatively high-level thinking, providing underlying control capabilities through various packages. It can be said that some form of abstraction is the only means of increasing (and reduced) language levels. However, abstraction is to pay for the cost, and the abstract ability is either accompanied by the weakening of control capabilities, or with the sharp increase in complexity. ADA and C do not have to choose powerful abstract capabilities and control, and construct complex language systems. 5. Once a good language interoperability is provided, the effective combination of various levels of language will be the most economical and effective way to construct the system. In contrast, constructing the entire system using a generic language will be very uneconomic choice. That is, the code generated by various languages ​​cooperates with each other on the binary level, which is more economical than if the programmer jumps between different language levels.

6. We can see a universal language as a unity of several language subsets of several levels. This also makes the tailoring of the language become an objective behavior, and is also very difficult. Because of several language subsets, we may cut the language to accommodate the needs of each level. Because it is a unity, this type of tailor is very difficult.

7. C is currently a system language (that is, low-level language) is complete, but as a medium-sized language, its support library, language mechanism has many defects (such as lack of unified object-level callback mechanisms). This brings great troubles to those who want to use C as a high-level language. Before these problems are not solved, the Best application area of ​​C is still system development - that is, the general language C of the vertices of each layer is used as a low-level language, which is just right when absolutely appropriate. Higher layer mechanism.

According to P. J. Plauger discussion, for C , there is generally from small to a large number of tailoring schemes, as shown below:

ANSI C | | | Add to reference, overload, etc. Simple extension | | a better c | | | Add non-virtual member function, specific class | | Object-based C // / / joining template / / joining single inheritance and polymorphism / / / / Object-based Embedded C Template C } / / / / / / / / / / / Embedded Template C | | Add to Multi Inheritance, Frequency Base, Exception | | ANSI C Hope This figure can face the actual field C programmers can help. For me, Better C is not attractive, I am not as good as the portability of Portplant. Object-based C provides classes and packages, but it is limited, and the same effect can be easily achieved with C language. Embedded C is a standard developed by the Japanese, essentially C in 1987, high availability. There is no Object-based Template C in the document, but theoretically there is this possibility, that is, it is completely free of inheritance, polymorphism, exception, and only uses specific classes and templates (STLs), which with herb Sutter at 1998. The programming style advocated before the year is very close. Embedded Template C is an informal name, maintained by companies such as Green Hill, Metrowerk (Code Warrier), most suitable for embedded applications. Microsoft's Embedded Visual C 3.0 is an excellent Embedded Template C implementation, but it supports multiple inheritance and virtual base classes to support COM development. Finally, it is ANSI C . The manufacturer of embedded development tools is now fully supporting ANSI C , but I think the developer of embedded systems will take a long time (maybe forever) will need to use ANSI C 's complete works.

转载请注明原文地址:https://www.9cbs.com/read-292.html

New Post(0)