C #, nature progress

zhaozj2021-02-17  79

With the retreat of Visual J , Microsoft introduces C # to fill this gap.

Michael L. PERRY

Mallard software designer

August 2000

Microsoft has far from the Internet's new field of view with today's online content. Microsoft predicts the future Internet is a cross-associated service that is developed from different languages ​​in different languages, which can be run on different Internet operating systems.

The company is provided with the new world of boldly .Net platform. In fact, .NET is not a platform in traditional sense; it is not a public hardware or software system. .NET is actually a set of protocols that allow Internet applications to utilize different services running on different machines.

The result of the new Microsoft's new strategy is the next generation of Microsoft Visual Studio will have redesigned languages, especially support .NET platforms. Java will no longer be in this package, Visual J will not have a new version. Don't worry, Microsoft will launch a new language C # to fill this gap. The company has used its best resources, including star language expert Anders Hejlsberg to develop C #.

Non-him is: Anders Hejlsberg, Language Architecture Designer

Consider the experience of Hejlsberg, will not surprise Microsoft to give him a heavy responsibility. After all, C # will not be his first major event in software development.

As the chief architect designer of Borland, Hejlsberg secretly turns Turbo Pascal into an object-oriented, a real visual environment and an excellent database access feature application development language. Delphi once used to be touted as "VB killer" is still Borland (now for Inprise / Borland) fist products.

Microsoft hired Hejlsberg with a generous salary, stock subscription rights and huge franchise bonuses, Borland has proposed the accusation of new members by unfair means. Borland also claimed that there is a small detail to support allegations - Hejlsberg is developing "Delphi for Java". This lawsuit finally closed with Borland's victory; but from that time, Microsoft was already working in Hejlsberg.

Hejlsberg enriches Microsoft's Java products; it is particularly concerned that in order to keep up with the current version number of other Visual Studio languages, others will increase their version number from 1.1 to 6.0. In fact, the jump of this version number is not exaggerated between 6.0 and its previous version. The function added by Hejlsberg has made this language into a powerful Windows application development platform. The added features include access to the Windows API; therefore, programs that use these new features no longer have portability.

Hejlsberg changes to Microsoft's Java products to promote Sun accumulated Microsoft violates the Java license agreement. Sun claims that the Visual J language extension does not maintain Java platform neutrality, but locks developers on the Microsoft platform. Although Microsoft's Visual J is actually the best Java compiler, and the company's virtual machine (executing the Java byte code run module) is the fastest virtual machine, but Sun's lawsuit has blocked Microsoft competition in the Java stage.

Microsoft's response is completely returned from Java and replaces it with a new foundation Internet platform - .net - and a new banner language - C # to replace it. Anders Hejlsberg is the natural choice for completion of the work. Prove a reasonableness of a new programming language

Recently, some news about C # debate claims that developers will not accept another programming language. Although there are still several useful languages ​​available for developers, there is still a space to accommodate another language - if it fills still not satisfied. A new language is just another tool for professionals available to create a software solution. Let us analyze the goals of Microsoft as C #, as well as other languages ​​that have not been met so far.

Fast application development: One of the most important targets that Microsoft is C # is the support of RAD. The Internet application must be developed as an Internet; a new language must be easy to learn and debug, and must generate an easy to update code. Although Delphi and VB are excellent in these, C is not so successful. The language itself is complicated and difficult to master, and there are very few useful C libraries to provide a simple interface. In addition, C manual memory management and complex type conversion model make it difficult to debug.

In addition, as we will see below, C does not prevent potential issues caused by the incompatibility of the version. Although Microsoft and Borland have made great efforts to this language, C is still not suitable for fast application development.

Cross-platform deployment: According to the definition, the Internet language should support cross-platform deployment. Because the Internet is a network of different systems, the service must be deployed to a wide variety of hardware and software. In addition, client software should be able to run on multiple types of devices, including PDA and cellular portable wireless phones. This flexibility is actually a challenge to all languages ​​other than Java. VB, especially only Windows applications running on an Intel microprocessor-based machine. Delphi is also subject to the same limit. Delphi for Linux will not be released soon, but it does not support Internet devices. VB and Delphi do not meet the target of cross-platform deployment.

Access platform Inherent Resources: According to Microsoft, developers need to access the platform inherent resources. This access is sometimes essential for writing powerful target applications. Visual J 6.0 allows developers to access Windows API, Java usually does not allow this access. Java provides a cross-platform deployment by defining the minimum cential criteria for each virtual machine. Java developers write code based on this weakening standard, and cannot take advantage of only certain platforms to provide more powerful services. In this way, Java cannot meet this goal of providing access to the inherent resource of the platform.

