the other side!

zhaozj2021-02-11  267

[Translator Press] Dr. Bjarne Stroustrup, born in Denmark in 1950, graduated from Denmark University and the University of Cambridge, the AT & T large-scale procedure design department, AT & T, Bell Lab and ACM members. In 1979, b. S began to develop a language, called "c with class", and later evolved as C . In 1998, ANSI / ISO C standard established, in the same year, b. S launched the third edition of its classic books C Programming Language. The standardization of C marks the great idea of ​​Dr. S. 20 years of 20 years of hardships. However, the development of computing technology has a thousand miles away. In a few years ago, people also guess C eventually will finally be a world, but with the explosive growth of the Internet, similar to Java, C #, etc., modern language is aggressive, and various Script language is more It is like the rain, spring bamboo shoots have emerged. In this case, people can not help but feel awkward. Is C have been out of time? What is the prospect? What is the meaning of standard C ? How should I learn? Let's take a look at B. S thinking about these problems. The following text is a severity of the translator from the Stroustrup1998, and the conversation is selected, and the content is more repetitive because of the point of origin, in order to maintain complete, and translated.

The following content is selected from the FAQ published on B. S in its home page.

1. Please talk about C books.

No, it is impossible to have a book is best for everyone. But for those real programmers, if he likes to learn some new concepts and technology from the middle of the "classic style", I recommend my THE C Programming Language, the third edition and special edition of 1998. The book is pure and pure C , which is completely independent of the platform and library (of course, the standard library can be said). The written written to those who have a certain experience, helping them to master C , but not suitable for beginners who have no experience, and is not suitable for those temporary programmers to taste C snacks. So the focus of this book is concept and technology, and there is a lot of effort in integrity and accuracy. If you want to know why C will become today's appearance, my other book The Design and Evolution of C can give you a satisfactory answer. Understanding the principles and restrictions can help you write better procedures. Www.accu.com is one of the best book review sites, and many experienced programmers speak this, let's take a look.

2. How long does it take to learn C ?

It depends on what you mean by "learning". If you are a PASCAL programmer, you should quickly make your C level to the extent to which Pascal; and if you are a C programmer, you can learn more excellent C style using C within one day. Program. On the other hand, if you want to completely master the main mechanism of C , such as data abstraction, object-oriented programming, general programming, object-oriented design, etc. Be odd. So is this that this is the time you need to learn C ? Maybe there may be another reappearance, I want to be a better designer and programmer at least so long. If you learn a new language can't make our work and ideas, what is it? Compared with a pianist or proficiency, you can learn a new, different language and programming style is simple. 3. Learn about C is the prerequisite for learning C ?

no! The subset of C and C is actually better than the C language itself. The type of error will be less, and it is not like C, and there is a better support library. So you should learn C from this subset.

4. If you want to be a real OO programmer, is I got to learn SMALLTALK?

no. If you want to learn smaltaok, despite going to learn. This language is very interesting, and learning new things is always a good idea. But smalltalk is not C , and does not have any good results in the SmallTalk's programming style in C . If you want to be an excellent C programmer, it is not bored in a few months, please concentrate on learning from C and his thoughts behind it.

5. How do I start learning C ?

This depends on your foundation and learning motivation. If you are an initiator, I think you'd better find an experienced programmer to help you, or if you are unavoidable in learning and practice, it will greatly blow your enthusiasm. In addition, even if your compiler is equipped with sufficient documentation, a C book is always essential. After all, the documentation is not a good textbook for learning programming.

When choosing books, be sure to pay attention to the standard C from the beginning and use the standard library mechanism. For example, reading a string from the input should be like this:

String S; // Standard C style cin >> s; instead of this: char s [MAX]; / * Standard C Style * / Scanf ("% s", s);

Let's take a look at the book recommended by the solid C programmers. Remember, no book is best for everyone.

In addition, to write authentic C programs, avoid writing traditional style programs with C syntax, new bottles have not much significant meaning.

(Unfortunately, in the Chinese C textbooks on the market, it can be said that it can be said that there is no one, you have to find some English information on the Internet. - Translator)

6. How to improve my C program?

