Why not develop new language

H

Hannu Kankaanp??

Ioannis Vranos said:
C++ is a multi-paradigm language and supports 4 paradigms. The Object
Oriented programming paradigm, the generic programming paradigm
(templates), the procedural programming paradigm and the modular
programming paradigm (namespaces).

Each paradigm is supported *well* with optimal space and time efficiencies.

The links you gave to back this one up were only about what intentions
Stroustrup had. He didn't really prove any kind of optimality (as if
that would be possible). A more restricted environment like C# has
more potential for optimization and JIT compilers might even exceed
C++ in speed for "equivalent" code. In fact they already do in some
specially engineered test cases (which I have not done myself and am
relying on perhaps biased or wrong information).
C# currently supports only 1 paradigm, the OO one and this not
completely, but only single inheritance and multiple inheritance only
for interfaces.

C# has static functions for procedural programming, namespaces for
modular programming. Does C++ support OO "completely"? It has no
metaclasses, no multidispatch, classes aren't objects nor does it have
reflection [1]. I know of libraries that attemt at doing each of
these, but if they were accepted, I'm sure someone could write a C#
library for multiple inheritance among everything else. Only the
degree of cumbersomeness varies.

As for constructs not supported in C++ but supported in C#:
properties, reflection (& serialization), string switches, typeof,
language support for multithreading. Once again I'm sure many of these
can be achieved in C++ through rigorous programming practices. And in
asm for that matter.

[1] There just is no official definition for OO. If one can list
"multiple inheritance" as a required part, I'm sure these others will
do quite as well.
 
I

Ioannis Vranos

Hannu said:
The links you gave to back this one up were only about what intentions
Stroustrup had.


All C++ constructs and all C++ implementations are designed with
efficiency always in mind.


C# is OK I guess for .NET applications, but is not a systems programming
language.



He didn't really prove any kind of optimality (as if
that would be possible). A more restricted environment like C# has
more potential for optimization and JIT compilers might even exceed
C++ in speed for "equivalent" code. In fact they already do in some
specially engineered test cases (which I have not done myself and am
relying on perhaps biased or wrong information).



There is also a Symmetrical Multiprocessing Standard called OpenMP
(http://www.openmp.org) for C, C++ and Fortran compilers (the efficient
languages).


-Now being MS specific- it is already supported by many compilers, and
the upcoming VC++ will also support it, in addition to .NET multi-threading.

An example is, when you have a loop like


for(int i=0; i<something; ++i)
a=b;


where each assignment is independent of the others, you can do:



#pragma omp for
for(int i=0; i<something; ++i)
a=b;


And each assignment is executed in a separate thread, taking advantage
of all processors available.


Also in the after Whidbey release of Visual Studio, C++ will be able to:

Create managed objects in native heap.

Create native types in managed heap.

In few words everything.



C# on the other hand is OK I guess, for regular .NET/CLI applications,
but is not a systems programming language.


C# has static functions for procedural programming,


That is pseudo-procedural. :)


namespaces for
modular programming. Does C++ support OO "completely"? It has no
metaclasses, no multidispatch, classes aren't objects nor does it have
reflection [1].


All these are features of CLI and of course there is C++ support for
these with system extensions keywords like __property,

and in C++/CLI more natively.


Talking C++/CLI can you do this kind of thing in C# at *compile time*,
producing 100% verifiable code?


//A generic function adding two objects
template <class T>
inline T Add(const T %a, const T %b)
{
return a+b;
}

value class someclass
{
int x;
};




int main()
{
int x = 7, y = 8;

int r = Add(x,y);
}


C:\c>cl /clr:safe temp.cpp
Microsoft (R) C/C++ Optimizing Compiler Version 14.00.40809
for Microsoft (R) .NET Framework version 2.00.40607.16
Copyright (C) Microsoft Corporation. All rights reserved.

temp.cpp
Microsoft (R) Incremental Linker Version 8.00.40809
Copyright (C) Microsoft Corporation. All rights reserved.

/out:temp.exe
temp.obj

C:\c>



I know of libraries that attemt at doing each of
these, but if they were accepted, I'm sure someone could write a C#
library for multiple inheritance among everything else. Only the
degree of cumbersomeness varies.

