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 are just so many languages that have 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, is that we tried to stay much closer 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 are there no enums in Java, for example? I mean, what's the rationale for cutting those? Enums are clearly a meaningful concept in C++. We've preserved enums in C# and made them type-safe as well. In C#, enums are 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" is 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 is much closer to C++.

But beyond these more traditional language issues, one of our key design goals was to make the C# language component-oriented, to add to the language itself all of the concepts that you need when you write components. Concepts such as properties, methods, events, attributes, anddocumentation 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 completely new and innovative. I haven't seen it in any other programming language. And C# is the first language to incorporate XML comment tags that can be used by the compiler to generate readable documentation directly from source code.

Another important concept is what I call "one-stop-shopping software." When you write code in C#, you write everything in one place. There is no need for header files, IDL files (Interface Definition Language), GUIDs and complicated interfaces. And once you can write code that is self-describing in this way, then you can start embedding your software, because it is a self-contained unit. Now you can slot it into 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 in the industry about whether languages should 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 an interface and forward to an object. It's all possible to do, just as it's possible to do object-oriented programming in C. It's just harder, and there's more housekeeping, and you end up having to do all this work in order to truly express your ideas. We just think the time is right for a language that makes it easier to create components. Developers are building software components these days. They're not building monolithic applications or monolithic class libraries. Everyone is building components that 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 have those concepts be first class.

译文:

首先,C#不是Java的克隆。在设计C#期间,我们考察了很多种语言,如C++、Java、Modula 2、C、Smalltalk等。很多语言都有我们感兴趣的相同的核心思想,比如深度面向对象、简化对象等等。 
    C#和这些别的语言尤其是Java的关键不同点是它非常接近C++。在我们的设计中努力使然。C#从C++直接借用了大多数的操作符、关键字和声明。我们还保留了许多被Java抛弃的语言特性。为什么Java中没有枚举,道理何在?我的意思是,抛弃它们是基于何种理论基础?在C++中,枚举显然是一个很有意义的概念。在C#中,我们保留了枚举并同样使其类型安全,并且,枚举不只是整型,它们实际上是从.NET基类库里的System.Enum派生下来的强类型的值类型。如果没有造型转换,枚举类型“foo”和枚举类型“bar”不可互换。我认为这是个重要的差异。我们还保留了操作符重载和类型转换。C#名字空间的整体结构也非常接近C++。 
    但是,超越这些传统的语言论题,我们设计语言的一个关键的目标是使C#面向组件。我们向语言自身加入了你在编写组件时所需要的所有概念。例如属性[译注:即property,翻译为“属性”,由来已久。我怀疑如果先有attribute的话,property会不会被翻译为“性质”、“特性”,而attribute才是“属性”:JL]、方法、事件、特性[译注:即attribute,截至目前,此名词译法仍较混乱。有的翻译和property不区分,也译为“属性”;有的译为“特性”;有的译为“属性信息”。在该名词译法尚未统一之前,本着精简原则,笔者先把它翻译成“特性”。但注意,XML中的attribute的译法一般比较统一,即为“属性”(因为XML中没有一个类似于property的东西会与之混淆)。因此,本文最后交叉描述C#和XML的部分,请留心“特性”、“属性”各有所指。]和文档等,它们都是一流的语言结构。我们对特性所做的工作是全新的和创新的。利用特性可为任何对象加入有类型的、可扩展的元数据。这在目前任何其它程序语言里都看不到的。C#也是第一个合并XML注释标记的语言,编译器可以用其直接从源码中生成可读的文档。 
    另外一个重要的概念是我所说的“一站购物式软件”[one-stop-shopping software]。一旦你用C#写代码,你就在这一个地方写了一切。不再需要头文件、IDL(接口定义语言)文件、GUID和复杂的接口。因为它是自包容的单元。一旦用这种方式写自描述的代码,你就可以把你的软件嵌入到ASP页面或植入各种不同的环境,这在以前是不可能的。 
    但是让我们再回到组件这个重要的概念。语言是否应该支持属性或事件,业界有很多争论。没错,我们是可以用方法表达这种概念。我们可以用诸如“get”或“set”之类的程序块的命名模式模拟属性的行为。我们可以用接口和实现接口的适配器并转发到对象。这都是可能实现的,就象可能在C语言里进行面向对象编程一样。只是它太困难了,需要太多的手工劳动,为了表达你真正的思想,你最终不得不去做所有的工作。我们认为是时候了,应该有个语言使得创建组件变得容易些。今天程序员在创建软件组件。他们并不是创建整个应用或整个类库。每个人都是在创建从宿主环境提供的基组件继承下来的组件。这些组件重载一些方法和属性,它们处理一些事件,并把组件安装回系统。树立这些概念是关键的第一课。

