C++ sucks as an OO language

Discussion in 'Programming' started by z_kingtut, Oct 17, 2007.

  1. #1
    Static typing makes using generic containers a pain in the butt, due to the need of upcasting. So one tries to fix it by using STL template based containers. But then you switch to Generic programming and getting it to work with your OO designed program is asking for trouble.

    Say you got a scene graph type of structure, consisting of Shape objects. Shape use a composite pattern. LayeredShape and GroupShape inherit Shape. Each store shape objects in different data structures. You want to provide access to all sub shapes in the composites. The natural choice would be to use an iterator. Except you can't expose STL type iterators because those are type specific to the container type. E.g. a vector<int>::iterator is of a different type from list<int>::iterator. Now this works fine for Generic programming because you are not programming against interfaces like in OOP. But it makes it impossible to define a virtual iterator accessor in the Shape class.

    This is just one example, but I find it to be a annoying and extremely reoccuring problem that concepts from STL and generic progarmming simply don't fitt in with OOP.

    On large applications I find that you essentially end up reimplementing the features of a more dynamic OO language in a non standard and buggy way on C++.

    Please not I am not saying C++ is a bad language. It is extremely powerfull for creating algorithms and template programming is extremely powerfull. But as an OO language it is extremely cumbersome to use. One ends up reinventing too much concepts from other languages.
     
    z_kingtut, Oct 17, 2007 IP
  2. firesexwater

    firesexwater Peon

    Messages:
    19
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Plain C is better than C++
     
    firesexwater, Oct 17, 2007 IP
  3. buldozerceto

    buldozerceto Active Member

    Messages:
    1,137
    Likes Received:
    43
    Best Answers:
    0
    Trophy Points:
    88
    #3
    Plain C doesnt support Object-Oriented Programming DUDE
     
    buldozerceto, Oct 18, 2007 IP
  4. lavaglobe

    lavaglobe Guest

    Messages:
    26
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #4
    c++ is just c with a few added commands. how could c be any way better then c++ :p
     
    lavaglobe, Oct 18, 2007 IP
  5. jkrish41

    jkrish41 Banned

    Messages:
    2,416
    Likes Received:
    111
    Best Answers:
    0
    Trophy Points:
    0
    #5
    I took 2 years of c++ programming in my school, and I wish there was another programming course I could of taken, but c++ was the only available one.

    I honestly probably won't use it again, but I am going into the computer field for college, so it will probably be good just to say I know c++ :p
     
    jkrish41, Oct 18, 2007 IP
  6. getjimmy

    getjimmy Prominent Member

    Messages:
    17,260
    Likes Received:
    1,005
    Best Answers:
    0
    Trophy Points:
    360
    #6
    Java is better as an Object-Oriented,
     
    getjimmy, Oct 18, 2007 IP
  7. firesexwater

    firesexwater Peon

    Messages:
    19
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #7
    Don't you assume I already know that ... my point was that Plain C is more efficient than C++ ... with C you just basically work with functions

    http://nothings.org/computer/cpp.html

    this FAQ page is by the inventor of C++:

    http://www.research.att.com/~bs/bs_faq.html
     
    firesexwater, Oct 18, 2007 IP
  8. Forrest

    Forrest Peon

    Messages:
    500
    Likes Received:
    25
    Best Answers:
    0
    Trophy Points:
    0
    #8
    C++ is C with a few added concepts, but it's pretty different.
     
    Forrest, Oct 18, 2007 IP
  9. Bronto

    Bronto Peon

    Messages:
    308
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    0
    #9
    You can use pointer in C++ but not in Java.
     
    Bronto, Oct 19, 2007 IP
  10. Barti1987

    Barti1987 Well-Known Member

    Messages:
    2,703
    Likes Received:
    115
    Best Answers:
    0
    Trophy Points:
    185
    #10
    There is no such as better language. Each one has their own preferences.

    Peace,
     
    Barti1987, Oct 19, 2007 IP
  11. justinbezanson

    justinbezanson Peon

    Messages:
    160
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #11
    C# is better than Java :D
     
    justinbezanson, Nov 1, 2007 IP
  12. tonybogs

    tonybogs Peon

    Messages:
    462
    Likes Received:
    13
    Best Answers:
    0
    Trophy Points:
    0
    #12
    Well said.. If you want an OO language use a language designed as OO.
    C is very powerful but sucks for use as a OOP
     
    tonybogs, Nov 2, 2007 IP
  13. NesQuiK190

    NesQuiK190 Guest

    Messages:
    10
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #13

    That was hilarious... That was the reason for C++, because of "sphagetti code" which was present in C and thanks to OOP we don't have that...
     
    NesQuiK190, Nov 2, 2007 IP
  14. teraeon

    teraeon Peon

    Messages:
    40
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #14
    The newer languages (Java, C#) are *more* object oriented than C++ because basically you are only dealing with classes communicating and utilizing other classes... HOWEVER this was only possible because of C++, while it wasn't the first OOP language (Pascal preceded it), later in it's development it was utilized more and more like how Java and C# operate today.... which was actually what lead to the development of Java, and then later on C#.
     
    teraeon, Nov 3, 2007 IP