As for constructs not supported in C++ but supported in C#:
properties, reflection (& serialization), string switches, typeof,
language support for multithreading. Once again I'm sure many of these
can be achieved in C++ through rigorous programming practices. And in
asm for that matter.


C++/CLI and even current "managed extensions" supports all of them with
keywords. No additional libraries.
 
I

Ioannis Vranos

Ioannis said:
There is also a Symmetrical Multiprocessing Standard called OpenMP
(http://www.openmp.org) for C, C++ and Fortran compilers (the efficient
languages).


-Now being MS specific- it is already supported by many compilers, and
the upcoming VC++ will also support it, in addition to .NET
multi-threading.

An example is, when you have a loop like


for(int i=0; i<something; ++i)
a=b;


where each assignment is independent of the others, you can do:



#pragma omp for
for(int i=0; i<something; ++i)
a=b;


And each assignment is executed in a separate thread, taking advantage
of all processors available.




And as said above: In addition to .NET multithreading.





C++/CLI and even current "managed extensions" supports all of them with
keywords. No additional libraries.


*Every facility* available to C# is also available to C++ *in the same
way*, while the opposite is not true.

Especially about .NET multithreading, this is what I have been reading
these days, much pretty stuff. The Monitor class and the Thread class.

Running state, Stopped state, Suspended state, WaitSleepJoin state,
Background state etc. :)
 
H

Hannu Kankaanp??

Ioannis Vranos said:
namespaces for
modular programming. Does C++ support OO "completely"? It has no
metaclasses, no multidispatch, classes aren't objects nor does it have
reflection [1].

All these are features of CLI

Though I wasn't talking about CLI, AFAIK that's not true. But show me
wrong. (I know reflection is a feature of CLI)
and of course there is C++ support for
these with system extensions keywords like __property,

Then I'm sure you can describe me which keywords enable each of those
features, because I'm quite sceptical of this one as well. I wouldn't
call it C++ support either if only one compiler happened to implement
some feature.
and in C++/CLI more natively.

The C++/CLI draft 1.5 has no mention of metaclasses or multidispatch.
I have not read it but I did a quick search. I doubt one can just pass
classes around like objects, either. Maybe through some wrappers.
Reflection is there though.

And last but not least, when I was talking about C++, I was talking
about *the* C++ (1998 standard), not C++/CLI, or any non-standard
extensions to C++. Much like when I say C, I don't mean C++.
 
I

Ioannis Vranos

Hannu said:
Ioannis Vranos said:
namespaces for
modular programming. Does C++ support OO "completely"? It has no
metaclasses, no multidispatch, classes aren't objects nor does it have
reflection [1].

All these are features of CLI


Though I wasn't talking about CLI, AFAIK that's not true. But show me
wrong. (I know reflection is a feature of CLI)



For consistency I will use the C++/CLI standard syntax that will be used
in the upcoming version of Visual Studio 2005 and afterwards.

About classes not being objects, yes in C++ types themselves are not
objects and do not occupy space, and I think this is very reasonable.
But they do have static methods though.



Now about metaclasses, I assume you talk about attributes.


using namespace System;


// I create a custom attribute

[AttributeUsageAttribute(AttributeTargets::Class)]
public ref class SomeAttribute: public Attribute
{
public:
SomeAttribute(String ^) {}
property int Something;
};


// A class using this attribute

[SomeAttribute("Text", Something=7)]
ref class TestClass
{
};



int main()
{
TestClass obj;
}



Reflection is library support. We get a Type object etc.



Then I'm sure you can describe me which keywords enable each of those
features, because I'm quite sceptical of this one as well. I wouldn't
call it C++ support either if only one compiler happened to implement
some feature.




In the above code I created a trivial property, where the compiler
produces its definition.


In any case to avoid this tiring thing, have you checked this Microsoft
presentation?


http://microsoft.sitestream.com/TechEd/DEV/DEV333_files/Botto_files/DEV333_Sutte.ppt


C++ becomes the systems programming language of CLI and .NET, so C++ can
do all things C# can, while the opposite is not true.


Have you automatic Dispose definition in C#? Objects in the stack?
Compile time definition?



Can you do this in C#?


ref class ReferenceType
{
int i;

public:
ReferenceType():i(1) {}
ReferenceType(const ReferenceType %x) { i=x.i; }

void print() { System::Console::WriteLine(i); }

};