Is C# a clone of a Microsoft replacement for Java?的更多相关文章

  1. 对象复制、克隆、深度clone

    -------------------------------------------------------------------------------- ------------------- ...

  2. 详解Java中的clone方法:原型模式

    转:http://developer.51cto.com/art/201506/478985.htm clone顾名思义就是复制, 在Java语言中, clone方法被对象调用,所以会复制对象.所谓的 ...

  3. 温故而知新 clone

    浅复制(浅克隆) 被复制对象所有变量都含有与原来对象的相同值,对象中对其他对象的引用仍然指向原来的对象,换言之,复制对象只复制考虑的对象,而不复制所引用的对象.继承自java.lang.Object类 ...

  4. clone 深拷贝 浅拷贝

    1. 定义:知道一个对象,但不知道类,想要得到该对象相同的一个副本,在修改该对象的属性时,副本属性不修改,clone的是对象的属性 2. 意义:当一个对象里很多属性,想要得到一个相同的对象,还有set ...

  5. Java基础——clone()方法浅析

    一.clone的概念 clone顾名思义就是复制, 在Java语言中, clone方法被对象调用,所以会复制对象.所谓的复制对象,首先要分配一个和源对象同样大小的空间,在这个空间中创建一个新的对象.那 ...

  6. HDOJ 5000 Clone

    所有的属性,以满足一定的条件,是,财产和等于sum/2结果最大. Clone Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536 ...

  7. 转:Java中的Clone()方法详解

    Java中对象的创建 clone顾名思义就是复制, 在Java语言中, clone方法被对象调用,所以会复制对象.所谓的复制对象,首先要分配一个和源对象同样大小的空间,在这个空间中创建一个新的对象.那 ...

  8. Java中的clone()----深复制,浅复制

    这篇文章主要介绍了Java中对象的深复制(深克隆)和浅复制(浅克隆) ,需要的朋友可以参考下 1.浅复制与深复制概念 ⑴浅复制(浅克隆) 被复制对象的所有变量都含有与原来的对象相同的值,而所有的对其他 ...

  9. java clone()

    Java中对象的创建   clone顾名思义就是复制, 在Java语言中, clone方法被对象调用,所以会复制对象.所谓的复制对象,首先要分配一个和源对象同样大小的空间,在这个空间中创建一个新的对象 ...

随机推荐

  1. Strom实现数字累加Demo

    import java.util.Map; import backtype.storm.Config; import backtype.storm.LocalCluster; import backt ...

  2. 51nod-1686 第K大区间(二分+尺取法)

    题目链接: 第K大区间 基准时间限制:1 秒 空间限制:131072 KB    定义一个区间的值为其众数出现的次数.现给出n个数,求将所有区间的值排序后,第K大的值为多少. Input 第一行两个数 ...

  3. 初识 Asp.Net内置对象之Cookie对象

    Cookie对象 Cookie对象用于保存客户端浏览器请求的服务器页面,也可用于存放非敏感性的用户信息,信息保存的时间可以根据用户的需要经行设置.并非所有的浏览器都支持Cookie,并非数据信息都是以 ...

  4. c# 匿名对象增加动态属性

    在开发过程中碰到了一个需求,需要动态创建对象及其动态属性.在尝试几种方法后,最后完成了需求,记录下过程,给园友参考下 1.动态创建对象一:匿名对象 ",Birthday =DateTime. ...

  5. EF Code First 数据迁移命令

    只需要开启程序管理控制台(Package Manager Console) 然后输入  Enable-Migrations -ContextTypeName youContextdb(你的数据库上下文 ...

  6. Java计算机网络

    计算机网络: 分布在不同的地域的计算机通过外接设备(路由器),实现共享和数据传输网络编程:网络编程主要是用来解决计算机和计算机之间的数据传输网络编程:不需要基于HTML就可以达到数据之间的传输,比如Q ...

  7. java实现Composite(组合)模式

    组合模式涉及的是一组对象,其中一些对象可能含有其他对象,这些对象也可以含有对象,因此,有些对象代表的是对象群组. Composite模式的设计意图在于:让所有的用户能够用统一的接口处理单个对象以及对象 ...

  8. R语言快速入门

    R语言是针对统计分析和数据科学的功能全面的开源语言,R的官方网址:http://www.r-project.org/  在Windows环境下安装R是很方便的 R语言的两种运行模式:交互模式和批处理模 ...

  9. android View 绘制完成监听

    <span style="font-size:18px">//view重绘时回调 view.getViewTreeObserver().addOnDrawListene ...

  10. oracle发送邮件

    1.创建发送邮件的存储过程 CREATE OR REPLACE PROCEDURE send_mail(p_recipient VARCHAR2, -- 邮件接收人 p_subject VARCHAR ...