Hard to say. It depends on how you use this language. Most people underestimate the value of abstract classes and templates, but in turn use the modeling mechanism (CAST) and macro. You can take a look at my articles and books. The role of abstractions and templates is of course providing a convenient means to construct a single level or reuse function, but more importantly, they provide a simple, logic service representation mechanism as an interface. 7. Is the language choice is important?

Yes, but don't count on the miracle. Many people seem to believe that a language can solve almost all problems encountered in system development, they constantly look for perfect programming languages, then failing again and again, and frustrating. Other people will derogate the programming language, and put the big silver on the development process and design method, they will always use Cobol, C and some proprietary languages. An excellent language, such as C , can help designers and programmers do a lot, and their capabilities and defects can be clearly understood and treated.

8. Is the ANSI / ISO Standard Board not ruined C ?

of course not! Their work (we) is very good. You can find some 歪 理 in some details, but I personally make this language and the new standard library. ISO C is more good and more stronger than the previous version of C . At the beginning of the start of the standardization process, you can write more elegant and easier maintenance today. The new standard library is also a real gift. Since the standard library provides Strings, Lists, Vectors, Maps, and the basic algorithms acting on them, huge changes have occurred.

9. Do you want to delete some C features now?

No, true. People who ask these questions probably hope that I will answer one of the following characteristics: multiple inheritance, exceptions, templates and RTTI. But without them, C is incomplete. In the past N years, I have repeatedly considering their design and improved their details with the Standards Commission, but there is no one that can be removed and does not cause a big earthquake.

From the perspective of language design, the part I don't like is the subset with C, but I can't take it, because the programs who work in the real world are too big. C and C are compatible, this is a key design decision, it is definitely not a soldier. The implementation and maintenance of compatibility is very difficult, but it does make programmers have benefited more. But now, C has a new feature, and programmers can free from a C style that is more troublesome. For example, using a container class in a standard library, like Vector, List, Map, String, etc., you can avoid the warning of the underlying pointer operation skills.

10. If you don't have to be compatible with C, the language you create will be Java? No, it is far away. If people don't take C and Java as comparison, I suggest them to read the Design and Evolution of C , see why C looks today, use the principle of designing C to test these two languages. These principles are obviously different from the idea of ​​the Sun's Java Development Team. In addition to the similarities of surface syntax, C and Java are distinct language. In many ways, Java is more like SmallTalk (Translator Press: I use Sun's training materials when I learn Java, which clearly wrote: Java uses the syntax similar to C , Semantic with SmallTalk in design. So similar to SmallTalk. So It can be said that Java and C are generic gods, and smaltalk is the heart of the heart. The Java language is relatively simple, this part is an illusion, part of because this language is still incomplete. Over time, Java grows greatly in volume and complexity. It will increase two to three times in size, and there will be some implementation related extensions or libraries. This is a road to the development of each successful business language. Casually analyze a language you think in a great range, I know that it is definitely no exception, and it is actually very reasonable. The upper side is written before Java 1.1. I am sure that Java needs a mechanism of templates and needs to enhance support for inherent types. Simply put, these work should be done for basic integrity. There is also a lot of small changes, most of which are expanded. In the autumn of 1998, I got a proposal from James Gosling (the founder of Java language - translator), saying to increase inherent type, operator overload, and mathematical calculation support in Java. Another paper is a world-class master in the field of mathematical analysis, and HOW Java's Floating-Point Hurts Everyone Everywhere, W. Kahan, University of Berkeley, and how Java's floating point operations are harmful. - Translator) reveals some secrets of Java.

I found that in TV and publications, Java's advocity is inaccurate, and the momentum is annoying. The big code is not Java code is garbage, this is an insult to programmers; it is recommended to rewrite all reserved code with Java, which is a heart, neither realistic is not responsible. Sun and his followers seem to feel that in order to deal with Microsoft's "Imperial Times", they must be so self-sufficient. But insults and fraud will only force programmers who like to use different programming languages ​​to the Microsoft Camp.

