Re:C#如何与C ++和VB进行比较 [英] Re: how does C# compare to C++ and VB

查看:63
本文介绍了Re:C#如何与C ++和VB进行比较的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

On Fri,2008年7月18日07:03:37 -0700,Ben Voigt [C ++ MVP]

< rb *@nospam.nospamwrote:


[...]


>严重的是,我认为你是在过度思考。 C#,C ++和
VB都具有基本相同的功能。他们彼此更像(尤其是C ++和C#),而不像其他大多数语言一样。每种语言都有一些特定的差异,而一些



C#与C ++相比更接近Java和VB.NET。



我完全同意接近Java。但OP并没有问过关于Java的问题。 :)


我不同意VB / VB.NET的观点,但我猜这是一个意见问题

所以并非完全出乎意料。尽管C ++和C#之间存在一些基本的概念性差异,但我发现在这些语言之间来回移动比在C#和VB.NET之间来回移动要容易得多。并且

所以对我来说,它们彼此之间的相似性比C#更接近于VB.NET(并且

如果仅限制与C ++ / CLI的比较,则尤其如此

比C ++更普遍)。


C ++有与B#基本相同的OOP功能,但是模板可以做的不是

仿制药不能用,



仿制药可以做模板不能做的事情。它们是相似的,但不等于
等价物。


其他功能也更强大,并且作为一个

结果C ++支持现代非OOP编程风格(例如TMP)。



恕我直言,将一种语言描述为更强大是一种煽动性。因为

与另一个相比,并且在大多数情况下(包括这一个)肯定是

不准确。


当然,如果通过其他功能更强大你并不是故意暗示C#不具备更强大的价值。功能,然后我的关注

是错位的。但那不是我读你的陈述的方式。


Pete

解决方案

Peter Duniho写道:


周五,2008年7月18日07:03:37 -0700,Ben Voigt [C ++ MVP]

< rb * @ nospam .nospamwrote:


> [...]


>>说真的,我认为你是在推翻事物。 C#,C ++和
VB都具有基本相同的功能。他们彼此更像(尤其是C ++和C#),而不是像其他语言一样。每种语言都有一些特定的差异,而且一些


C#与Java和VB.NET相比,它更接近于C ++。



我完全同意接近Java。但OP

没有问过Java。 :)


我对VB / VB.NET的观点持不同意见,但我想这是一个关于

意见的问题所以并非完全出乎意料。尽管有一些基本的



但他们并没有看。相似,但VB.NET和C#

的实际特征矩阵几乎完全相同。 VB有C#没有的异常过滤器。我怀疑

我们很难列出超过6个差异。


C ++和C#之间的概念差异,我在C#和VB.NET之间来回移动和回复之间更容易找回这些语言之间的回复和b / b
对我来说它们更类似于每个
除了C#之外的
是VB.NET(如果只是将
限制为与C ++ / CLI而不是C ++的比较,则尤其如此)。


> C ++与C#基本上具有相同的OOP功能,但是模板可以做的不是泛型不能用的东西,


而且泛型可以做模板不能做的事情。它们相似,但不等于
等价物。



泛型可以执行Microsoft C ++编译器无法使用

模板执行的操作,因为Microsoft C ++不支持C ++标准

(特别是出口)。因为我知道只有一个C ++编译器可以实现导出,所以你的语句对于所有实际用途都是正确的。


但是,Microsoft C ++编译器确实支持泛型。


>


>其他功能也更强大,结果C ++支持现代非OOP编程风格(TMP for
示例)。



恕我直言,将一种语言描述为更强大是一种煽动性。因为

与另一个相比,并且在大多数情况下(包括这一个)肯定不会是b $ b不准确。



你不同意C ++比C更强大吗?它实际上是一个100%超集的b $ b $ 100。 C ++与C#的情况也是如此,尽管他们的能力更接近于
。实际上支持C#的一个重点是,它是由一家公司控制的,因此新功能可以让开发人员多花多少钱b / b
案件较早。 C ++ 03胜过C#1.x,同时在

可用。而且C ++ 0x将是一个接近超集的,无论什么版本的C#同时出现,可能是4.x


>

当然,如果其他功能更强大,你并不是说

暗示C#也没有更强大的意思。功能,然后我的

关注是错误的。但那不是我读你的陈述的方式。



C#中有一些强大的功能,在C ++中没有直接等价的
。有一些非常好的语法糖,比如匿名方法

(虽然很快就会关闭C ++)。但是他们中没有一个表示真正不同的范例,比如TMP,所以最终选择C#而不是C ++的原因(例如垃圾收集,运行时

代码生成等)来自缺乏功能(使语言更容易学习)或CLR,这不是任何特定.NET的特征

语言。这些可以通过使用适当的库

和运行时在C ++中完成,其中一个,由于/ clr选项,是.NET本身。


>

Pete



Ben Voigt [C ++ MVP]< rb * @ nospam .nospamwrote:


我不同意VB / VB.NET的观点,但我想这是

意见所以并非完全出乎意料。尽管有一些基本的



