C++ with automatic garbage collection = C#
-
What is the real difference, you ask? It is there in the title itself. Plus you may argue that c# is more typesafe and stuff; avoids any usually complex pointer logic; avoids pointers totally...yada yada yada... To me it is just the way c# language compiler was designed. When you come down to the compiler level you have to de-initialize an object and clear memory. No other way to do this. It may be a mammoth task in c++, but it is possible. Everything is possible. Those who say something is impossible are probably out of ideas (or lack of sample code maybe :confused:). Given indefinite time I believe developing applications in c++ would result in robust applications. However what most programmers do today is charge into the arena like a bull! I'd rather like to plan my path. And a piece of paper and a pen that writes is always a good start. I wonder who the hell said: time is money. I'd want to throw my pc at him, and say thankyou very much! It is what people are asking for. It is our society. Most of the time when customers ask developers to do something, they completely drop the ethical sense. The result of this is that you are being pressurized, unnecessarily; or worse the customers themselves pressurizing you, unnecessarily! For if it was the opposite case (i.e. the customers had this ethical knowledge) and they kept pressurizing you, there would at least be some sort of justice/sense in that! (You being nailed to the wall here is not the point). --deostroll
Well maybe C++ is assembler with... ummm... objects and stuff.
-
Well maybe C++ is assembler with... ummm... objects and stuff.
No, it's C with objects and stuff. C is assembler with variable names and stuff.
Christian Graus - Microsoft MVP - C++ "I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
-
Stroustrup was asked when Java came out what he thought of GC. His core answer was that GC would have killed C++, because of performance issues ( which may have been more real with the speed of processors then, than now ). There are a LOT of differences between C++ and C#. C++ has a better standard library, but C# offers support for things that C++ does not, such as regex. Yes, you can add those, I'm talking core language here. If anything, I think it's a shame C# looks like C++, when it's really very different in many ways.
deostroll wrote:
The result of this is that you are being pressurized, unnecessarily; or worse the customers themselves pressurizing you, unnecessarily!
Really, the issue is that your client has no idea how long software takes, and a strong idea of when they want it. Explain the development triangle to them. Features, time, reliability. You can have two. Tell me which one to sacrifice to get the other two done.
deostroll wrote:
Given indefinite time I believe developing applications in c++ would result in robust applications.
Given *reasonable* time, C++ results in robust applications.
Christian Graus - Microsoft MVP - C++ "I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
The D language is a better candidate to be called "C++ with GC".
Christian Graus wrote:
a better standard library
More importantly all the CLI languages share one standard library.
Christian Graus wrote:
I think it's a shame C# looks like C++,
I do too; I wish C# fixed more of the shortcomings of C/C++. The worst, in my opinion, is
switch
statements. Yes, default fallthrough is bad, but requiringbreak
isn't much better. Things would be so much better ifbreak
didn't affectswitch
at all. (Yes, I realize it was done this way to make refactoring C/C++ to C# less error prone. And yes I think they made the right decision under the circumstances.) I'm waiting for thenext
language that will learn from C#'s shortcomings. -
No, it's C with objects and stuff. C is assembler with variable names and stuff.
Christian Graus - Microsoft MVP - C++ "I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
And via inheritence...
-
The D language is a better candidate to be called "C++ with GC".
Christian Graus wrote:
a better standard library
More importantly all the CLI languages share one standard library.
Christian Graus wrote:
I think it's a shame C# looks like C++,
I do too; I wish C# fixed more of the shortcomings of C/C++. The worst, in my opinion, is
switch
statements. Yes, default fallthrough is bad, but requiringbreak
isn't much better. Things would be so much better ifbreak
didn't affectswitch
at all. (Yes, I realize it was done this way to make refactoring C/C++ to C# less error prone. And yes I think they made the right decision under the circumstances.) I'm waiting for thenext
language that will learn from C#'s shortcomings.PIEBALDconsult wrote:
More importantly all the CLI languages share one standard library.
So ?
PIEBALDconsult wrote:
The worst, in my opinion, is switch statements.
Far from the worst, but it is a disaster. The C# team says they are aiming to make the language as easy as possible, which is the exact opposite of the goal of the C++ team ( make it as powerful as it can be ).
PIEBALDconsult wrote:
Things would be so much better if break didn't affect switch at all
It would be more obvious. But, the C++ way is better, because it assumes I have half a brain, and it gives me more power to write good code.
PIEBALDconsult wrote:
I'm waiting for the next language that will learn from C#'s shortcomings.
It is indeed unfair to compare C++ and C#, excepting where C# fails and C++ succeeds, because it makes no sense to suggest that a language that came out 10 years later ( or whatever it is ) would not take the time to learn from the mistakes of what came before.
Christian Graus - Microsoft MVP - C++ "I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
-
PIEBALDconsult wrote:
More importantly all the CLI languages share one standard library.
So ?
PIEBALDconsult wrote:
The worst, in my opinion, is switch statements.
Far from the worst, but it is a disaster. The C# team says they are aiming to make the language as easy as possible, which is the exact opposite of the goal of the C++ team ( make it as powerful as it can be ).
PIEBALDconsult wrote:
Things would be so much better if break didn't affect switch at all
It would be more obvious. But, the C++ way is better, because it assumes I have half a brain, and it gives me more power to write good code.
PIEBALDconsult wrote:
I'm waiting for the next language that will learn from C#'s shortcomings.
It is indeed unfair to compare C++ and C#, excepting where C# fails and C++ succeeds, because it makes no sense to suggest that a language that came out 10 years later ( or whatever it is ) would not take the time to learn from the mistakes of what came before.
Christian Graus - Microsoft MVP - C++ "I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
Christian Graus wrote:
it assumes I have half a brain
Oh I'd assume more than that. The problem with
break
in aswitch
is when theswitch
is in awhile
and I want tobreak
thewhile
. I cancontinue
thewhile
; I should be able tobreak
thewhile
. Or is there some tried-and-true technique of which I'm unaware? Set something I know will terminate thewhile
and usecontinue
? -
Stroustrup was asked when Java came out what he thought of GC. His core answer was that GC would have killed C++, because of performance issues ( which may have been more real with the speed of processors then, than now ). There are a LOT of differences between C++ and C#. C++ has a better standard library, but C# offers support for things that C++ does not, such as regex. Yes, you can add those, I'm talking core language here. If anything, I think it's a shame C# looks like C++, when it's really very different in many ways.
deostroll wrote:
The result of this is that you are being pressurized, unnecessarily; or worse the customers themselves pressurizing you, unnecessarily!
Really, the issue is that your client has no idea how long software takes, and a strong idea of when they want it. Explain the development triangle to them. Features, time, reliability. You can have two. Tell me which one to sacrifice to get the other two done.
deostroll wrote:
Given indefinite time I believe developing applications in c++ would result in robust applications.
Given *reasonable* time, C++ results in robust applications.
Christian Graus - Microsoft MVP - C++ "I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
Christian Graus wrote:
Yes, you can add those, I'm talking core language here.
this always annoys me (not you, this). IMO, the "core language" is the syntax and grammar. something that you write using that grammar and ship with the compiler isn't part of the language, it's an external library. ex., RegEx support in C# is something someone wrote using C# (or some other .Net language, or something that can be called from C#) - it's not something that's intrinsic to C# any more than RegEx is intrisic to C++. just because MS ships their C# compiler with all these wonderful classes doesn't make C# the language better - it just makes MS's C# package better. yes, yes, i know standards bodies can say that X,Y and Z are part of the language. but that's nonsense. it's like saying the C# specification is part of the official English language, and that makes English a better language than some equally-expressive spoken language into which the C# spec hasn't been translated. the C# spec is the C# spec, regardless of the language used to describe it, and no language will ever be created of which the C# spec is considered an integral part. in other words: you can't measure the quality of a language in terms of things that have been written in that language, you can only measure it in terms of things that can be written in that language, and the language is the syntax and grammar. GC is part of C# the same way vtables are part of C++. RegEx is an add-on in both. yes, i know that's not the official CS point of view. /rant
-
Christian Graus wrote:
Yes, you can add those, I'm talking core language here.
this always annoys me (not you, this). IMO, the "core language" is the syntax and grammar. something that you write using that grammar and ship with the compiler isn't part of the language, it's an external library. ex., RegEx support in C# is something someone wrote using C# (or some other .Net language, or something that can be called from C#) - it's not something that's intrinsic to C# any more than RegEx is intrisic to C++. just because MS ships their C# compiler with all these wonderful classes doesn't make C# the language better - it just makes MS's C# package better. yes, yes, i know standards bodies can say that X,Y and Z are part of the language. but that's nonsense. it's like saying the C# specification is part of the official English language, and that makes English a better language than some equally-expressive spoken language into which the C# spec hasn't been translated. the C# spec is the C# spec, regardless of the language used to describe it, and no language will ever be created of which the C# spec is considered an integral part. in other words: you can't measure the quality of a language in terms of things that have been written in that language, you can only measure it in terms of things that can be written in that language, and the language is the syntax and grammar. GC is part of C# the same way vtables are part of C++. RegEx is an add-on in both. yes, i know that's not the official CS point of view. /rant
Chris Losinger wrote:
GC is part of C#
No, it's part of .net. -- modified at 23:17 Thursday 4th October, 2007 the common language runtime (CLR)'s garbage collector http://msdn2.microsoft.com/en-us/library/ms973837.aspx[^]
-
PIEBALDconsult wrote:
More importantly all the CLI languages share one standard library.
So ?
PIEBALDconsult wrote:
The worst, in my opinion, is switch statements.
Far from the worst, but it is a disaster. The C# team says they are aiming to make the language as easy as possible, which is the exact opposite of the goal of the C++ team ( make it as powerful as it can be ).
PIEBALDconsult wrote:
Things would be so much better if break didn't affect switch at all
It would be more obvious. But, the C++ way is better, because it assumes I have half a brain, and it gives me more power to write good code.
PIEBALDconsult wrote:
I'm waiting for the next language that will learn from C#'s shortcomings.
It is indeed unfair to compare C++ and C#, excepting where C# fails and C++ succeeds, because it makes no sense to suggest that a language that came out 10 years later ( or whatever it is ) would not take the time to learn from the mistakes of what came before.
Christian Graus - Microsoft MVP - C++ "I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
Christian Graus wrote:
The C# team says they are aiming to make the language as easy as possible, which is the exact opposite of the goal of the C++ team ( make it as powerful as it can be ).
That's why I don't like C#. IMO they are creating a monster with the language. As an example, do the
yeild return
thing adds power? No. But it makes it easy. It reminds me of all this keywords they added to VB6 (not comparing both languages though). They are just making it fancier, instead of giving power to the programmer. However, I wish the C++ library had more features. A GUI, for example, would be very nice. And XML and networking support. I know that the main goal is to make it portable, thus there may be devices that couldn't support this features. But what the hell, for these cases, they don't have to fulfill the standard (e.g. Embedded VC++ 3 didn't support exception handling). Any way, I'm still looking forward the next version of the standard.
Hope is the negation of reality - Raistlin Majere
-
What is the real difference, you ask? It is there in the title itself. Plus you may argue that c# is more typesafe and stuff; avoids any usually complex pointer logic; avoids pointers totally...yada yada yada... To me it is just the way c# language compiler was designed. When you come down to the compiler level you have to de-initialize an object and clear memory. No other way to do this. It may be a mammoth task in c++, but it is possible. Everything is possible. Those who say something is impossible are probably out of ideas (or lack of sample code maybe :confused:). Given indefinite time I believe developing applications in c++ would result in robust applications. However what most programmers do today is charge into the arena like a bull! I'd rather like to plan my path. And a piece of paper and a pen that writes is always a good start. I wonder who the hell said: time is money. I'd want to throw my pc at him, and say thankyou very much! It is what people are asking for. It is our society. Most of the time when customers ask developers to do something, they completely drop the ethical sense. The result of this is that you are being pressurized, unnecessarily; or worse the customers themselves pressurizing you, unnecessarily! For if it was the opposite case (i.e. the customers had this ethical knowledge) and they kept pressurizing you, there would at least be some sort of justice/sense in that! (You being nailed to the wall here is not the point). --deostroll
deostroll wrote:
C++ with automatic garbage collection = C#
Next version of C++ standard comes with garbage collector. :cool:
Hope is the negation of reality - Raistlin Majere
-
Christian Graus wrote:
it assumes I have half a brain
Oh I'd assume more than that. The problem with
break
in aswitch
is when theswitch
is in awhile
and I want tobreak
thewhile
. I cancontinue
thewhile
; I should be able tobreak
thewhile
. Or is there some tried-and-true technique of which I'm unaware? Set something I know will terminate thewhile
and usecontinue
?If my switch code was that complex, I'd have the switch call a method, which returned true or false, and use that return value to break or continue.
Christian Graus - Microsoft MVP - C++ "I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
-
deostroll wrote:
C++ with automatic garbage collection = C#
Next version of C++ standard comes with garbage collector. :cool:
Hope is the negation of reality - Raistlin Majere
That's plain sad.
Christian Graus - Microsoft MVP - C++ "I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
-
Christian Graus wrote:
Yes, you can add those, I'm talking core language here.
this always annoys me (not you, this). IMO, the "core language" is the syntax and grammar. something that you write using that grammar and ship with the compiler isn't part of the language, it's an external library. ex., RegEx support in C# is something someone wrote using C# (or some other .Net language, or something that can be called from C#) - it's not something that's intrinsic to C# any more than RegEx is intrisic to C++. just because MS ships their C# compiler with all these wonderful classes doesn't make C# the language better - it just makes MS's C# package better. yes, yes, i know standards bodies can say that X,Y and Z are part of the language. but that's nonsense. it's like saying the C# specification is part of the official English language, and that makes English a better language than some equally-expressive spoken language into which the C# spec hasn't been translated. the C# spec is the C# spec, regardless of the language used to describe it, and no language will ever be created of which the C# spec is considered an integral part. in other words: you can't measure the quality of a language in terms of things that have been written in that language, you can only measure it in terms of things that can be written in that language, and the language is the syntax and grammar. GC is part of C# the same way vtables are part of C++. RegEx is an add-on in both. yes, i know that's not the official CS point of view. /rant
Chris Losinger wrote:
GC is part of C# the same way vtables are part of C++. RegEx is an add-on in both
Nitpicking, one could say that is true. In the real world, C# doesn't really exist apart from the .NET framework. It's a bit like people assuming that MFC is part of C++, the difference is that in the C# world, there's no real world opposing viewpoint, no version of C# for which it's not true.
Christian Graus - Microsoft MVP - C++ "I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
-
Christian Graus wrote:
Yes, you can add those, I'm talking core language here.
this always annoys me (not you, this). IMO, the "core language" is the syntax and grammar. something that you write using that grammar and ship with the compiler isn't part of the language, it's an external library. ex., RegEx support in C# is something someone wrote using C# (or some other .Net language, or something that can be called from C#) - it's not something that's intrinsic to C# any more than RegEx is intrisic to C++. just because MS ships their C# compiler with all these wonderful classes doesn't make C# the language better - it just makes MS's C# package better. yes, yes, i know standards bodies can say that X,Y and Z are part of the language. but that's nonsense. it's like saying the C# specification is part of the official English language, and that makes English a better language than some equally-expressive spoken language into which the C# spec hasn't been translated. the C# spec is the C# spec, regardless of the language used to describe it, and no language will ever be created of which the C# spec is considered an integral part. in other words: you can't measure the quality of a language in terms of things that have been written in that language, you can only measure it in terms of things that can be written in that language, and the language is the syntax and grammar. GC is part of C# the same way vtables are part of C++. RegEx is an add-on in both. yes, i know that's not the official CS point of view. /rant
Chris Losinger wrote:
this always annoys me (not you, this)
:omg: But but but what would you do without the
this
pointer?
Hope is the negation of reality - Raistlin Majere
-
deostroll wrote:
C++ with automatic garbage collection = C#
Next version of C++ standard comes with garbage collector. :cool:
Hope is the negation of reality - Raistlin Majere
Ehhhhxcellent... :cool:
-
That's plain sad.
Christian Graus - Microsoft MVP - C++ "I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
Well, it's optional. AFAIK, you'll have to place a modifier to the class, so only those classes' instances will be collected.
Hope is the negation of reality - Raistlin Majere
-
If my switch code was that complex, I'd have the switch call a method, which returned true or false, and use that return value to break or continue.
Christian Graus - Microsoft MVP - C++ "I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
Could also put the
while
in a method andreturn
from theswitch
. Lots of ways to do it, various levels of cleanliness. -
Well, it's optional. AFAIK, you'll have to place a modifier to the class, so only those classes' instances will be collected.
Hope is the negation of reality - Raistlin Majere
Either way, what's the point of having different languages, that are all the same ?
Christian Graus - Microsoft MVP - C++ "I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
-
Could also put the
while
in a method andreturn
from theswitch
. Lots of ways to do it, various levels of cleanliness.Sure - core issue is to refactor so a switch doesn't contan buckets of code. You should definately be able to easily see all the cases. And, I like to refactor code anyhow, to make for smaller, simpler methods.
Christian Graus - Microsoft MVP - C++ "I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
-
Chris Losinger wrote:
GC is part of C#
No, it's part of .net. -- modified at 23:17 Thursday 4th October, 2007 the common language runtime (CLR)'s garbage collector http://msdn2.microsoft.com/en-us/library/ms973837.aspx[^]
PIEBALDconsult wrote:
No, it's part of .net.
Yeah but in a future version of the .NET framework, if it was a configurable option to turn off the GC (say via a GC::ShutDown() method), I am sure this wouldn't be a practical option for C#. Since C# does not have a syntactic equivalent of the C++ delete. You'd have to end up doing something weird like GCHandle::Delete(object) which would kill off C# popularity. So while GC is a part of .NET, people will always associate it with C#.
Regards, Nish
Nish’s thoughts on MFC, C++/CLI and .NET (my blog)
My latest book : C++/CLI in Action / Amazon.com link