Java is not a platform, it is itself a platform. Like Windows, it is also a proprietary business platform. That is, you can write code for Windows / Intel, or write code for Java / JVM. In either case, you are writing code for a platform belonging to a company, which is related to it. The company's commercial interests are pulled together. Of course, you can use any language, combined with the mechanism of the operating system to write programs for JVM execution, but what the JVM and things are strongly biased towards Java language. It is not like a general, fair, language neutral VM / OS.

In private, I will insist on using the portable C to do most of the work, and use different languages ​​to work.

("Java IS Not Platform-Independent, It Is The Platform", B. S is a great impact on C users, and the translator sees in several newsgroups abroad. Some C experts even put this As your own signature file to indicate the attitude of Java and the sick to defend C . In fact, many programmers are not just a kind of tools as a tool, more as a belief. - Translator) 11. How do you view C # language?

I have nothing to say about the C # language itself. I want me to believe that this world needs another proprietary language is not an easy task, and this language is still specifically for a proprietary operating system, which makes me unacceptably. Directly, I am not an obsessed with a proprietary language, but an open official standard supporter.

12. When doing a big project, do you really recommend ADA instead of C ?

of course not. I don't know who this is a rumor, it is definitely an ADA believers, or too frankly, or it is not good.

13. Would you like to compare C with other languages?

Sorry, I don't want it. You can find reasons in the Design and Evolution Of C introductory text.

Many book reviewers invite me to compare C than other languages, I have decided not to do this. Here I would like to reiterate a view that I have always emphasized for a long time: There is no significance of the comparison between the language, and it is more unfair. The reasonable comparison between mainstream languages ​​takes a lot of energy, and most people will not be willing to pay such a big price. In addition, there is also a need in a wide range of applications, maintaining a non-confident, objective independence stand, has a fair selfless belief. I don't have time, and as a c creator, I will never get complete trust in justice selflessness.

People try to bring a long and short language, some phenomena I have noticed again and again, and I am worried. The authors do their best to express their fairness, but they are ultimately unpaired to a particular application, or a specific programmer culture. Worse, when a language is obviously more famous than another language, some unrecognizable stolen beam is started: the defects in the more famous language are intentionally diluted, and they are incorporated by corners; The defect is described as a fatal and hard injury in the non-listed language. Similarly, the technical information about the relatively famous language is often updated, and the technical information of less famous languages ​​is often a few years ago. How does this comparison? So I have strictly limited the language of C language to be in general particularly specific areas.

In other words, I think C is the best choice for most people to develop most applications.

14. Others often take their language with C , which makes you feel uncomfortable?

I really feel uncomfortable when these are incomplete or for commercial purposes. Most of the most widely comparative reviews are published by some languages, which is the purpose of the Z language, with the aim of prove that Z is better than other languages. Since C is used extensively, C usually has a name on the blacklist. Typically, such an article is caught in the product provided by the Z language supplier, it has become a means of its market competition. Shocking is that there are quite a lot of such comments to reference those employees working in the development z language, and these can't afford the test articles are nothing more than wanting to prove Z is the best. Especially in these comparisons, there are some factors that have some zero dispersions, (so more deceptive-translators), after all, there is no language is best in any case. C is of course imperfect, but please note that the fact that specially selected, although it seems correct, it is sometimes completely misleading. When you see the article in language comparison, please pay attention to who is written. Is his expression not based on facts, in a fair as a criterion, especially the criterion of the judgment, is not for every language quoted. All fair and reasonable. This is not easy to do.

15. When do you do a small item, is C ?

I think it is not. In addition to issues caused by lack of good C compilers, I have never seen which project C will be more appropriate than using C .

(But now the problem caused by the C compiler is not negligible. When you see the same function, the C program can perform code volume ratio C, it will feel much more, it will feel much slower. - Translator )

The following content from Visual C Developer's Journal Editor Elden Nelson's interview with B. S in March 2000 16. What do you do if you have the opportunity to design C language now?

Of course, you will never re-design a language, that is meaningless, and any language is the product of its era. If I let me design a language today, I will still consider the graceful, efficiency, versatility, and complexity of people and the preferences of people. It is a huge impact on their habits to their preferences.

Now, I will find a simple grammar, I will limit the conflict of type system to few cases in a few cases, and you can easily discover these issues. This will easily disable unsafe operations.

