Thread: whats best c or c++

  1. #1
    Registered User the bassinvader's Avatar
    Join Date
    Jul 2006
    Location
    Europe
    Posts
    51

    whats best c or c++

    Hi all!!

    real simple question from someone who wants to be as clever as all of you!

    I'm a month into learning c but i'm beginning to wonder if i should learn c or c++. I'm looking for a future in IT and programming if i can, so which is best?
    Is c old hat or is it the equal of c++.
    whats the difference between them?

  2. #2
    Supermassive black hole cboard_member's Avatar
    Join Date
    Jul 2005
    Posts
    1,709
    I wouldn't call C old hat. For me, C is a release - C++ has been getting on my nerves recently.

    You could have (should have?) googled for this - would've been quicker than waiting for an answer from here (not that I answered the question).
    Good class architecture is not like a Swiss Army Knife; it should be more like a well balanced throwing knife.

    - Mike McShaffry

  3. #3
    Fear the Reaper...
    Join Date
    Aug 2005
    Location
    Toronto, Ontario, Canada
    Posts
    625
    I don't know whether or not there IS a correct answer to that question...
    Teacher: "You connect with Internet Explorer, but what is your browser? You know, Yahoo, Webcrawler...?" It's great to see the educational system moving in the right direction

  4. #4
    Lurking whiteflags's Avatar
    Join Date
    Apr 2006
    Location
    United States
    Posts
    9,613
    Not that this thread hasn't happened before.

  5. #5
    Registered User the bassinvader's Avatar
    Join Date
    Jul 2006
    Location
    Europe
    Posts
    51
    sorry guys!!!

    dont mean to be annoying but i dont know why there are different types of c.

    what are the advantages of one over another?
    are there any?
    is it better to learn c before taking an interest in c++?

  6. #6
    Registered User
    Join Date
    May 2006
    Location
    uk
    Posts
    14
    when i started C++ i found it more easy becuase i am well advance with javascript and in some strange way C ++ to me is a bit like js

  7. #7
    Registered User
    Join Date
    Aug 2005
    Posts
    44
    There used to be different types of C, and then the language was standardized to ANCI spec. Most C compilers are not up to the latest ANCI version, some of the improvements of this version are thought by some to be unnesecary.

    As to whether you should learn C or C++, you should first understand the differences between the two, namely, understand OOP. OOP provides features to encapsulate code to make it more modular and extensible, thats all it does. Leaving out the OOP in C++ youre left with a language almost the same as C, but with more safeguards and better type checking. Some would say the permisive syntax in C gives better leeway to a programmer who knows what he/shes doing. In the end, the OO features cost a bit in overhead, which is why speed critical code is still done in C. But you have to be honest with yourself, as a beginner these differences in speed are not going to be an issue, so really, in my opinion, your choice of first language should be what teaches you the most. If you are a self learner, I recommend Java. Java has all the OOP features of C++, but leaves out all the low level features that overwhelm a beginner. After Java then learn C to learn the low level features. Then you will know C++ automatically because Java and C have everything C++ has.
    Last edited by shintaro; 07-02-2006 at 09:33 PM.

  8. #8
    int x = *((int *) NULL); Cactus_Hugger's Avatar
    Join Date
    Jul 2003
    Location
    Banks of the River Styx
    Posts
    902
    "ANSI".

    Holy wars have been started over this subject. I personally like the OOP aspects (classes) of C++, but if I can fall back to C, I will. (Usually for simple/small projects.) C++ isn't always available if you come across some exotic platform. (Which I have... but it was all fun.) Pick whatever language will best suit the project, in terms of speed (running the app), speed (developing the app), cost, availability, knowledge of others that might work with you, etc.

    Haven't yet been able to stomach Java. Ironically, it was the first real programming I ever learned.
    Last edited by Cactus_Hugger; 07-02-2006 at 09:45 PM.
    long time; /* know C? */
    Unprecedented performance: Nothing ever ran this slow before.
    Any sufficiently advanced bug is indistinguishable from a feature.
    Real Programmers confuse Halloween and Christmas, because dec 25 == oct 31.
    The best way to accelerate an IBM is at 9.8 m/s/s.
    recursion (re - cur' - zhun) n. 1. (see recursion)

  9. #9
    The Richness... Richie T's Avatar
    Join Date
    Jan 2006
    Location
    Ireland
    Posts
    469
    Here's a few links you should see IMO:

    Bjarne Stroustrup's C++ page
    His FAQ
    This FAQ in particular

    Now for my own opinion (NOT FACT):

    >>I'm looking for a future in IT and programming if i can, so which
    >>is best?

    I would recommend C++ for the following reasons:

    1) Companies like C++ because it's a good alternative to java,
    code can be highly portable and it executes pretty fast - faster
    than java compiled to bytecode (technical stuff - not too
    significant if you don't know what I'm saying)

    2) Object orientated languages suit such business, but they have
    the feature of bulking up program size - C on the other hand is
    more basic - the array of features that C++ has over C is immense
    but if you were programming a microcontroller, manipulating raw
    data, and you need it done efficiently, then C is the way to go.

    They way I generally look at it is: Use C if you want really specific
    control of a system (the Linux kernel is written in C, as is the
    Windows kernel I think), but use C++ if you want to work on a
    project that requires a lot of versatility from the language you
    use.

    >>Is c old hat or is it the equal of c++.

    C is not the equal of C++ - although it is possible to reproduce
    OOP features in C, there is no point in my opinion when C++
    handles it much more easily. Similarly, there is no point in
    programming a washing machine using classes, inheritance,
    templates and all the other massive features C++ offers. My point
    is that the right programming language makes all the difference,
    and a lot of the time C still holds ground.

    Lastly, if you do want to go into programming as a career, you
    shouldn't limit yourself to choosing between C and C++, but
    rather learn both - and a few other languages while you're at it.
    Apparently java is easy enough to pick up if you come from a C++
    background, and in my experience, if you learn C well (and don't
    pick up bad habits), C++ is an easy step to make. As Stroustrup
    says, "Well written C tends to be legal C++ also"
    No No's:
    fflush (stdin); gets (); void main ();


    Goodies:
    Example of fgets (); The FAQ, C/C++ Reference


    My Gear:
    OS - Windows XP
    IDE - MS Visual C++ 2008 Express Edition


    ASCII stupid question, get a stupid ANSI

  10. #10
    (?<!re)tired Mario F.'s Avatar
    Join Date
    May 2006
    Location
    Ireland
    Posts
    8,446
    This thread should have had only one reply post and one answer: C++ is a better C, which doesn't necessarily mean C++ is better than C.
    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. #11
    Registered User the bassinvader's Avatar
    Join Date
    Jul 2006
    Location
    Europe
    Posts
    51
    thanks for all your answears guys!!!!

    it really is appreciated

  12. #12
    pwns nooblars
    Join Date
    Oct 2005
    Location
    Portland, Or
    Posts
    1,094
    Depending on where you end up in the IT field you wont even use C/C++. I am a programmer and use C++ for almost all my home projects, but at work I use Perl, PHP, Java, SQL and *SHUDDER* Jython. Focus on one of then languages, the language you understand best at the moment, then branch out to other languages... my C++ background helped me a lot in learning other languages, just as those other languages have made me understand some things in C++ better .

  13. #13

Popular pages Recent additions subscribe to a feed