Anders Hejlsberg talks about contracts and collaborative work

xiaoxiao2021-03-06  79

Contracts and Interoperability Contract and Collaborative Work Ability

A Conversation with Anders Hejlsberg, Part V Anders Hejlsberg Interview

Bill Venners With Bruce Eckel Interviewer: Bill Venners, Bruce Eckel

November 3, 2003 Time: 2003-11-3

Summary

Anders Hejlsberg, The Lead C # Architect, Talks With Bruce Eckel and Bill Venners About DLL Hell and Interface Contracts, Strong Names, and The Importance of Interoperability.

Summary:

Anders Hejlsberg is the C # of C #, in Bruce Eckel and Bill Venners, he talked about "DLL hell" and contract theory, strong name, and collaborative work.

DLL Hell and The Theory of Contracts

"DLL Hell" and contract theory

Bill Venners: To what extent is "DLL Hell" a failure of interface contracts to work adequately in practice If everyone fully understands and adheres to the contract of the functions of a particular DLL, should not updating that DLL in theory not break any? Code?

By how much, "DLL Hell" is a failure when the interface contract is fully working in the actual work? If everyone fully understands and follows a specific DLL functional contract, should it be theoretically, should the DLL should be upgraded to avoid damage to certain code?

Anders Hejlsberg:. Hell has many tortures One aspect of DLL hell is that you do not adhere to your promised semantic contract You do something different than what you did before, and therefore you break code That's actually probably not the biggest issue that.. we face. The true problem with DLL hell is that we do not allow you to have multiple different versions of a particular DLL present on the machine. Once you upgrade the DLL you upgrade everybody, and that's a mighty big hammer.

"DLL Hell" makes us more torment. On the one hand, you won't follow the semantic contract you have promised, you have to do something and before, so you will destroy the code. Maybe this is not the biggest problem we face. The truly trouble of "DLL Hell" is that we don't allow you to place a plurality of different versions of a DLL on the same computer. Once you update this DLL, you must upgrade all users, this is a very huge workload. Bill Venners: But if The Contract Is Followed, Shouldn't The Most Recent Version Work for All Users of That DLL?

So, in order to follow the contract, the latest version should not work for all users of the DLL?

Anders Hejlsberg:.. In theory, yes But any change is potentially a breaking change Even a bug fix could break code if someone has relied on the bug By the strictest definition you realize that you can do nothing once you've shipped..

In theory, it is like this. But any modification may have potential destructive. Even a bug correction can also destroy the code, if the user has dependent on this bug. Through the most stringent definition, you will realize that once you have already released (DLL), you can no longer make any modifications to it.

Versioning is all about relaxing the rules in the right way and introducing leeway. The absolute answer, the only way guaranteed to not break anything, is to change nothing. It is therefore important to support side-by-side execution of multiple versions of the Same FunctionAL, ON The Same Box or Even The Same Process. Side-by-Side Execution IS One Option We Support in The Older DLL Model.

With the right way, and have some tradeoff, this limitation will be relaxed by the control of the version. If you want an absolute answer, then the only way to ensure that no destructive is not to change. Therefore, the parallel execution of multiple versions of the same function - is very important in the same "子", or even the process - support. Parallel Execution is a feature we support in .NET, it is not available in previous DLL mode.

Strong names in .net

Strong name in .NET

Bill Venners: I Assume You Use strong names to ide you want. How do Strong names work?

I guess that you are using a strong name to identify the version of the link library you need. So how is the strong name work?

Anders Hejlsberg: Strong names have a logical and physical part The logical part is composed of the namespace and class names Actually, from the Common Language Runtime's [CLR's] perspective, namespaces do not really exist We can pretend that namespaces exist in... the programming language, but from the CLR's perspective, a class name may have dots in it. that's the logical name of the class. The physical name includes the name of the assembly that the code lives in, the version number, the locale, and The Cryptographic Key Associated with the name. Strong name is divided into two parts: logic and physics. The logical part consists of namespace and class name. In fact, from the perspective of the Public Language Runtime (CLR), naming space is not true. We assume that the namespace exists in the programming language, but from the CLR angle, a class name may contain some points. This is the logical name of the class. The physical name includes the name, version number, area information, and key of this name where the code is located.

You can refer to a particular type in a particular assembly with a particular version or with a particular strong key. You can literally have a guarantee that you will either get precisely the implementation you were compiled against or nothing. Or, you can relax parts of The strong name. You can say, "I'll Take Any Version Later Than Some Version."

You can reference the specified type in the specified program set by specifying a version number or a specified key. You can define if you have compiled whether something compiled is accurately implemented. Of course, you can also weaken some parts of the strong name (restrictions). You can say this: "I can use any versions lower than a version."

