Peter said:
[...]
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).
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.
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.