G
Guest
Hi Bo... Of course, the code is not _exactly_ equivalent Stack vs Heap
allocation.
allocation.
Greg said:Some have pointed out advantages of C++ which I don't contest. Yet, I am not
sure these are outweighed by other considerations for many .NET development
scenarios.
There are some cases where C++ is the only option: e.g. a pure native
Windows App with no .NET Runtime required.
However for a .NET app, if C++ is on par with C#, then how does one decide
which language to use. Are there any criteria besides being already familiar
with C++ etc.?
I.e. are there any concrete reasons why the full development cycle right up
to delivery will be more cost effective and yield greater ROI using one
language vs. the other?
Thank You
Andre Kaufmann said:But this unfortunately doesn't help if you need to have an object in
multiple lists and automatically disposed after the last reference has
been removed from the list.
[...]
Andre
JAL said:Hi Bo... Of course, the code is not _exactly_ equivalent Stack vs
Heap
allocation.
Greg said:Some have pointed out advantages of C++ which I don't contest. Yet,
I am not
sure these are outweighed by other considerations for many .NET
development
scenarios.
There are some cases where C++ is the only option: e.g. a pure
native
Windows App with no .NET Runtime required.
However for a .NET app, if C++ is on par with C#, then how does one
decide
which language to use. Are there any criteria besides being already
familiar
with C++ etc.?
I.e. are there any concrete reasons why the full development cycle
right up
to delivery will be more cost effective and yield greater ROI using
one
language vs. the other?
JAL said:class JALCollection : IDisposable //, IEnumerator
{
private bool disposed = false;
private ArrayList list = new ArrayList(); [...]
public void Dispose()
{
Dispose(true);
GC.SuppressFinalize(this);
foreach (IDisposable d in list)
{
d.Dispose();
}
}
Bo said:"Greg" <[email protected]> skrev i meddelandet
[...]That is actually 3 languages, not 2.IMHO C++ - C++/CLI and C# can be used very effectively together and
both ...
C++/CLI is not even close to the language called ISO C++. It just
looks similar, just like Java does.
Bo Persson
JAL said:Andre.. Ok this stuff IS harder than brain surgery. If I get some time I will
try to implement this but after doing 40 hours of neurosurgery I need to go
to sleep .
Andre Kaufmann said:Bo said:"Greg" <[email protected]> skrev i meddelandet
[...]That is actually 3 languages, not 2.IMHO C++ - C++/CLI and C# can be used very effectively together
and
both ...
C++/CLI is not even close to the language called ISO C++. It just
looks similar, just like Java does.
C++/CLI is an extension to C++, therefore a C++/CLI compiler must be
able to compile standard C++.
So I think it's equally true to speak of 2 and/or of 3 languages.
;-)
Bo said:[...]Andre Kaufmann said:Bo Persson wrote:
C++/CLI is an extension to C++, therefore a C++/CLI compiler must be
able to compile standard C++.
No, it does not.
There are some extensions, but also some parts that are missing, and
some parts that just behave differently.
Let's disagree.
Bo Persson
<SNIP>JAL said:Sounds like C++ meets all your requirements and you have no need to code in a
garbage collected environment.
Andre Kaufmann said:Bo said:[...]Andre Kaufmann said:Bo Persson wrote:
C++/CLI is an extension to C++, therefore a C++/CLI compiler must
be able to compile standard C++.
No, it does not.
Quote from the C++/CLI standard:
"C++/CLI is an extension of the C++ programming language as
described in ISO/IEC 14882:2003"
There are some extensions, but also some parts that are missing,
and some parts that just behave differently.
Could you give an example of C++ code, which the C++/CLI compiler
cannot compile ?
Bo said:That is valid ISO C++ code, but C++/CLI has reserved the namespace cli
for itself.
template<typename T> struct generic {
There are other differences in name lookup for subclasses, if they are
native or ref. Can you override a private virtual function? Not to
talk about multiple inheritance from non-interface classes...
Bo said:"Andre Kaufmann" <[email protected]> skrev i meddelandet
[...]
The C++/CLI standard (9.1.1) also shows a problem with a template
struct called "generic"
template<typename T> struct generic {
typedef int I;
};
class X {};
generic<class X> x1;
generic<class X()> x2;
This would compile in ISO C++, but is invalid C++/CLI.
There are other differences in name lookup for subclasses, if they are
native or ref. Can you override a private virtual function? Not to
talk about multiple inheritance from non-interface classes...
Bo Persson
Tamas Demjen said:That will hardly ever be a problem in the real world.
Interesting. But this is almost the same as
#define if for
#define public private
You're hijacking the language.
You wrote "C++/CLI is not even close to the language called ISO C++.
It just looks similar, just like Java does", and Andre pointed out
that it's not so. Now you're bringing up fabricated examples to
prove that C++/CLI is indeed just 99.9% ISO compatible, not 100%.
They're very entertaining examples, but C++/CLI is in fact truly an
extension to ISO C++, even if it break a couple of subtle details.
I agree that the extensions themselves are not that close to ISO
C++, and when you program in a pure managed environment, you're
using the extension part mostly, and therefore it looks different
than an ISO C++ code.
Andre Kaufmann said:Bo said:"Andre Kaufmann" <[email protected]> skrev i
meddelandet [...]
The C++/CLI standard (9.1.1) also shows a problem with a template
struct called "generic"
template<typename T> struct generic {
typedef int I;
};
class X {};
generic<class X> x1;
generic<class X()> x2;
This would compile in ISO C++, but is invalid C++/CLI.
There are other differences in name lookup for subclasses, if they
are native or ref. Can you override a private virtual function? Not
to talk about multiple inheritance from non-interface classes...
Yes. But I pointed out that you can compile the ISO C++ code, you
just have to disable the language extension if you have code that
should use the new reserved keywords. So this wouldn't be a real
world problem as Tom has already pointed out.
There are enough examples for valid ISO C++ code that have the same
problems:
E.g.:
class export {};
Has been for a long time valid ISO C++ code. While VC 2005 still
compiles this code, other compilers e.g. Comeau won't compile it.
There are also other examples for the upcoming C++ standard, which
will break existing code.
A valid C++/CLI compiler must be also able to compile ISO C++ code,
if you have to disable the language extensions or change the code is
another story.
I've already agreed that you cannot freely mix C++ and C++/CLI code
in all aspects, but that wasn't part of our discussion ;-)
The ISO C++ comitee has been very restrictive in introducing new
keywords, because they could break existing code. Microsoft has done
a fairly good job in introducing the new keywords in a context
sensitive way:
E.g.:
class abstract
{
virtual void s() abstract;
};
compiles without any problems as managed and unmanaged code.
IIRC the ISO C++ committee has also adopted this way in introducing
new context sensitive keywords, but I'm not sure about that - please
correct me if I'm wrong.
I don't have anything against new keywords. Far from it, IMHO they,
the ISO C++ committee, shouldn't have been that restrictive.
virtual void s() abstract;
looks better and would be more logical for developers learning C++
than
virtual void s() = 0;
To sum it up, I think Microsoft has done it well to introduce a new
C++/CLI standard, rather than continuing the ISO compliant managed
C++ extensions.
Bo said:"Andre Kaufmann" <[email protected]> skrev i meddelandet
[...]There are enough examples for valid ISO C++ code that have the same
problems:
E.g.:
class export {};
Has been for a long time valid ISO C++ code. While VC 2005 still
compiles this code, other compilers e.g. Comeau won't compile it.
No, export is a reserved word in ISO C++. MS has just not implemented
that part, being too busy doing C++/CLI instead.
[...]
I agree to that. I just don't agree that it is still the same
language. It's an new one, sometimes called "New C++" by Microsoft.
Bo Persson