但他们并没有看。相似,但VB.NET和C#

的实际特征矩阵几乎完全相同。 VB有C#没有的异常过滤器。我怀疑

我们很难列出超过6个差异。



我在游戏中看看我们是否可以在我们之间进行管理。尽管如此,没有作弊和寻找

。但是,如果有人想验证我的猜测,那就是'b
不同的事情:)


VB 9有XML文字; C#没有。


C#3有块体的lambda表达式(即多个

语句); VB 9只允许单个表达式的lambda,IIRC。


VB 9允许可变的匿名类型;它们总是在C#中不变。


VB允许后期绑定; C#还没(还)。


C#有指针并允许不安全的代码。我不确定VB是否还有这个



C#有迭代器块;我不相信VB会这样做。


这是6 - 有人可以添加到*更多*超过6吗?


-

Jon Skeet - < sk *** @ pobox.com>

网站: http://www.pobox.com/~skeet

博客: http://www.msmvps.com/jon_skeet

C#深度: http://csharpindepth.com


周五,2008年7月18日12:34:14 -0700,Jon Skeet [C#MVP]< sk *** @ pobox.com>

写道:


[...]

这是6 - 有人可以添加到*更多*超过6吗?



当然,我认为至少有几个显而易见的:


- VB有一个概念一个默认实例。也就是说,如果您按名称而不是明确分配的实例引用

类型,VB会为您创建实例
。我不太清楚VB是否足以知道这是什么语言功能或者Form类的特殊功能,但它确实是一个特殊的东西。发生在VB但不发生在C#中。


- With声明。


- VB支持声明一个事件处理程序,它指定了它实际处理的事件(在C#中你需要订阅活动

明确表示。


哎呀,对不起。那是三个。


我怀疑这两种语言的专家可以拿出很多比这更多的b $ b。


这就是说,我并不是真的不同意VB.NET和

C#共享大量功能的整体想法。这并不奇怪,因为

它们是专门针对相同的运行时和框架而设计的。


让我感到惊讶的是Ben可以一方面认为VB.NET

和C#彼此之间的关系比C#更接近C ++,而另一方面又说b
$ b $ "超集" C#。最好的情况是,C ++只能被认为是C ++的超集,如果只看一下C ++的Microsoft实现C ++ / CLI实现(推断我发现了一点)不诚实),但是,即使有人这样做,这个假设的含义是C ++与B#类似,就像C#一样。


但是正如我之前所说过的,我个人认为所有三种语言

在功能上基本相同。整个讨论是开始抨击我的语言比你的更好的
。而且我认为这是一个愚蠢的讨论。这种性质的宗教论据不会对我感兴趣。


Pete


On Fri, 18 Jul 2008 07:03:37 -0700, Ben Voigt [C++ MVP]
<rb*@nospam.nospamwrote:

[...]

>Seriously though, I think you''re overthinking things. C#, C++, and
VB all have substantially the same kinds of features. They are more
like each other (especially C++ and C#) than they are like most other
languages. Each language has some specific differences, and some


C# is far closer to Java and VB.NET than it is to C++.

I agree whole-heartedly about being closer to Java. But the OP didn''t ask
about Java. :)

I disagree on the VB/VB.NET point, but I guess that''s a matter of opinion
so not entirely unexpected. In spite of some fundamental conceptual
differences between C++ and C#, I find moving back and forth between those
languages much easier than moving back and forth between C# and VB.NET and
so to me they are more similar to each other than C# is to VB.NET (and
this is especially true if only limiting the comparison to C++/CLI rather
than C++ more generally).

C++ has
substantially the same OOP features as C#, but templates can do a not of
things generics can''t,

And generics can do things templates can''t. They are similar, but not
equivalent.

other features are more powerful as well, and as a
result C++ supports modern non-OOP programming styles (TMP for example).

IMHO it''s inflammatory to describe one language as "more powerful" as
compared to another, and in most cases (including this one) decidedly
inaccurate.

Of course, if by "other features are more powerful" you did not mean to
imply that C# does not also have "more powerful" features, then my concern
is misplaced. But that''s not how I read your statement.

Pete

解决方案

Peter Duniho wrote:

On Fri, 18 Jul 2008 07:03:37 -0700, Ben Voigt [C++ MVP]
<rb*@nospam.nospamwrote:

>[...]

>>Seriously though, I think you''re overthinking things. C#, C++, and
VB all have substantially the same kinds of features. They are more
like each other (especially C++ and C#) than they are like most
other languages. Each language has some specific differences, and
some


C# is far closer to Java and VB.NET than it is to C++.


I agree whole-heartedly about being closer to Java. But the OP
didn''t ask about Java. :)

I disagree on the VB/VB.NET point, but I guess that''s a matter of
opinion so not entirely unexpected. In spite of some fundamental

They don''t "look" alike, but the actual feature matrices for VB.NET and C#
are almost identical. VB has exception filters that C# doesn''t. I suspect
we''d be hard-pressed to list more than 6 more differences.

conceptual differences between C++ and C#, I find moving back and
forth between those languages much easier than moving back and forth
between C# and VB.NET and so to me they are more similar to each
other than C# is to VB.NET (and this is especially true if only
limiting the comparison to C++/CLI rather than C++ more generally).

