Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. The Lounge
  3. C++ with automatic garbage collection = C#

C++ with automatic garbage collection = C#

Scheduled Pinned Locked Moved The Lounge
questioncsharpc++performance
87 Posts 31 Posters 2 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • P PIEBALDconsult

    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 requiring break isn't much better. Things would be so much better if break didn't affect switch 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 the next language that will learn from C#'s shortcomings.

    C Offline
    C Offline
    Christian Graus
    wrote on last edited by
    #7

    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 )

    P F M 3 Replies Last reply
    0
    • C Christian Graus

      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 )

      P Offline
      P Offline
      PIEBALDconsult
      wrote on last edited by
      #8

      Christian Graus wrote:

      it assumes I have half a brain

      Oh I'd assume more than that. The problem with break in a switch is when the switch is in a while and I want to break the while. I can continue the while; I should be able to break the while. Or is there some tried-and-true technique of which I'm unaware? Set something I know will terminate the while and use continue?

      C 1 Reply Last reply
      0
      • C Christian Graus

        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 )

        C Offline
        C Offline
        Chris Losinger
        wrote on last edited by
        #9

        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

        image processing toolkits | batch image processing

        P F C 3 Replies Last reply
        0
        • C Chris Losinger

          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

          image processing toolkits | batch image processing

          P Offline
          P Offline
          PIEBALDconsult
          wrote on last edited by
          #10

          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[^]

          N 1 Reply Last reply
          0
          • C Christian Graus

            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 )

            F Offline
            F Offline
            Fernando A Gomez F
            wrote on last edited by
            #11

            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

            J B D B 4 Replies Last reply
            0
            • D deostroll

              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

              F Offline
              F Offline
              Fernando A Gomez F
              wrote on last edited by
              #12

              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

              C P A 3 Replies Last reply
              0
              • P PIEBALDconsult

                Christian Graus wrote:

                it assumes I have half a brain

                Oh I'd assume more than that. The problem with break in a switch is when the switch is in a while and I want to break the while. I can continue the while; I should be able to break the while. Or is there some tried-and-true technique of which I'm unaware? Set something I know will terminate the while and use continue?

                C Offline
                C Offline
                Christian Graus
                wrote on last edited by
                #13

                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 )

                P 1 Reply Last reply
                0
                • C Chris Losinger

                  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

                  image processing toolkits | batch image processing

                  F Offline
                  F Offline
                  Fernando A Gomez F
                  wrote on last edited by
                  #14

                  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

                  1 Reply Last reply
                  0
                  • C Chris Losinger

                    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

                    image processing toolkits | batch image processing

                    C Offline
                    C Offline
                    Christian Graus
                    wrote on last edited by
                    #15

                    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 )

                    S C J 3 Replies Last reply
                    0
                    • F Fernando A Gomez F

                      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

                      C Offline
                      C Offline
                      Christian Graus
                      wrote on last edited by
                      #16

                      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 )

                      F 1 Reply Last reply
                      0
                      • F Fernando A Gomez F

                        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

                        P Offline
                        P Offline
                        PIEBALDconsult
                        wrote on last edited by
                        #17

                        Ehhhhxcellent... :cool:

                        1 Reply Last reply
                        0
                        • C Christian Graus

                          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 )

                          F Offline
                          F Offline
                          Fernando A Gomez F
                          wrote on last edited by
                          #18

                          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

                          C J 2 Replies Last reply
                          0
                          • C Christian Graus

                            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 )

                            P Offline
                            P Offline
                            PIEBALDconsult
                            wrote on last edited by
                            #19

                            Could also put the while in a method and return from the switch. Lots of ways to do it, various levels of cleanliness.

                            C 1 Reply Last reply
                            0
                            • F Fernando A Gomez F

                              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

                              C Offline
                              C Offline
                              Christian Graus
                              wrote on last edited by
                              #20

                              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 )

                              F P 2 Replies Last reply
                              0
                              • P PIEBALDconsult

                                Could also put the while in a method and return from the switch. Lots of ways to do it, various levels of cleanliness.

                                C Offline
                                C Offline
                                Christian Graus
                                wrote on last edited by
                                #21

                                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 )

                                R 1 Reply Last reply
                                0
                                • C Christian Graus

                                  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 )

                                  F Offline
                                  F Offline
                                  Fernando A Gomez F
                                  wrote on last edited by
                                  #22

                                  Good point. But I believe that is more like taking good things from other languages, as long as they do not get in the way of the main language's goals. But yeah, I understand your point --and kinda agree with you.


                                  Hope is the negation of reality - Raistlin Majere

                                  1 Reply Last reply
                                  0
                                  • P PIEBALDconsult

                                    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[^]

                                    N Offline
                                    N Offline
                                    Nish Nishant
                                    wrote on last edited by
                                    #23

                                    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

                                    P S 2 Replies Last reply
                                    0
                                    • D deostroll

                                      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

                                      A Offline
                                      A Offline
                                      Anton Afanasyev
                                      wrote on last edited by
                                      #24

                                      deos**troll**

                                      What else do you want from the guy?


                                      :badger:

                                      P 1 Reply Last reply
                                      0
                                      • F Fernando A Gomez F

                                        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

                                        A Offline
                                        A Offline
                                        Anton Afanasyev
                                        wrote on last edited by
                                        #25

                                        I wonder how long it would take till the first Service Pack that fixes the memory leak in the GC for C++?


                                        :badger:

                                        F 1 Reply Last reply
                                        0
                                        • A Anton Afanasyev

                                          deos**troll**

                                          What else do you want from the guy?


                                          :badger:

                                          P Offline
                                          P Offline
                                          PIEBALDconsult
                                          wrote on last edited by
                                          #26

                                          Well yes, but if he's God's own troll...

                                          1 Reply Last reply
                                          0
                                          Reply
                                          • Reply as topic
                                          Log in to reply
                                          • Oldest to Newest
                                          • Newest to Oldest
                                          • Most Votes


                                          • Login

                                          • Don't have an account? Register

                                          • Login or register to search.
                                          • First post
                                            Last post
                                          0
                                          • Categories
                                          • Recent
                                          • Tags
                                          • Popular
                                          • World
                                          • Users
                                          • Groups