The generation of C # is a natural progress

Source: Internet
Author: User
Tags export class
C #, natural progress
With the retreat of Visual J ++, Microsoft introduces C # to fill this gap.

 

Michael L. Perry
Mallard software designer
August 2000

Microsoft's new vision of the Internet is far from today's online content network. Microsoft healthcare's future Internet is an interconnected Service developed on different hardware platforms by different people in different languages. It can run on different Internet operating systems.

The company provides the. NET platform for the New World, which is boldly imagined. In fact,. NET is not a traditional platform; it is not a public hardware or software system .. Net is actually a collection of protocols that allow Internet applicationsProgramUse different services running on different machines.

The result of Microsoft's new strategy is that the next generation of Microsoft Visual Studio will have a re-designed language, especially to support the. NET platform. Java will no longer be included in this package, and Visual J ++ will not have a new version. Don't worry, Microsoft will launch a new Language C # to fill this gap. The company used its best resources, including star language expert Anders hejlsberg, to develop C #.

None of them belong to: Anders hejlsberg, a language architecture designer
Considering hejlsberg's experience, it's no wonder Microsoft has handed it over to him. After all, C # will not be his first major reform in software development.

As Borland's chief architecture designer, hejlsberg secretly turned Turbo Pascal into an object-oriented application development language with a truly visualized environment and superior database access features. Delphi, once hailed as the "VB killer", is still a fist product of Borland (now Inprise/Borland.

After Microsoft hired hejlsberg with generous salaries, stock subscriptions, and a huge franchise bonus, Borland sued new members through improper means. Borland also claims that it provides few details to support the allegations-hejlsberg is developing "Delphi for Java ". The lawsuit eventually ended with Borland's victory, but since then Microsoft has been working for hejlsberg.

Hejlsberg has enriched Microsoft's Java products. Specifically, to keep up with the current version number of other Visual Studio languages, he artificially upgraded the version number from 1.1 to 6.0 in one release. In fact, the jump of this version number does not exaggerate the difference between 6.0 and the previous version. The features added by hejlsberg have turned the language into a powerful windows application development platform. The added features include access to Windows APIs. Therefore, programs that utilize these new features are no longer portable.

Hejlsberg's changes to Microsoft's Java product prompted sun to accuse Microsoft of violating the Java license agreement. Sun claims that Visual J ++ language extensions do not maintain Java's platform neutrality, but instead lock developers on Microsoft platforms. Although Microsoft's Visual J ++ is actually the best Java compiler, and the company's Virtual Machine (runtime module that executes Java bytecode) is the fastest virtual machine, however, sun's lawsuit has effectively prevented Microsoft from competing in the Java stage.

Microsoft's reaction is to exit completely from Java and replace it with a new basic Internet platform-. Net-and a new flag language-C. Anders hejlsberg is the natural choice for the last job.

Prove a newProgramming LanguageRationality
Some recent news about the C # debate claims that developers will not accept another programming language. Although there are already several useful languages available for developers, there is still room for another language-if it fills in the unfulfilled needs. A new language is, after all, another tool that professionals can use to create software solutions. Let's analyze the Goals Microsoft has set for C # And the situations where other languages have not yet met these goals.

Rapid Application Development: One of the most important goals Microsoft has set for C # is to support rad. Internet applications must be developed at the pace of the Internet; a new language must be easy to learn and debug, and must generate easy to updateCode. Although Delphi and VB are excellent in these aspects, C ++ has not been so successful. The language itself is complex and difficult to grasp, and few useful C ++ libraries provide simple interfaces. In addition, C ++ manual memory management and complex type conversion models make it difficult to debug.
In addition, as we will see below, C ++ essentially does not prevent potential problems caused by version incompatibility. Although Microsoft and borland have made great efforts in this language, C ++ is still not suitable for Rapid Application Development.

Cross-platform deployment: According to definitions, Internet languages should support cross-platform deployment. Because the Internet is a network of different systems, services must be deployed on a variety of hardware and software. In addition, client software should be able to run on a variety of devices, including PDAs and cellular portable wireless phones. This flexibility is actually a challenge to all languages except Java. In particular, VB can only generate Windows applications running on Intel microprocessor-based machines. Delphi is also subject to the same restrictions. Delphi for Linux will be released soon, but it does not support Internet devices. Both VB and Delphi do not meet the cross-platform deployment goal.

Access to the inherent resources of the Platform: According to Microsoft, developers need to access the inherent resources of the platform. Such access is sometimes essential for writing powerful target applications. Visual J ++ 6.0 allows developers to access windows APIs. Java generally does not allow such access. Java provides cross-platform deployment by defining the minimum public denominator standard for each virtual machine. Java developers write code based on this weakened standard, rather than using more powerful services provided by some platforms. In this way, Java cannot meet the objective of providing access to the inherent resources of the platform.