Enforcing Semantic Contracts

Strengthen the semantic contract

Bruce Eckel: Have you coming Up Ways TOEFORCE SEMANTIC CONTRACTS?

For how to strengthen the semantic contract, what do you have to interested?

Anders Hejlsberg: I ​​think the most promising ideas are existing and new developments in pre- and post-conditions, assertions, invariants, and so forth Microsoft research has several ongoing projects that we continually evaluate We have looked at some pretty concrete proposals... In the end we realized that-as is the case for almost any truly important feature-you can not just do contract enforcement from purely a programming language perspective. you have to push it into the infrastructure, the CLR, the Common Language Specification, and therefore all the other programming languages. What good is putting invariants on an interface, if it is optional for the implementer of the interface to include the code of the invariant? So it's really more at a type system level than at a programming language level , But this, we're not going to address it. we are not doing what in the next release It has existed, such as pre-conditions, post-conditions, assertions and invariates. We have assessing some of the projects that Microsoft Research Institutes are working, and there are some considerable recommendations, and finally recognize - this is the case for any truly important feature - you can't just be used from the perspective of programming languages. Contract strengthening. You must put it in the infrastructure, public language runtuar, and common language specification, and then turn to all other programming languages. If you include an invariant code when an interface is implemented, what is the benefit of the invariant placed on an interface? It is a type system level instead of programming language level, but this does not mean that we will not consider it (the translator Note: refers to the programming language level). In the next version, we will not do this, but go on this road, it will end the basic features in C #.

Interoperability

Collaborative work

Bill Venners: You Have Said That Where Java Is Striving for Platform Independence, .NET IS STRIVING for Interoperability. What do you mean by interoperature

You said that Java is unrelated to the platform, and .NET is working hard for collaborative work. What is a collaborative work ability? Anders Hejlsberg: Interoperability means several things First, it means interoperability between various programming languages ​​in .NET Our design goal was that the .NET CLR would be language neutral, that it would support multiple programming languages ​​Java, by contrast, was one... programming language and execution machinery for that one programming language. The CLR supports many features that have surfaced in only a few programming languages, for example, pointers. Unsafe code in C # and managed C have pointers, but Visual Basic and JScript do not. Yet all the infrastructure for pointers is in place in the CLR. Language interoperability is about the realization that as much as we try we're not going to convince everybody that you just program in one programming language. And honestly the way that the industry moves Forward and INNOVATION HAPPENS IS BY New Programming Languages ​​Being to try to install it. We're Going to Encourage IT.

There are several ways to cooperate with work. First, it refers to the cooperative work capability of different languages ​​under the .NET framework. Our design goals are: .NET CLR becomes the core of language, allowing it to support multiple programming languages. Conversely, Java is just a programming language, and its implementation mechanism only supports a programming language. CLR supports many features that only have several programming languages, such as pointers. The unsafe code of C # has a pointer, but VB and JScript are not. However, all of the basic support of the pointer is placed in the CLR. We will strive to achieve collaborative work capability in multiple languages, rather than people believe that you only use a language programming. Honestly, industrial progress and innovation emergence are accompanying the invention of emerging programming languages. We will not stop, but will advance this process.

Another aspect of interoperability is interoperability with existing systems. Back when we were in the Java business, one of the things that we tried to improve upon in our Java VM was interoperability with existing code, because we just think that kind of interoperability is so key . And we still think that. in the CLR, therefore, we have focused very heavily on interoperability with DLLs, COM, OLE automation-all of these technologies that any piece of code was written in before .NET. Secondly, it can be referred to There is a synergistic work ability between the system. Looking back in Java mode, one of its goals is to work hard to improve the Java virtual machine, just to work with the code, this is precisely because we see this collaborative ability. So this idea, in the CLR, we are very concerned about the collaboration with DLLS, COM, and OLE - all the code to use these technologies is completed before .NET.

It goes back to what I said earlier [In Part IV] that the key today is leverage. We've got to find ways for our programmers to leverage existing systems and code. Achieving that goal means having great interoperability, because how else can you Levee® That Puts US IN A Complete Opposition To Java's "100% Pure" ViewPoint of the World. And i think we're doing the right thing with it. I really do.

I have said (in the fourth interview): Currently, the key is "leverage". We have to find ways to "shake" existing systems and code for programmers. Realizing this goal means having a good cooperative work ability, do you have any way? However, this also pushed us the opposite of the "100% purity" view of Java, but I think we are doing so correct, definitely.

