D vs. C#
Steven Schveighoffer
schveiguy at yahoo.com
Mon Oct 22 12:21:12 PDT 2007
"Walter Bright" wrote
> Lutger wrote:
>> Walter Bright wrote:
>>> I've never been able to discover what the fundamental advantage of a VM
>>> is.
>>
>> I thought the .NET platform was developed with the intent to replace COM?
>
> I don't know what MS's reasons were
I think the reason was pretty obvious... replace Java :) Sun slapped MS's
hand when it tried to differentiate Java, so MS wanted to not depend on Java
anymore.
As far as COM, I don't think they ever wanted to replace it because that
would make all the millions of lines of code already written with COM
useless. MS's main goal in anything they do is, and always has been,
backwards compatibility. Why do you think Windows is so damn bloated
compared to Linux? Because it all has to be able to still run Windows 3.1
crap.
>but it seems strange to replace COM with something inaccessible from C++
>(the main language used to interface with COM).
.net is accessible from C++. It's called C++.net :) With .net, you can
implement "managed" or garbage collected C++ classes, and from there you can
call either normal C/C++ classes or other .net langauge-based
classes/functions. I usually do this because it's much easier (in my mind)
than importing C/C++ stuff into C#
IMO, D does a much better job of importing C functions, and is much more
understandable. As far as interfacing with C++, .net has D beat because it
can use the classes directly from a C++.net class. But I think, as you do,
that this is more trouble than it's worth.
>
>> And by extension, complementing and / or replacing the C way of
>> cross-talking between languages for application development.
>
> Except that .net cannot talk to C or C++ code, which are the usual
> languages for applications.
>
> All languages need to interoperate are a standard calling convention, not
> a wholly different environment.
The whole point of .net is to allow ANY language to generate the SAME
bytecode. For example, you can have a C++.net class, calling a VB.net
class, which calls a COBOL.net class (yes, COBOL.net exists, I can't believe
it either). It's actually a really neat idea, but in practice, you
generally only use one language anyways, and interfacing with old code
usually means you have to write wrappers or reimplement the code, so it's
not like you can magically merge legacy stuff with .net without a ton of
work.
So yes, you can talk to C or C++ using .net, but it's not always pretty.
-Steve
More information about the Digitalmars-d
mailing list