Support for com and. Net platforms: Microsoft has set support for com and. Net platforms as the most important objective of C. Of course, there is currently no language to support the. NET platform, because it is still being built. Unlike. net, COM has been around for quite a while, but it still lacks powerful language support. Most languages, including C ++ and Delphi, require developers to create an additional IDL declaration, a class factory, and a dedicated modifier for each COM object they create.
Some language vendors have provided some wizard to automate many common COM and Ole tasks, but these tools do not completely hide the complexity of COM. VB does successfully hide the complexity of COM, but it is at the cost of sacrificing functions. Not only does VB lack the power of object-oriented languages, but it cannot support low-level COM functions-such as multiple interfaces, clustering, and custom orchestration. In short, there is no existing language that fully supports COM like C.

Although these four goals are quite high for a new language, hejlsberg has come up with his best experience at work to ensure that C # achieves these goals. The result is a language that draws from Java and Delphi as much as from C and C ++ (if not exceeded ). Note that the following information is based on the C # operation procedure and may not accurately represent the final product release version.

C # Is a RAD environment

C # provides Java-style garbage collection: One of the most important rad functions provided by C # Is Java-style garbage collection. All objects that are not referenced will be automatically deleted at any time during the runtime. By freeing developers from manual memory management tasks, spam makes program development easy and error-prone. However, automatic garbage collection is time-consuming and unpredictable. Therefore, C # allows developers to disable spam locally when real-time performance is required-by marking the code as unsafe.

C # implemented the value/reference type system of Java and Delphi: to further support rad, C # The C/C ++ pointer model is always processed by a value/reference type system in the Java and Delphi style. In this system, the built-in types (integer, real, string, and so on), enumeration (enumeration), and structure are both value types. Value assignment operators and comparison operators copy and check the values of these types of variables. Interfaces, classes, and authorizations (described later) are reference types. Value 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 C ++ pointer model. It makes object processing easier and eliminates many memory errors that plague C and C ++ programs.

C # interfaces are declared independently of classes: C # also supports interface models similar to Java and Delphi. interfaces are declared independently of classes. This is opposite to the C ++ model. In C ++, interfaces are actually abstract base classes. Both interfaces and classes can inherit multiple interfaces. Classes can inherit a base class, and interfaces cannot inherit classes at all. This model avoids the multi-Inheritance Problem of C ++, and implementations in different C ++ classes may conflict with each other. Therefore, complex mechanisms such as virtual inheritance and explicit scopes are no longer needed. C #'s simplified interface model helps accelerate application development.

The declarations and definitions of class methods are combined: C # Another aspect of simplified development is to combine the declarations and definitions of class methods, which is similar to Java's practice. C ++ developers must maintain separate files for declarations (header files) and definitions (Implementation files), making the software development process complex. C # can even be automatically identifiedSource codeThe relationship between modules, which frees developers from an additional chores. Although C ++ needs to use # include (Delphi needs to use uses) to locate relevant source files, C # does not need any additional statements.

C # Use method reference, which is called authorization without using method pointer: C # Use method reference to quickly connect objects and methods. These methods, called authorization, reference a process type similar to Delphi. Hejlsberg also introduced the same mechanism into Visual J ++ 6.0, but it is not part of the standard Java specification. Method reference is a bit like a C ++ method pointer, but it is much more advantageous, secure, and useful.
Authorization is a reference type that holds the signature of a method. The application can assign any method that meets this signature to the authorization variable. When such an authorization variable is called, related methods are called. Unlike Delphi's process type, C # authorization automatically supports multi-point transfer. Applications can assign many methods to an authorization variable. When this variable is called, all methods are called.

C # use Java's simple thread synchronization mechanism. To implement thread synchronization in C #, developers only need to mark key code blocks. Java developers use the synchronized keyword, while C # developers use lock. Hidden mutex blocks wrap code blocks with signs, allowing only one thread to execute this code at any time. Except for different keywords, this mechanism is identical in C # and Java. Because all programming tasks in a thread are the most error-prone, any feature that simplifies synchronization can help Rapid Application Development.

Explicit overload Declaration: Finally, C # uses explicit overload Declaration to support rad. Explicit overload declarations enable Rapid Application Development by protecting the method namespace of the class and pointing out unexpected naming conflicts.
C # export class developers must explicitly use the keyword override to mark method overloading, just as in Delphi. If the export class contains an unlabeled method with the same name as a virtual method in the base class, the compiler cannot clearly identify the author's intent.