>C++ has
substantially the same OOP features as C#, but templates can do a
not of things generics can''t,


And generics can do things templates can''t. They are similar, but not
equivalent.

Generics can do things that the Microsoft C++ compiler can''t do with
templates, because Microsoft C++ doesn''t support the C++ standard
(specifically export). Since I''m aware of only one C++ compiler that does
implement export, your statement is correct for all practical purposes.

However, the Microsoft C++ compiler does support generics.

>

>other features are more powerful as well, and as a
result C++ supports modern non-OOP programming styles (TMP for
example).


IMHO it''s inflammatory to describe one language as "more powerful" as
compared to another, and in most cases (including this one) decidedly
inaccurate.

Would you disagree that C++ is more powerful than C? It''s practically a
100% superset. The same is true of C++ vs C#, although they''re a lot closer
in capability. Actually one of the big points in favor of C# is that it''s
controlled by a single company, so new features reach developers a lot more
often, in many cases earlier. C++03 beats C# 1.x which was available at the
same time. And C++0x will be a near superset of whatever version of C# is
out at the same time, probably 4.x

>
Of course, if by "other features are more powerful" you did not mean
to imply that C# does not also have "more powerful" features, then my
concern is misplaced. But that''s not how I read your statement.

C# has some of these powerful features that don''t have a direct equivalent
in C++. There''s some very nice syntactic sugar, like anonymous methods
(although closures are coming soon to C++ as well). But none of them
respresent a truely different paradigm, such as TMP is, so ultimately most
of the reasons to choose C# over C++ (such as garbage collection, runtime
code generation, etc) come from either lack of features (making the language
easier to learn) or the CLR, which isn''t a feature of any particular .NET
language. These can be accomplished in C++ by using an appropriate library
and runtime, one of which, thanks to the /clr option, is .NET itself.

>
Pete



Ben Voigt [C++ MVP] <rb*@nospam.nospamwrote:

I disagree on the VB/VB.NET point, but I guess that''s a matter of
opinion so not entirely unexpected. In spite of some fundamental


They don''t "look" alike, but the actual feature matrices for VB.NET and C#
are almost identical. VB has exception filters that C# doesn''t. I suspect
we''d be hard-pressed to list more than 6 more differences.

I''m game to see if we can manage it between us. No cheating and looking
it up though. If anyone fancies verifying my guesses, however, that''s a
different matter :)

VB 9 has XML literals; C# doesn''t.

C# 3 has lambda expressions with block bodies (i.e. multiple
statements); VB 9 only allows lambdas of a single expression, IIRC.

VB 9 allows mutable anonymous types; they''re always immutable in C#.

VB allows late binding; C# doesn''t (yet).

C# has pointers and allows unsafe code. I''m not sure whether VB has
this yet.

C# has iterator blocks; I don''t believe VB does.

That''s 6 - can anyone add to it to go to *more* than 6?

--
Jon Skeet - <sk***@pobox.com>
Web site: http://www.pobox.com/~skeet
Blog: http://www.msmvps.com/jon_skeet
C# in Depth: http://csharpindepth.com


On Fri, 18 Jul 2008 12:34:14 -0700, Jon Skeet [C# MVP] <sk***@pobox.com>
wrote:

[...]
That''s 6 - can anyone add to it to go to *more* than 6?

Sure, I think there''s at least a couple of obvious ones:

-- VB has a concept of a "default instance". That is, if you refer to
a type by name rather than an explicitly allocated instance, VB creates
the instance for you. I don''t know VB well enough to know if that''s a
language feature or something special to the Form class, but it''s
certainly something that happens in VB but not in C#.

-- The "With" statement.

-- VB''s support for declaring an event handler that specifies what
event it''s actually handling (in C# you have to subscribe the event
explicitly).

Oops, sorry. That''s three.

I suspect an expert in both languages could come up with a great deal many
more than that.

That said, I don''t really disagree with the overall idea that VB.NET and
C# share a great number of features. That''s not surprising given that
they are specifically designed to target the same run-time and framework.

What does surprise me is that Ben can on the one hand argue that VB.NET
and C# are closer to each other than C# is to C++, and yet on the other
hand argue that C++ is essentially a "superset" of C#. At best, C++ can
only be thought of as a superset of C++ if one looks only at the Microsoft
C++/CLI implementation of C++ (reasoning that I find a bit disingenuous),
but even if one does, the implication of that assumption is that C++ is
just as similar to VB.NET as C# is.

But as I''ve said before, personally I find all three languages
functionally to be basically equivalent. This entire discussion is
starting to smack of "my langauge is better than yours" and I think that''s
a silly discussion to have. Religious arguments of that nature don''t
interest me much.

Pete


这篇关于Re:C#如何与C ++和VB进行比较的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