Is C # a clone of a Microsoft replacement for Java?

Source: Internet
Author: User

Is C # a clone of a Microsoft replacement for Java? Let's look at what Anders Hejlsberg said.

Hejlsberg: First of all, C # is not a Java clone. In the design of C #, we looked at a lot of languages. We looked at C + +, we looked at Java, at Modula 2, C, and we looked at Smalltalk. There is just so many languages that has the same core ideas that we ' re interested in, such as Deep object-orientation, Object-simplification, and so on.

One of the key differences between C # and these other languages, particularly Java, was, we tried to stay much close R to C + + in our design. C # borrows most of its operators, keywords, and statements directly from C + +. We have also kept a number of language features that Java dropped. Why is there no enums in Java, for example? I mean, what's the rationale for cutting those? Enums is clearly a meaningful concept in C + +. We ' ve preserved enums in C # and made them Type-safe as well. In C #, enums is not just integers. They ' re actually strongly typed value types that derive from System.Enum in the. NET Base-class Library. An enum of type "foo" was not interchangeable with an enum of type "bar" without a cast. I think that ' s an important difference. We ' ve also preserved operator overloading and type conversions. Our whole structure for name spaces are much closer to C + +.

But beyond these + traditional language issues, one of our key design goals is to make the C # language component-or Iented, to add to the language itself all of the concepts so you need when you write components. concepts such as  properties, methods, events, attributes , and documentation  are All First-class language constructs. The work that we've done with attributes – a feature used to add typed, extensible metadata to any object – is Completel Y New and innovative. I Haven ' t seen it in any other programming language. and C # is the first language to incorporate XML comment tags which can be used by the compiler to generate readable documen Tation directly from source code.

Another important concept is the What I call "one-stop-shopping software." When you write the code in C #, you write everything. There is no need for header files, IDL files (Interface Definition Language), GUIDs and complicated interfaces. And once you can write code that's self-describing in the this-to-be-start embedding your software, because it is A self-contained unit. Now you can slot it to ASP pages and you can host it in various environments where it just wasn ' t feasible before.

But going back to these key component concepts, there's been a lot of debate on the industry about whether languages Shoul D support Properties or events. Sure, we can express these concepts by methods. We can have naming patterns like a "get" block or a "set" block that emulate the behavior of a property. We can have interfaces and adapters, that implement a interface and forward to an object. It's all possible to do, just as it's possible to does object-oriented programming in C. It's just harder, and there ' s more housekeeping, and your end up has a have to does all this work in order to truly express your Ideas. We just think the time is right for a language this makes it easier to create components. Developers is building software components these days. They ' re not building monolithic applications or monolithic class libraries. Everyone is building the inherit from some base component provided by some hosting environment. These components override some methods and properties, anD They handle some events, and put the components back in. It's key to has those concepts be first class.

is C # a clone of a Microsoft replacement for Java?

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.