On the other hand, naming conflicts may be inevitable, especially when the base class and the export class are implemented by different programmers (may work for different companies. In this case, the compiler will issue a warning and treat the method of the export class as a new declaration without regard it as a overload.

On the other hand, if the programmer intentionally asks a new method in the export class to have the same name as a virtual method in the base class, he or she can use the new keyword to prevent the compiler from issuing a warning.

Other features of C #
Considering all the language features that have just been discussed, strong support for rad seems to be a major objective Microsoft has set for C. However, C # must also focus on other important development needs. These requirements include cross-platform deployment, access to the platform's inherent resources, and support for the COM and. Net platforms. Let's analyze the C # language features to support these needs.

Cross-platform deployment: C # solves cross-platform deployment in the same way as Java solves this problem. C # The Compiler generates byte code streams interpreted by the. NET runtime. The running component works in a similar way as a Java Virtual Machine. Applications can be deployed on any device installed with. Net runtime.

Application access to inherent platform resources: Unlike Java virtual machines,. Net allows programs to access inherent platform resources during runtime. For example, a C # program can use Windows API as a full-featured application running on Windows 2000. By using the Windows ce api subset, the same program can also run on the PDA. Of course, not all services that the application expects will be available on all devices. Therefore, testing software on all target platforms is the responsibility of developers. If necessary, developers can write code in special cases, this will enable the system to still work when the required services are missing.

Support for com and. Net: To support COM and. Net platforms, C # contains a unique language feature called attribute. An attribute is actually a C # class, which provides metadata by modifying the source code. Properties enable C # to support specific technologies such as COM and. Net without interfering with the language specification itself.
For example, C # provides an attribute class for converting a C # interface to a COM interface. Some other property classes convert C # class to com class. No IDL or class factory is required to execute these conversions. Some language observers claim that all C # classes are COM objects. This is not correct-but with the appropriate attributes, any C # class can easily be converted to a COM object.

With another property library provided by the compiler, C # classes and functions are packaged as Web Services. Web services are managed software modules that can be called over the Internet through interactive protocols (such as soap. Soap wraps method calls together with their parameters and return values in XML data packets. Web services can be written in many languages and deployed on many hardware and software platforms. In addition, different types of web services can collaborate to form the entire web application. By using the correct attributes, programmers can easily convert any C # class or function into a web service.

C # features not available
Similar to the experiences of Anders hejlsberg, many features C # used to support Internet applications are selected from Delphi and Java. Microsoft claims that C # is transformed from C and C ++. Therefore, let's analyze some of the C ++ features that C # does not possess.

Scope and non-correlated OPERATOR: C # does not use the C ++ scope operator (: :); instead, it depends on the point operator (.) similar to Delphi and Java (.). In addition, because it is based on the Java and Delphi-style value/reference type systems described above, in most cases, C # does not use C ++'s non-correlated accessors (-> ), instead, the vertex operator is implemented again. Although the overloaded point operators may confuse C # programmers who are learning C # At the beginning, they are quite familiar with Java and Delphi developers.

Reference declaration Syntax: Because classes, interfaces, and authorization types are referenced by default, C # does not have the reference declaration Syntax of C ++. This new language uses a syntax similar to Delphi declaration to PASS Parameters by reference:
The unlabeled parameters are input parameters.
The ref keyword specifies an input/output parameter (similar to the VaR of Delphi)
The out keyword specifies an output parameter.
The Params keyword specifies a variable length parameter list (similar to the variant open-array parameter in Delphi)

Template: Like java and Delphi, C # does not have a template. Therefore, C # does not support declaring a type-safe set. Each class is eventually exported from a common base class object. Generally, a collection class must be a collection of objects, and its members must be converted to the desired type in an insecure manner.
Despite the absence of these language features of C ++, C # is still a powerful programming language designed to support Internet applications based on features similar to Java and Delphi. C ++ is not suitable for Internet application development languages because of its lack of machine-level attention and rad support. If C ++ developers need. after C # is released, it is strongly recommended to learn this language. Remember, the difference between it and C ++ is much greater than the difference indicated by their names.

In this transitional period, it is best to learn Java or Delphi. Not only will these two languages make you better understand C #, but they are also very useful languages. As software professionals, we should use the best available tools.

Author Profile
Michael L. Perry has been engaged in professional windows development for more than six years, and has expert experience in COM +, Java, XML, and other aspects, as well as other technologies that shape programming prospects. He founded Mallard software designs in 1998, where he strictly proved software design with mathematics-the correctness of the solution was first established before implementation.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.