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. Operation与GCD的不同

    最大并发数: 什么是并发数? 同时执行的任务数.比如同时开启三个线程执行三个任务,并发数就是3. 最大并发数相关的方法: -(NSInteger)maxConcurrentOperationCount ...

  2. c语言中赋值语句的结果

    c语言中赋值语句的结果 最近在看<C语言接口与实现>,在第一章就发现一个以前很少用到的用法.在实现strcpy函数时,书中给出了两种实现. //version 1, 使用数组实现(新手惯用 ...

  3. VsFTP+本地文件认证+SSl实现虚拟用户配置

    1.实验环境: [root@node21 ~]# cat /etc/centos-release CentOS release 6.8 (Final) [root@node21 ~]# uname - ...

  4. [转]如何烧录tizen镜像文件?(图文教程)

    http://blog.csdn.net/flydream0/article/details/9179143 上一篇文章我已讲过如何制作镜像文件(http://blog.csdn.net/flydre ...

  5. Windows命令行中使用SSH连接Linux

    转自 http://www.linuxidc.com/Linux/2014-02/96625.htm 1.下载: openssh for Winodws: 免费下载地址在 http://linux.l ...

  6. 十四、Android学习笔记_Android回调函数触发的几种方式 广播 静态对象

    一.通过广播方式: 1.比如登录.假如下面这个方法是外界调用的,那么怎样在LoginActivity里面执行登录操作,成功之后在回调listener接口呢?如果是平常的类,可以通过构造函数将监听类对象 ...

  7. Datazen 自定义地图--中国地图

    背景: 关于Datazen可以google一下,因为目前Datazen还没有中文版,所以google出来的资料会多一点,由于公司想用Datazen来做报表展示,所以有了下文. 参考文章: 中文---h ...

  8. linux中ftp用户登录密码忘记了怎么修改

    先来熟悉一下 vsftp 命令: 启动vsftp用命令: 1.service vsftpd start 重启vsftp用: www.111cn.net1.service vsftpd restart ...

  9. 理解C#系列 / 核心C# / 判断&循环&跳转

    判断&循环&跳转 说明 本节写的是C#语言的控制程序流的语句,“控制程序流”就是控制程序运行流程的意思. 判断 很容易理解:如果……就…… if语句:测试特定条件是否满足,如果满足就执 ...

  10. XMLHTTPRequest的属性和方法简介

    由于现在在公司负责制作标准的静态页面,为了增强客户体验,所以经常要做些AJAX效果,也学你也和我一样在,学习AJAX.而设计AJAX时使用的一个 重要的技术(工具)就是XMLHTTPRequest对象 ...