Support COM and .NET platform: Microsoft has supported the COM and .NET platform to identify the most important goals for C #. Of course, there is currently no language support .NET platform because it is still building. Unlike .NET, COM has been a considerable period of time, but it still lacks powerful language support. Most languages, including C and Delphi, require developers to create an additional IDL declaration, a class factories and dedicated modifications for each COM object they created.

Some language vendors have provided some wizards to automate many common COM and OLE tasks, but these tools do not completely hide the complexity of COM. VB has indeed successfully hidden the complexity of COM, but this is exchanged at the expense of sacrificial function. VB not only lacks the power to object-oriented language; it is also unable to support COM's low function - for example, multiple interfaces, aggregation, and custom arranging. In short, there is no existing language like C # to fully support COM. Although these four goals are quite high for a new language, hejlsberg has taken out their best experience in the work to ensure that C # implements these goals. The result is a language, which is the same as what is used in Java and Delphi as much as those drawing in from C and C (if there is no more than, " Please note that the following information is based on the C # operational procedure, which may not be accurately representative of the final product release.

C # is a RAD environment

C # provides Java style garbage collection: one of the most important RAD features provided by C # is the Java style garbage collection. All objects that are not referenced will be automatically deleted in any time during runtime. By liberating developers from manual memory management tasks, garbage collection makes program development easily and is not easy to errors. However, auto-garbage collection is time consuming and is unpredictable. Therefore, C # allows developers to disable garbage collection in the case of real-time performance - labeled the code as unsafe.

C # implements the value of Java and Delphi-style / reference type system: To further support RAD, C # always processes the C / C pointer model in Java and Delphi-style value / reference type system. In this system, built-in type (Integer, Real, String, etc.), enumeration and structure are all value types. Assigning operators and comparison operators copy and check the values ​​of these types of variables. Interfaces, classes, and authorizations (will be described later) are reference types. Assignment operators and comparison operators copy and check the identity of objects referenced by these types of variables.

This value / reference type system is much simpler than the pointer model of C . It makes object processing easier and eliminates many memory errors that plague C and C programs.

The C # interface is independent of the category: C # also supports interface models similar to Java and Delphi, and the interface is independent of the category. This is aligned with the C model, and the interface in C is actually an abstract base class. Interfaces and classes can inherit multiple interfaces. The class can inherit a base class, and the interface cannot inherit the class. This model avoids the multi-inheritance problem of C , and the implementation in different base classes in C may conflict. Therefore, this kind of complex mechanism such as virtual inheritance and explicit scope is also no longer needed. The simplified interface model of the C # helps speed up the development of the application.

The declarations and definitions of the class method are combined: C # Simplified development is a combination of declarations and definitions of the class method, similar to Java practices. C developers must maintain separate files for declaration (header) and definition (implementation file), resulting in complex software development processes. C # can even automatically find the relationship between the source code module, so that the developer will be freed from an additional miscellaneous administration. Although C needs to use #include (Delphi needs to use Usees) to locate the associated source file, but C # does not require any additional statements.

C # usage method reference, called authorization, without using method pointer: C # usage method reference to quickly connect objects and methods. These methods called authorized references are similar to Delphi process types. Hejlsberg also introduces the same mechanism into Visual J 6.0, but it is not part of the standard Java specification. Method references a bit like C method pointer, but it is superior, safe and useful. Authorization is a reference type, which holds a signature of the method. Applications can assign any methods that meet this signature to authorized variables. When this authorization variable is called, the relevant method is called. Unlike Delphi process type, C # authorization automatically supports multi-point transmission. Applications can assign many methods to an authorization variable; all methods are called when this variable is called.

C # uses Java's simple thread synchronization mechanism. To implement thread synchronization in C #, developers are only required to mark the critical code block. Java developers use Synchronized keywords, while C # developers use Lock. The hidden mutex will be packaged with a logo code block, only one thread is permitted to perform this code at any time. This mechanism is exactly the same in C # and Java except for the keywords. Because the thread all programming tasks is the most prone to error, any feature that simplifies synchronization will help quickly application development.

Explicit overload declaration: Finally, C # uses an explicit overload declaration to support RAD. Explicit overload declares supports fast application development by protecting the method namespace of the protection class and pointing out unexpected naming conflicts.

C # Exporting developers must explicitly use the keyword Override tag method to overload, as doing it in Delphi. If the export class contains an unmissive method that is the same as the false method in the base class, the compiler cannot clearly identify the author's intentions.

