I said VB. Net (middle)

zhaozj2021-02-08  220

I said VB. Net (middle)

(Author: Green Apple studio compilation, 2001 at 14:47 on March 7)

Easy-to-refractive intermediate language written in VB, C # or other .NET language, VS.NET code is compiled into an intermediate language (IL). When the application runs, an instant compiler handles IL code and compile it into a machine language. This means that it is theoretically creating a .NET runtime for platforms other than Windows, but now there is no official news about things. One defect in the intermediate language is that it is like the VB version of VB5, it is easy to be compiled. This possibility makes many developers universally question the security of the .NET architecture. The CLR affects the code inside and outside the IL level, which will benefit all languages ​​that use CLRs. However, language is only related to how the code is interpreted as IL, and the optimization of a particular language can be written according to the syntax of a particular language, so that the performance between the .NET language is small in technology. In any case, the general blueprint is beautiful. For example, CLR comparable to the VB's debugging and monitoring tools and C #, which did this because they were the same tool. The CLR provides an unprecedented cross-language integration, including the ability to inherit the code across language. All languages ​​that use CLR share a universal type system that makes it easier to develop applications using multiple languages. I don't like to translate C API to translate into VB in the form of VB, so I greatly appreciate the benefits of common type systems. The code running in the CLR is called managed code, and the memory used by the management code is completely controlled by the CLR. The management code brings a lot of benefits, including cross-language integration, cross-language exception handling, and simplified components interactions. Visual Basic is restricted to work only by managing code, however C # has the ability to jump to non-managed code (outside of the running library), and can do things like pointer operations. This is one of the different conditions of VB and C #. How important this ability depends on what you want to do. The architecture difference caused by CLR is more profound than a crosslinary integration, sharing function, and managed code. First, the support structure of Visual Studio.NET is not COM. In addition, all things in VB.NET, even strings are objects. Because of these and other reasons, Microsoft changes the way to support the structure of the structure. The COM implements a reference count scheme, which is incremented by the counter each time you reference an object. When an object reference exceeds a scope or is released, the counter is decremented, and this object is terminated when the reference count is reduced to zero. Microsoft claims that the cost of reference counts is too large under the .NET architecture, so that it cannot be implemented in .NET, it gives up the reference count transfer and use garbage collection. Garbage collection requires a new architecture CLR garbage collector mainly to monitor resources for a program that looks for useless objects when the available resources reach the determined threshold and clear these objects when they find them. A great advantage of garbage collection is that you no longer need to worry about most common loop references, that is, the child object references the parent object, and then the parent object will refer to the child object. Under the reference counting scheme, the loop reference makes two objects that cannot be released and cleared. However, the garbage collector will discover cyclic references and remove them. This also means that the object is not needed to immediately clear the object when the last reference of the object is released. A consequence of garbage collection is: You can no longer count on a class of Terminate events can be issued at an appropriate timing. In fact, if the thread is blocked, it may not issue a Terminate event at all. The determination termination provided with COM is reversed, which is called uncertainty. The lack of determination termination, and because the garbage collector rearranges and compresses the fact that the memory cannot be used, a fierce debate is stimulated in the news group. I think these new restrictions may hate you, because you have to rely on determination to terminate; it is also indifferent, because you don't rely on Terminate events. Garbage collection is not a matter of Wan Spirit, and the weak reference still needs to be considered.

From the reference count to garbage collection just the support structure of Visual Studio.NET is not one of the facts of COM. You can use COM objects in VB.NET, such as the ActiveX server or ActiveX control. However, you must access these objects by packaging. I have heard the term "packaging" at any time, you should understand that you face performance losses and the behavior of the object may vary. If you plan to transplant an engineering that uses a lot of COM objects, you need to carefully test and plan, and you may need to re-plan the application to be transplanted. Frankly, you have to have a setback preparation. Remember the process of migrating from VBX to OCX? I remember that my mental doctor also remembers. I will go to see him soon ;-) The language itself has far exceeds the changes in the architecture. Most changes do not make sense, but I don't think all changes are. Previous versions of VB allow you to do a lot of things in many ways, so that unified coding criteria either do not have something to force. Microsoft has made a lot of change to VB is "clear". In many cases, you have a good way to do something, now there is only one. Billy Hollis provides a detailed list of grammar changes, including discarded keywords, but some things need to be repeated here. First, the default method of transmitting data to process parameters is made by reference (BYREF) into a pass value (BYVAL). This change is mainly because references to be much larger than the risk of passing. Its risks are mainly due to the data in the process of calls that may be not intentionally tampered with. You can still pass data by reference, but this change allows you to modify the new default call method to use reference. The SET statement disappeared, the SET statement disappeared. In VB.NET If you need to pass an object reference to variables, just one equal sign, the object is considered to be the same as other values. This is cool, but there are side effects: the default property disappears. For example, you can no longer reference a property in this way: Text1 = "What, me Worry?" As an alternative, you must explicitly reference the properties: text1.text = "what, me worry?" May not seem This change is needed, but it is indeed remained off default properties. For example, suppose you have an object variable called Objfoo, no set statement, the reference to the following statement sets the ambissions: Objfoo = text1 This statement should be set to the Text1 reference, or the Text attribute of Text1 Fill Objfoo? You can't be sure, the compiler cannot be. Abandoning the SET statement simultaneously requests to abandon the default properties. There is a change I don't like: You can no longer declare the Property Get and Property SET procedures in different scopes. Note that VB.NET does not have a Property Let statement: objects and values ​​are used with Property SET. This means you can't use a Friend Property Let process to correspond to a public property get. There may be trouble when using VB to establish components. Many component developers create a Friend Property SET process to allow their applications to change a value, but provide the Public Property GET process to enable their client programs to get the value. I hope that I can find a suitable reason for this change, but I can't find it. Microsoft said that it strives to keep language clear and modernize - it is very doing well in most cases - but this scope problem and several other questions are confused. For example, while ... Wend should have disappeared very early because DO ... loop complete the same function.

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

New Post(0)