(B. S is: For bad code, even if it can't be completely banned, at least let it be white in the world, not hidden in the dark corner, dark arrows. C actually provides such a mechanism, For example, if you use it like ReinterPret_cast (Pointer), it is obviously very bad expressions, others will easily find the problem. Only C still allows you to use traditional, C style modeling mechanisms, There are many people who have always used this old style, so there are more troubles. B. S means that if it is now able to ban the vintage style! As a language designer, I am afraid it is Without this opportunity, but as a language user, there is still a big hope to improve your code. Where is it, it should be what we thought. - Translator)

I will also make the volume of the core language as little as possible, including the key abstraction characteristics of classes and templates, and put many other language features in the library. Of course, I will also guarantee that the core language is sufficient, so that the libraries are also sufficient to use this core language. I don't want the standard library to create a mystery mechanism that does not belong to the language itself. In addition, I will make the definition of this core language more accurate. (There are many new languages ​​to use "mystery mechanisms that do not belong to the language itself", such as VB and Java. From theory, this is a nearly rogue, so B. S is not good. But The most important thing from the practical departure is not hurt. This may be the most difficult, because once there is something obviously good and promising, everyone will swarming to use it, and there will be any incompatible fixes.

I believe that these ideas are very similar to what I originally designed C , and it is also these ideas to guide C C in the past 120 years. Of course, I think there is still nothing to make me feel like "perfect language."

17. What are you expected to do in C , will you delete something?

Unfortunately, although some things should be thrown away, I am afraid it is hard to really delete anything. The first thing that should be abandon is the shape of the C style and the type truncation conversion. Even if it is not prohibited, the authors of the compiler should also give this behavior to a strong warning. I hope to completely replace arrays with something similar to Vector, but this is obviously not willing. However, if the programmer can take the initiative to use the Vector to replace an array, it will benefit from the array. The key is that you don't have to use the most complicated difficult skills in C , now there is a much better alternative.

As for the main features, I didn't want to remove anything. In particular, those main features that distinguish C and C are probably not wavy. People who usually ask these questions are hoping that I will pick out the mechanism such as multi-inheritance, anomalies, and templates. So here I want to make a clear understanding, I think the multi-inheritance mechanism is necessary for the static type language to achieve inheritance, the abnormal mechanism is the correct way to deal with the error in the large system, the template mechanism is the type of security, exquisite And efficient professionals designed for a panacea. We can pick up challenge in small details, but in terms of big aspects, these basic concepts must stick.

Now we are still studying standard C , which is also developing updated, more interesting programming techniques based on the characteristics provided by the standard. In particular, people have just started using STL and abnormal mechanisms, and there are still many high-efficiency and powerful techniques, so they don't have to hurry to increase what new mechanisms.

I think the current focus is to provide a lot of new, more exquisite, more useful libraries, which is huge. For example, if there is a library that can be widely used, more refined supporting concurrent programming, it will be a big gospel - C style thread library (for example, pthread - translator) is not good enough. We can also match a variety of other systems, such as SQL, and different component models. People in the field of numerical calculations seem to have been in front, similar to the efficient and exquisite library like Blitz , Pooma, MTL has achieved extraordinary achievements. (Translator has visited BLITZ and Pooma's homepage, the former is a high-performance math library, which is said to be up and down with Fortran 77, while supporting a large number of C features. I think anything is in the field of numerical calculations. People know how great this. Pooma is a project that specializes in studying C parallel mathematics algorithms. Its outlook is even more unlimited. The translator is very agree with this concept of B. s. - Translator) After sufficient experience, we can better decide what adjustments should be made.

18. Obviously, the world has changed in these years, and is moving towards a Web-centered, distributed calculation as mainstream. So do you think C still maintain its position? Programmers can use several special languages ​​(such as Perl, JavaScript) to completely replace a generic language? (C is this universal language - translator) What should I do with the new computing mode, C and its standard libraries?

It has never been suitable for all work, I am afraid that there will be no later. The actual system is usually constructed in a variety of languages ​​and tools. C just wants to be one of several languages ​​and tools, and they can be complementary to C when some dedicated languages ​​are particularly highlighted in their field. That is, I think that if most of the current dedicated languages ​​can work together with the C library in specific areas, they will be better. The scripting language usually leads to a difficult-to-maintain code, and there is no other room for the structure, scalability, and maintenance of the program.

I don't dare to affirm whether the future code is really a web-centered. Even if the system directly processed the Web is mainly composed of a program module that handles local resources, such as IP connections.

Geographic distribution and server software's high dependence on concurrent mechanisms are indeed a challenge for the builders of the system. Some libraries for the above problems have appeared, maybe we will see that they are finally standardized. Of course, some original operations and guarantee rules should be added to the core language to provide better support for these libraries.

Overall, for web and networks, we need a real system / network-level security model. The scripting language that is expected to be JavaScript implementation this model is tantamount to dreaming. Note, I didn't say C to provide this problem solution. C center of gravity is an efficient access system resource, not anti-fraud.

19. How do you see C future? Will it decline in the next 10 years? Or do you basically keep the present form? Or in the form of development varies?

C has the best future. Use it you can write a great code. In addition to deliberate malicious fraud, C will still be the best language for developing high performance, high complex system. As far as I know, there is no language that can be unified in universal, efficiency and exquisite three aspects, and C .

I didn't see the sign of C fading. It will grow continuously in the future I can foresee. Of course, we will see some changes in the next ten years, but it will not be as significant as you think. Like each language, C will also grow. "Language experts" require improvement to improve, but the basic requests of system developers are stable. C will improve, but these improvements will be mainly to reflect the lessons learned from practice, but will not be hipster in order to chase the wind. In order to more efficiently use new programming technologies, such as general programming techniques, some small features may be added. There will be a lot of libraries, I expect a new, better library support mechanism. I hope that new extensions are mainly concentrated in the general characteristics of abstract, rather than providing specific mechanisms for certain special tasks.

For example, the concept of "attribute" is useful, but I don't think there is a place in a general programming language. This concept can be easily supported with a set of standard C . If we feel that the support of the concept of "Properties" is not satisfactory, it will not immediately ran to increase the attribute mechanism in the language, but carefully consider how to improve classes and templates to help library designers are as close as possible. "Properties" concept. Perhaps a satisfactory answer to this issue by improving the function object.

In order to keep C to keep flexible and variable in the next decade, it is a basic point to do not let standard C have a hipster or commercial. A large part of the increased characteristics can be achieved by using existing standard C development new libraries. Also, many features that people are eager have been included in standard C and are supported by the latest compiler. For many programmers, the best way to improve the quality of code is not what language extensions are pursued, but it is good, slowly taste the latest C technical books (unfortunately, we have no such opportunities so far - translator ).

20. How do you view the prosperity of scripting languages? In particular, Python seems to provide a simplest way to learn OO technology. Some languages ​​are very good. For example, Python, I like it very much. But I think you are not exactly the same as the OO technology you have learned from different languages. Of course, every professional programmer needs a few languages ​​and understands the differences between programming and design technology in various languages.

In my opinion, the system built with scripting languages ​​is different from the system built with C . The technical difference between the two types of languages ​​is obvious. There is no universal part in OO technology, it is critical to efficient construction of various systems.

21. Is there any new feature to add some new features to standard C to support distributed calculations?

No, I don't think there is this necessary. Almost solve the problem with a better library. Most, in order to support this type of library, we may add some low-level original operations and rules.

22. Is there a possibility of a portable binary interface in the future C ?

If you say "portable" refers to the portable transplantation of hardware and block operating system, I want to answer is not. We can of course design an interpreter or virtual machine (like Java practice - translator), but in this way, the ability of C will be weakened because it cannot access system resources in the best way. I really hope that something that can be seen in the future is Platform Abis. For example, some people are working to define C ABI for Intel's new IA64 system, I think these efforts will get huge support from users.

It is a very meaningful thing that can be compiled with code generated by different compilers.

23. In a lot of popular fields, C is gradually losing light, because it requires people to spend a lot of effort to deal with some basic work, such as managing memory (because there is no garbage collection mechanism), the dependence between management modules ( Because there is no package mechanism), the version of the component is managed. C lacks some modern languages ​​have considered the characteristics of standards. For example, the coolest Java language in rumors pay special attention to these issues. So do you solve these issues will cause the development of C from its fundamental purpose? What should C develop to ensure that we have a reasonable return in this language, rather than being forced to re-use another language? I haven't noticed that C is less than before. Instead, I see the indicator indicates that the use of C is still steadily increased. However, this base is very stable growth and the continuous improvement of standardity, transplantability and library, and there is no deceptive news effect. I think what you said is just a phenomenon in market sales and news.

If you need a garbage collection mechanism, you can insert a garbage collector in the C application. Many free and commercial garbage collectors have proven to be excellent in important practices.

If you don't want to use garbage collection mechanisms, it doesn't matter. You can use standard containers, which greatly reduces the need for explicit allocation and recycling memory. This way, using modern libraries and modern programming styles, you can avoid most of memory management issues.

The same technique can also be used to avoid management issues of general resources. Not only memory will leak, thread handles, files, mutex, network connections, etc. are important resources. In order to establish a reliable system, these resources must be properly managed. If you feel that there is a garbage collection mechanism to solve all resource management issues, then you'd better wake up from the dream.

C provides a number of mechanisms to manage general resources. Key means - "Get Resources is initialization" - you can use function objects to manage lifetime issues. The local constructor and abnormal mechanism of the object provide support for this technology.

Some languages ​​are always describe C with a back method of ironic comics, but C is actually much better. Especially, I think many other features have been flooded. In C , it usually is easy to simulate it. Conversely, new languages ​​are always increasing in the process of promotion, which is why it is widely used from a language to be widely used, and its volume usually increases two or three times.

At present, the most personal and organized, the best investment of C is to better understand standard C and modern C design programming technology. Most people use C ways to actually stay in the mid-1980s, even more old than that.

As for module-dependent issues, my point of view is that there should be a clear boundary between the work of programming language and the system, depending on the relationship should be separated from the programming language as much as possible, but by the system.

I don't think that the problem of forming a version should be solved by a programming language. This is a problem in a system category. In language, you should resolve it by providing the corresponding library. C has such a mechanism. Solving such problems will not deviate C from the track. But adding a lot of special features to C will cause C deviate from the track, and it will be a reverse in terms of maintaining portability and platform independence.

24. Standard C has been launched for a period of time, Java also stepped forward and achieved significant progress, how do you compare Java and C now? What do you think of Java wants to become like a language like C ? Do you have learned from Java? Is there any Java feature that you think can be absorbed by C ? I don't compare the language. It is very difficult to do this job and have few professional levels.

I think C progress will be based on the problems encountered in their users and their own logic. Of course, some ideas in other languages ​​will also be considered, but they cannot be simply passed down. You must examine those mechanisms in technology and ideological backgrounds, and find the best solutions to support these technologies in C .

Sometimes the best choice is to use several languages. After all, there is no language to put it four seas. C is now in the future, will continue to be one of the best languages ​​in a wide range of applications. However, we can't be pulled down, and you can't put all possible features to C to open to the public. I think Java and C will now be very different in the future, the syntax is similar, but the object model behind is significantly different.

For me, a very important difference is C has an ISO standard, while Java is a proprietary language.

25. In those years that Java have just appeared, there are many spoofing speeches that it will be the ultimate language and will replace C . Do you think Java has an impact on the followers of C in the past two or three years?

It is also visible everywhere about Java now. The development of Java in the past five years, the fanatical public seems to think that Java will end alteration of not only C , and there are all other programming languages. But on the other hand, the use of C is still continuing to grow. I don't think that Java's impact on C has made people turn to develop the Java tool library to develop the Java tool library. Java doesn't have much new thing for those who learn programming, so there is no impact on the definition of C . In that field, Java has worked hard to catch up. For example, I think Sun will add a similar template to Java sooner or later.

People should recognize how different C and Java goals are. Taking C design concepts to measure Java, or measure C with Java design philosophy, it will not be good.

At the end of the interview, maybe I should show the attitude again: C is still my favorite language, when you write the code, you will find that there is no language that can achieve such a wide range of applications and platforms. Exquisite.

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

New Post(0)