On the other hand, naming conflicts may be inevitable; especially when the base class and the derived class are achieved by different programmers (potential to work for different companies). In this case, the compiler will issue a warning and the method of the export class is considered a new declaration without regarding it as an overload.

On the other hand, if the programmer delivers a new method in the export class with a virtual method in the base class, he (or her) can use the New keyword to prevent the compiler from issuing a warning.

Other features of C #

Consider all the language features that have just been discussed, the powerful support for RAD seems to be a one most important goal set by Microsoft as C #. However, C # must also be committed to other important development needs. These requirements include cross-platform deployment, access to platform inherent resources, and support for COM and .NET platforms. Let us analyze C # language features aimed at supporting these needs.

Cross-platform deployment: C # solves the problem of cross-platform deployment in the same way as Java solves this problem. The C # compiler generates the byte stream explained by the .NET runtime. The working mode of runtime is very similar to the Java virtual machine; the application can be deployed on any device that has been installed .NET runtime.

Applications Access to the platform inherent resource: Unlike the Java virtual machine, the .NET runtime allows the program to access the platform inherent resources. For example, a C # program can run using Windows API as a full-featured application on Windows 2000. By using the Windows CE API subset, the same program can also be run on the PDA. Of course, not all services expected by the application can be obtained on all devices. Therefore, testing software on all target platforms is the responsibility of the developer. If necessary, developers can also write special cases, which will still work when the system is missing.

Support COM and .NET: To support COM and .NET platforms, C # contains a unique language characteristic called attribute. A property is actually a C # class, which provides meta information by modifying source code. Property allows C # to support specific technologies such as COM and .NET without interfere with language specification itself. For example, C # provides an attribute class that converts the C # interface into a COM interface. Other attribute classes convert C # classes to COM classes. Doing these conversions do not require any IDL or class factories. Some language observers claim that all COM objects are all COM objects. This is incorrect - but through the appropriate attribute, any C # class is easy to convert to a COM object.

The C # class and functions are packaged as web services with another property library provided by the compiler. The Web service is a managed software module that can be called by interactive protocols (such as SOAP) on the Internet. SOAP wraps method calls in the XML packet with their parameters and return values. Web services can be written in many languages ​​and can be deployed to many hardware and software platforms. Moreover, different types of Web services can collaborate the entire web application. By using the correct attribute, the programmer can easily convert any C # classes or functions to a web service.

C # does not have characteristics

Many characteristics of C # used to support the Internet applications in the experience of Anders Hejlsberg are selected from Delphi and Java. The Microsoft claims that C # is converted from C and C . So let's analyze some C features that C # does not have.

Scope and non-correlation operators: C # does not use C scope operators (: :); but depends on Delphi and Java similar point operand (.). In addition, because it is based on the previously described Java and Delphi-style value / reference type system, in most cases, C non-associated visits (->) are used again, but the point operator is again. Although the overloaded point operator may confuse the C programmers who just started to learn C #, this is quite familiar with Java and Delphi developers.

Reference Declaration Syntax: Because classes, interfaces, and authorization types are referenced by default, C # does not have C reference declaration syntax. This new language is changed to use syntax similar to Delphi declaration as reference to passing parameters:

Unmarked parameters are input parameters

Ref Keyword Specifies an input / output parameter (similar to Delphi VAR)

OUT keyword specifies an output parameter

Params Keyword Specifies a list of pole length parameters (similar to the Variant Open-Array parameter of Delphi)

Template: Like Java and Delphi, C # has no template. Therefore, C # does not support the mechanism of a collection of statements. Each class is ultimately exported from a common base class Object. The general set class must be an Object collection that needs to be converted into the required type of members in securely.

Although there is no C language characteristics, C # is still a powerful programming language, which is designed around the characteristics similar to Java and Delphi to support Internet applications. Because C is concerned with machine-level attention and lack of RAD support, it is not suitable for the basis for use as an Internet application development language. If C developers need to write applications and services for the .NET platform, they will be strongly suggested after C # publishing this language - remember that it is different from the actual difference between C than their names. Much more.

In this transition, it is best to learn Java or Delphi. Not only because of these two languages ​​will make you better understand C #, but also because these two languages ​​themselves are also very useful languages. As a software professionals, we should use the best tools available. About the Author

Michael L. Perry has been engaged in professional Windows development, and has expert experience in COM , Java, XML, and other technologies currently shaping programming prospects. He established Mallard Software Designs in 1998, in the company's strict proven software design - the correctness of the first establishment of the solution before implementation.

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

New Post(0)