C++/Java/C#

This is a discussion on C++/Java/C# within the A Brief History of Cprogramming.com forums, part of the Community Boards category; I strongly dis agree. Simply because it the GC will destroy objects at its whim, not when YOU want to. ...

  1. #91
    C++まいる!Cをこわせ! Elysia's Avatar
    Join Date
    Oct 2007
    Posts
    22,614
    I strongly disagree. Simply because it the GC will destroy objects at its whim, not when YOU want to.
    You also have to be extra careful about when the GC may destroy objects.
    C++ was not designed for garbage collection. Simple as that.
    I don't doubt the quality of the collectors, but I doubt their ability to function properly in advanced written C++ code.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  2. #92
    Registered User
    Join Date
    Apr 2008
    Posts
    890
    Quote Originally Posted by Elysia View Post
    I strongly disagree. Simply because it the GC will destroy objects at its whim, not when YOU want to.
    You also have to be extra careful about when the GC may destroy objects.
    C++ was not designed for garbage collection. Simple as that.
    I don't doubt the quality of the collectors, but I doubt their ability to function properly in advanced written C++ code.
    Perhaps you can chat with Bjarne and tell the designer of the language why he's wrong.

  3. #93
    C++まいる!Cをこわせ! Elysia's Avatar
    Join Date
    Oct 2007
    Posts
    22,614
    I have been known to disagree with Bjarne a lot of times and this is one of them.
    GC does not belong to C++. It completely destroys C++ design.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  4. #94
    (?<!re)tired Mario F.'s Avatar
    Join Date
    May 2006
    Location
    Portugal
    Posts
    7,467
    Quote Originally Posted by medievalelks View Post
    This guy disagrees
    Does he?

    Quote Originally Posted by The C++ Programming Language 3rd Edition, 10.4.5
    Some C++ implementations automatically recycle the storage occupied by unreachable objects (garbage collecting implementations), but their behavior is not standardized. [...] In particular, where a garbage collector is known to exist, destructors that do memory management only can be eliminated. This simplification comes at the cost of portability and for some programs, a possible increase in run time and loss of predictability of run-time behavior.
    Bold and any possible typos are mine. I suggest you also read Appendix C, 9.1

    And, for good measure... do read the rest on his website...

    I suggest you don't do hasty lookups on the web to try and prove your point. Especially when you don't do an effort to hear the other side of things. And what the language author himself has to say about this issue on his more detailed expositions. I'm trying to find also a very interesting article I was linked to on these boards from Josuttis on this very same issue. Makes a good reading. Will post it here when I find it.

    EDIT: I'm not the one going to stop you though. If you want to start using a GC on your projects, have all the fun in the world. I just know for a fact you won't do it for long.
    Last edited by Mario F.; 06-29-2008 at 10:15 AM.
    The programmer’s wife tells him: “Run to the store and pick up a loaf of bread. If they have eggs, get a dozen.”
    The programmer comes home with 12 loaves of bread.


    Originally Posted by brewbuck:
    Reimplementing a large system in another language to get a 25% performance boost is nonsense. It would be cheaper to just get a computer which is 25% faster.

  5. #95
    Cat without Hat CornedBee's Avatar
    Join Date
    Apr 2003
    Posts
    8,893
    Don't confuse garbage collection with non-deterministic destruction. Just because a language has automatic garbage collection for the heap doesn't mean you won't have deterministic destruction for the stack. For example, if you use a garbage collector library for C++, you'll still have deterministic destruction on the stack (sufficient for RAII), but possibly no destruction at all on the heap. (So don't put things on the heap that require a destructor.)

    In fact, requiring cleanup actions for an object that is garbage collected is bad style, no matter what language. That's why finalizers are considered a last resort in Java, and why the dispose pattern should be preferred in C#.
    All the buzzt!
    CornedBee

    "There is not now, nor has there ever been, nor will there ever be, any programming language in which it is the least bit difficult to write bad code."
    - Flon's Law

  6. #96
    Registered User
    Join Date
    Jan 2005
    Posts
    7,319
    I didn't realize there was a default clone.

  7. #97
    Registered User
    Join Date
    Apr 2008
    Posts
    890
    Quote Originally Posted by Mario F. View Post
    Does he?
    Yes, he disagrees with your and Elysia's blanket claim that C++ was poorly designed for GC.


    I suggest you don't do hasty lookups on the web to try and prove your point. Especially when you don't do an effort to
    It was a hasty lookup to disprove a hasty, blanket statement.

    I just know for a fact you won't do it for long.
    Another hasty, blanket statement. This thread is devolving into religion, so I think I'll exit.

  8. #98
    (?<!re)tired Mario F.'s Avatar
    Join Date
    May 2006
    Location
    Portugal
    Posts
    7,467
    Look medievalelks, I even like you. But don't call blanket statements to posts I put an effort on, giving quotes from important references and searching for long forgotten links from respected C++ programmers, all for your benefit (not mine).

    Just makes me want to not do it again and don't bother with you.
    The programmer’s wife tells him: “Run to the store and pick up a loaf of bread. If they have eggs, get a dozen.”
    The programmer comes home with 12 loaves of bread.


    Originally Posted by brewbuck:
    Reimplementing a large system in another language to get a 25% performance boost is nonsense. It would be cheaper to just get a computer which is 25% faster.

  9. #99
    Super Moderator VirtualAce's Avatar
    Join Date
    Aug 2001
    Posts
    9,596
    I mean, GC languages aren't theory, they've been around for decades and used in production systems.I mean, GC languages aren't theory, they've been around for decades and used in production systems.
    This too has been widely debated on the internet. Many feel the GC memory model of Java is seriously flawed. I have not seen a lot of debate about C# but I'm sure there are some valid ones out there.

    Java and C# in and of themselves are not bad and are just tools. But trying to apply their use of memory to C++ is a waste of development time. C++ is a different tool. Why try to make a hammer like a screwdriver? A hammer does what it does best but if you try to make it work like a screwdriver..well good luck with that.

    One of my co-workers was worried about memory management b/c at his former job they used Java. He really felt that memory management was a huge issue in C++. I kept telling him it was not and just said if you new it, delete it, malloc it, free it. We had a discussion just the other day and after about 6 months in C++ he now feels that memory management in C++ is not a problem. He believed all the rumors before even trying to manage his own memory. Now that he can I suspect he will detest not being able to in a GC language.

    I really don't think memory management is a problem in C++. But if this can be proven true then all of the GC languges have a better reason to even exist in the first place. Java's main argument, in my book, is it's Web applications which are not nearly as easy in C++. Therefore I feel that Java does have it's niche. For C# I'm just not sure where it fits since C++ can do anything and everything that C# can including GUIs. Perhaps it's niche is that the .NET controls are ten times better than anything in the Win32 API.

    Most C++ compilers offer a very robust debug CRT that will just about hold your hand along the way. They can report leaks, where they were allocated, and their size. With all of this turned on it's unclear to me why people have trouble with memory management in C++. I can't see a competent C++ programmer claiming memory management is an issue in C++ and then give Java or C# as a 'way out'. That's not much basis for a new language.
    Last edited by VirtualAce; 06-29-2008 at 10:43 AM.

  10. #100
    Registered User
    Join Date
    Apr 2008
    Posts
    890
    Quote Originally Posted by Bubba View Post
    With all of this turned on it's unclear to me why people have trouble with memory management in C++. I can't see a competent C++ programmer claiming memory management is an issue in C++ and then give Java or C# as a 'way out'. That's not much basis for a new language.
    I've said several times that mem mgmt in C++ is not a difficult issue, it's just an ever present one that I grow tired of.

  11. #101
    (?<!re)tired Mario F.'s Avatar
    Join Date
    May 2006
    Location
    Portugal
    Posts
    7,467
    If you grow tired of STL containers and smart pointers you shouldn't program in C++. We agree on that.
    The programmer’s wife tells him: “Run to the store and pick up a loaf of bread. If they have eggs, get a dozen.”
    The programmer comes home with 12 loaves of bread.


    Originally Posted by brewbuck:
    Reimplementing a large system in another language to get a 25% performance boost is nonsense. It would be cheaper to just get a computer which is 25% faster.

  12. #102
    Cat without Hat CornedBee's Avatar
    Join Date
    Apr 2003
    Posts
    8,893
    Quote Originally Posted by Daved View Post
    I didn't realize there was a default clone.
    There is. It's implemented roughly like this:
    Code:
    public Object clone()
    {
      if(!(this instanceof Cloneable)) throw new IForgotWhichException();
      return low_level_clone();
    }
    All the buzzt!
    CornedBee

    "There is not now, nor has there ever been, nor will there ever be, any programming language in which it is the least bit difficult to write bad code."
    - Flon's Law

  13. #103
    Registered User
    Join Date
    Nov 2006
    Posts
    519
    Quote Originally Posted by medievalelks View Post
    The need for deep-copy in a language that passes by reference is the exception, not the rule, at least the way I program. There's generally no need to be copying objects around willy-nilly in a program anyway.

    In C++ you have to adhere to convention (pass by ref or ptr instead of value) to obviate the need for copying objects.
    "problem" so far are the stl containers, they love to copy. do java/c#/python containers just hold references to avoid that?

  14. #104
    C++まいる!Cをこわせ! Elysia's Avatar
    Join Date
    Oct 2007
    Posts
    22,614
    STL containers are efficient. In Java, everything is "references" which really are pointers.
    You can do the same in C++ by putting pointers inside the containers.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  15. #105
    Cat without Hat CornedBee's Avatar
    Join Date
    Apr 2003
    Posts
    8,893
    The need for copying really only exists for data objects anyway. Those are always problematic in Java, because you're faced with two design choices where both have considerable trade-offs - a consequence of the lack of a proper const keyword.

    Non-data objects should be made non-copyable.
    All the buzzt!
    CornedBee

    "There is not now, nor has there ever been, nor will there ever be, any programming language in which it is the least bit difficult to write bad code."
    - Flon's Law

Page 7 of 8 FirstFirst 12345678 LastLast
Popular pages Recent additions subscribe to a feed

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21