If You Contrast What IT Feels Like to Call A DLL from Java, You'll Very Quickly See What I Mean. It is Very Complicated To Use Jni, And i Think It Is A PiTy That Haven't done anything better there, because so much more could be done. It does not make sense that the minute you have to interoperate with any other system in the world you enter this netherworld that is quite possibly more complicated than straight C or C programming. you have to run all these tools that spit out some header files. you have to remember to call this and that. If you want to dereference an object, you better remember to lock it down else it could, in one out of a thousand cases of running your program, move when the GC somehow happens to sweep right then. Then you can never reproduce it again. If it's OK for a system to do garbage collection and type safety and all, why should not it help you interoperate? It Just Seem Like Such a Reasonable Thing to Do. If you compare the way to call the DLL in C # and Java will be very I understand what I mean. JNi is very complicated, I can't do more regrettable for them, in fact, it can be available in this area. At this moment, you just have entered hell, it is much more complicated than directly programming with C or C , which is meaningless. You have to run a lot of tools to pick out some headers, you must remember calling this, calling that. If you want to release a reference to an object, you'd better lock it first, otherwise, the garbage collector may happen to clear it - your program is running, this possibility is one thousandth. If this is, you can't let it regenerate. If the system can manage the garbage collection, type security, etc., isn't it helpful to work with collaborative work? This is precisely a very worthwhile thing.

Bill Venners: From my perspective looking in from the outside of both Microsoft and Sun, I've noticed a cultural or philosophical difference between the two companies that I think influences the design differences between Java and .NET At Microsoft, I get the sense. that the prevailing view is that software is written to program the hardware-the box, the device, and so on. I think that's a totally reasonable perspective given how Microsoft makes its money. By contrast, even though "The network is the computer" was a Sun marketing slogan, I find that attitude really does exist in Sun culture to a great extent. The network offers the services, not the box. And Java is really like an object-oriented layer sitting on top of the network stack, aimed AT ABSTRACTING AWAY The NetWork. In the perspective of my outsiders, I examine Microsoft and Sun, I found that the difference between the two companies in culture and philosophy led to the difference in Java and .net in design. I feel that Microsoft's mainstream view is: After the software is written, it is used to control hardware, such as some cockroaches, equipment, etc. I think this is a completely reasonable explanation for Microsoft why money can make money. Although the "network is computer" past is just Sun's market slogan, this awareness is indeed a considerable amount of accumulation in its corporate culture. The network provides services, not the "scorpion". Java is indeed like an object-oriented class, which is dedicated to stripping and network-related heterogeneous components.

Anders Hejlsberg: What's interesting is that any Java solution you care to point at in the real world has platform-specific stuff in it I know of nothing that is pure Java only, that does not somehow rely on some other component Any of.. the web stuff relies on Apache or some web server, some database, and some form of interoperability with those systems. It's just ridiculous to think that the whole world is pure Java. The whole world is about putting systems together and making them work. and that's why the whole world is so excited about things like web services, because they're a wonderful way to interoperate. and we just think interoperability comes in many forms and we should just push as hard as we can and make it better and easier for Systems to Interoperate. Interestingly, you picked out any Java solution in the real world to find out that it contains things related to the platform. I haven't found anything is pure Java, and I don't rely on other components at all. The web program depends on Apache or other web servers, as well as databases, and other systems to establish certain forms of collaborative work relationships. I thought that the whole world is pure Java, which is very ridiculous. The world puts all kinds of systems together and then let them work together. This is the reason why the world is excited for Web Services - they are a wonderful way to achieve collaborative work. We believe that collaborative work capabilities will appear in many fields, we will try our best to make a better system better and work earlier.

Bill Venners: Actually, The Scenario You Just Described Is Exactly What I Have on The Artima.com Server. I have Tomcat Running JSPS, AND Tomcat Does Talk to Apache.

The fact is true, what you have depicted is the scene when my Artima.com server is working. I use Tomcat to run JSPS, let Tomcat and Apache dialog.

Anders Hejlsberg: and you probably has a database.

Maybe you have a database.

Bill Venners: Yes, the Java application also talks to a database There is platform-specific stuff in the sense that the Java API implementations use JNI, but the code of my application is all Java And in my case even the connectors from Tomcat.. To Apache and the Database Are Pure Java, Because The Use Sockets To Interoperate, Not JNI. Yes, Java applications also communicate with database communications. In the Java API, this is the platform is related to the platform, but my application code is all Java. In my solution, even Tomcat and Apache, the database's connector is written in pure Java because they use sockets instead of JNI to work together.

Bruce Eckel: One of the Things That I Like About Python Is That Its if You Want to Be Platform Independents You Can, IFORM, You CAN.

One of the reasons I like Python is that it tells me: If you want the platform, you can do it; if you want to talk to the platform, you can do it.

Anders Hejlsberg: Yes, EXACTLY. It Should Be your choice.

It is completely correct, your choice should be like this.

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

New Post(0)