Thread: Advantages of using C first?

  1. #16
    "Why use dynamic memory?"
    Join Date
    Aug 2006
    Posts
    186
    it seems that C started it all. For me, i started C++ first.

    But is there a difference really ?

    To me, as a simple programmer, C++ is just C with OOP, i do not like to be very technica.

    So learning C++, in my 'untechnical' opinion is learning C.

    I only use the term C to refer to the first language created by Ritchie. When I say C++, i simply mean new C with OOP power
    "C makes it easy to shoot yourself in the foot; C++ makes it harder, but when you do, it blows away your whole leg."-Bjarne Stroustrup
    Nearing the end of finishing my 2D card game! I have to work on its 'manifesto' though <_<

  2. #17
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Location
    Inside my computer
    Posts
    24,654
    You will little way if you merely use C with classes. C++ is an entirely different language on its own.
    I suggest that you learn C++ before C, mostly to get used to C++ way of thinking. C++ has a lot to offer, ranging from lots of algorithms to generics, classes and RAII. Don't be another C with classes user. There are zillions of them already. We want more real C++ programmers.

    Learning C is an "essential" part of learning C++ because a lot of stuff, usually that deals with implementing containers, deal with these low parts. So it is part of it, but it should be learned as a part of the course and certainly not first.
    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.

  3. #18
    Software engineer
    Join Date
    Aug 2005
    Location
    Oregon
    Posts
    283
    It's still going I'm okay with studying C++. I like this book because it teaches where C ends and C++ begins, and the chapters progress towards C++. It's been a while so it's refreshing.

    Didn't Bjarne say C++ was originally C with Classes? It feels that way. Hard to say it's something else after he started designing it. Visual Basic tried to improve over time adding OOP hooks but it has a legacy it's still trying to move away from. As Visual Basic.NET has "Option Strict On" and "Option Explicit On" options, C++ developers constantly use C libraries that are not OOP, making their project always C with their own classes and whatever C++ might provide in the non-oop std namespace: std::min(), std::max(), etc.

    Don't remember where but I remember reading something from him saying C++ is a multi-paradigm language. I do think he's stressing OOP because that's where his market is, which is fine. I guess my point is you can never be a real C++ programmer if you're always using C libraries etc. I don't think anyone would have time to abstract everything. But still, OOP is good if the project benefits from it. Not all do.
    Last edited by dxfoo; 03-26-2010 at 12:39 PM.

  4. #19
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    28,413
    Quote Originally Posted by dxfoo
    Didn't Bjarne say C++ was originally C with Classes? It feels that way. Hard to say it's something else after he started designing it.
    Scott Meyers suggests that "the easiest way is to view C++ not as a single language but as a federation of related languages. (...) there are only four". These four that he lists are:
    • C
    • Object-Oriented C++
    • Template C++
    • The STL

    Of course, this is a rather simplified view, since the members of this "federation of related languages" can be further subdivided and blend with each other in "multi-paradigm programming".
    Quote Originally Posted by Bjarne Stroustrup (2000-10-14)
    I get maybe two dozen requests for help with some sort of programming or design problem every day. Most have more sense than to send me hundreds of lines of code. If they do, I ask them to find the smallest example that exhibits the problem and send me that. Mostly, they then find the error themselves. "Finding the smallest program that demonstrates the error" is a powerful debugging tool.
    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  5. #20
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Location
    Inside my computer
    Posts
    24,654
    Quote Originally Posted by dxfoo View Post
    Didn't Bjarne say C++ was originally C with Classes? It feels that way. Hard to say it's something else after he started designing it. Visual Basic tried to improve over time adding OOP hooks but it has a legacy it's still trying to move away from. As Visual Basic.NET has "Option Strict On" and "Option Explicit On" options, C++ developers constantly use C libraries that are not OOP, making their project always C with their own classes and whatever C++ might provide in the non-oop std namespace: std::min(), std::max(), etc.
    Originally, yes, but it has evolved so much since then.
    Templates and RAII, for example, are certainly not just "C with some C++ touch". And designing in modern C++, what with classes, smart pointers, RAII, templates is certainly so much more different than C.
    So while C++ was C with classes once, it is such no longer, I would argue.
    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.

  6. #21
    Software engineer
    Join Date
    Aug 2005
    Location
    Oregon
    Posts
    283
    Do you mean RTTI instead of RAII, or are those two different things?

  7. #22
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Location
    Inside my computer
    Posts
    24,654
    Two verrrrrrrrrrrrrrry different things. RTTI is avoided; RAII is encouraged.
    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.

  8. #23
    Software engineer
    Join Date
    Aug 2005
    Location
    Oregon
    Posts
    283
    Gotcha... wikipedia knows all.

    I originally wanted to know the advantages of using C first instead of C++, but I guess it just really depended what I wanted to do with it. Each language has its own advantage depending on the project. Since I want to do game development, I see thers more advantage in using C++ more than strictly C, so I think my skills should be primarily focused on C++ than C, but being familiar with C enough to maintain, enhance, and convert into its object-oriented version. I bet there's a lot of Nintendo developers who use C still, for example. Nintendo is my long-term dream job, and I have no idea if it's in C or not given the developer history on the console. But I'm sure C++ is becoming more of the trend.

  9. #24
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Location
    Inside my computer
    Posts
    24,654
    Although I cannot say for sure, I would guess that it's probably C++. The simple reason is that C++ scales easier than C, and for big projects, scalability helps.
    C++ will probably be the dominant language in games for who knows how many years to come.
    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.

  10. #25
    (?<!re)tired Mario F.'s Avatar
    Join Date
    May 2006
    Location
    Ireland
    Posts
    8,446
    Quote Originally Posted by Elysia View Post
    RTTI is avoided; RAII is encouraged.
    Uh? RTTI is a feature of the language. What do you mean avoided?

    But yes. RTTI and RAII are two completely different things.
    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.

  11. #26
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Location
    Inside my computer
    Posts
    24,654
    Avoided as in discouraged.
    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.

  12. #27
    (?<!re)tired Mario F.'s Avatar
    Join Date
    May 2006
    Location
    Ireland
    Posts
    8,446
    RTTI is discouraged?
    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.

  13. #28
    Software engineer
    Join Date
    Aug 2005
    Location
    Oregon
    Posts
    283
    I know RTTI has a small performance issue but should be nil on today's compilers & machines.

  14. #29
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Location
    Inside my computer
    Posts
    24,654
    Yes, but unlike Java, C++ has a vast and powerful static type system: templates.
    It allows you to work with types without knowing the true type.
    That isn't to say that RTTI isn't used or shouldn't be used, but 99% of the times, it can be solved without it. Hence, it's discouraged, just as throwing an exception in a destructor is.
    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. #30
    Software engineer
    Join Date
    Aug 2005
    Location
    Oregon
    Posts
    283
    I think templates are used to not know the type initially, and RTTI is used to discover the type.

    An example from my book:

    Code:
    Mammal *ptr;
    
    for (int i = 0; i < 10; i++) { 
      ptr = factory();
    
    if (typeid(*ptr) == typeid(Puppy)) { // it's a puppy! }
    }
    Last edited by dxfoo; 03-26-2010 at 02:35 PM.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 1
    Last Post: 09-24-2009, 01:28 AM
  2. advantages of using IDE
    By surrounded in forum C Programming
    Replies: 8
    Last Post: 03-03-2009, 06:36 AM
  3. Advantages of using macro for BIT positions
    By donmorr in forum C Programming
    Replies: 8
    Last Post: 07-23-2008, 06:15 AM
  4. advantages of tile-based engine...
    By o0obruceleeo0o in forum Game Programming
    Replies: 25
    Last Post: 07-22-2003, 08:03 AM