template <class T>
void display(T x)
{
x.print();
}



int main()
{
// Object with stack semantics - Deterministic destruction
// at the end of its scope
ReferenceType obj;

display(obj);


// Object in the managed heap
ReferenceType ^hobj= gcnew ReferenceType;

display(*hobj);


// Deterministic destruction
delete hobj;


ReferenceType ^hobj2= gcnew ReferenceType;

display(*hobj2);

// Not destroying hobj2, let it be finalised
}

C:\c>cl /clr:safe temp.cpp
Microsoft (R) C/C++ Optimizing Compiler Version 14.00.40809
for Microsoft (R) .NET Framework version 2.00.40607.16
Copyright (C) Microsoft Corporation. All rights reserved.

temp.cpp
Microsoft (R) Incremental Linker Version 8.00.40809
Copyright (C) Microsoft Corporation. All rights reserved.

/out:temp.exe
temp.obj

C:\c>temp
1
1
1

C:\c>


That is 100% verifiable code.




The C++/CLI draft 1.5 has no mention of metaclasses or multidispatch.
I have not read it but I did a quick search. I doubt one can just pass
classes around like objects, either. Maybe through some wrappers.
Reflection is there though.





You mean passing classes to other functions? Easy. Can you do this in C#?


ref class ReferenceType
{
public:

static void somefun() { System::Console::WriteLine("Hey\n"); }
};


ref class ReferenceType2
{
public:

static void somefun() { System::Console::WriteLine("Hey2\n"); }
};


template <class T>
void display()
{
T::somefun();
}



int main()
{
display<ReferenceType>();

display<ReferenceType2>();
}



C:\c>cl /clr:safe temp.cpp
Microsoft (R) C/C++ Optimizing Compiler Version 14.00.40809
for Microsoft (R) .NET Framework version 2.00.40607.16
Copyright (C) Microsoft Corporation. All rights reserved.

temp.cpp
Microsoft (R) Incremental Linker Version 8.00.40809
Copyright (C) Microsoft Corporation. All rights reserved.

/out:temp.exe
temp.obj

C:\c>temp
Hey

Hey2


C:\c>


And last but not least, when I was talking about C++, I was talking
about *the* C++ (1998 standard), not C++/CLI, or any non-standard
extensions to C++. Much like when I say C, I don't mean C++.




You don't get it. C++ standard itself is the core compile-time language
defining portability.


System specific stuff like CLI Virtual Machines, you will use those
facilities.



I use C++/CLI as you use C#/CLI (there is no a C# standard alone).


For example you can't use C# in a non-CLI environment, while ISO C++
code compiles everywhere, both in CLI and non CLI environments.
 
H

Herb Sutter

C++ becomes the systems programming language of CLI and .NET, so C++ can
do all things C# can, while the opposite is not true.

Just a note to avoid well-intentioned language-bashing: The above is what
Visual C++ 2005 is doing with respect to .NET (CLI) features, such as that
C++ will expose a few more of .NET's generics feature details than C#
chooses to.

But it would be incorrect to say that C++ can do all things C# can in
other respects when it comes to comparing language features. Notably, C#
2005 has both partial classes (the ability to add new members to an
already-defined class, within some limits) and anonymous delegates (a
limited but useful form of lambda functions) that VC++ 2005 will not have.

I do hope that the ISO C++ committee does more work on lambda functions
because I think they're important especially to make the standard
algorithms much more usable, and I hope to help develop that or be
involved somehow, but it's a "time permitting" thing.

Herb

---
Herb Sutter (www.gotw.ca)

Convener, ISO WG21 (C++ standards committee) (www.gotw.ca/iso)
Contributing editor, C/C++ Users Journal (www.gotw.ca/cuj)
Architect, Developer Division, Microsoft (www.gotw.ca/microsoft)
 
R

red floyd

Merrill said:
...snips...
testing

congratulations. You failed the test.

1. use alt.test
2. please don't post binary attachments. Put your code in your post in
raw text.
3. Visual Studio specific stuff (as your attachment appeared to be) is
not relevant to this group. Try one of the microsoft.public.vstudio groups.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,062
Latest member
OrderKetozenseACV

Latest Threads

Top