C #, natural progress

Source: Internet
Author: User

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 applications to use 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 the rationality of A New Programming Language
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, debug, and generate code that is easy to update. 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 automatically identify the relationship between source code modules, so that developers can be freed 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

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.