Thread: Why learn C?

  1. #1
    The Earth is not flat. Clyde's Avatar
    Join Date
    Mar 2002
    Posts
    1,403

    Why learn C?

    I'm in the process of learning C.. but i'm tempted to drop it entirely and concentrate on C++.

    Is there any reason to stick with C, I mean there must be right? Otherwise no-one would use it anymore.

    From what i've read, when you get into windows programming C++ is pretty much a must, so I was planning on swapping over to C++ once i had got a firm grasp of C. (though at this point i'm not terribly sure what a "firm grasp" actually entails)

    But as far as I can make out the only differences are slightly different commands (Cin/Cout instead of scanf/printf, etc.) and the class system. If thats the case I figure i'm better off forgetting straight C and going to C++.

    Advice?

  2. #2
    left crog... back when? incognito's Avatar
    Join Date
    Oct 2001
    Posts
    1,427
    From what i've read, when you get into windows programming C++ is pretty much a must, so I was planning on swapping over to C++ once i had got a firm grasp of C. (though at this point i'm not terribly sure what a "firm grasp" actually entails)

    Well from what I hear Programming Windows is mostly C, and this book is one of the best if not the best book out there to learn Window Programming, I think in my opinion once you learn C++ you can look at a C book and pretty much learn the basics of C right away.
    There are some real morons in this world please do not become one of them, do not become a victim of moronitis. PROGRAMMING IS THE FUTURE...THE FUTURE IS NOW!!!!!!!!!

    "...The only real game I thank in the world is baseball..." --Babe Ruth

    "Life is beautiful"-Don Corleone right before he died.

    "The expert on anything was once a beginner" -Baseball poster I own.


    Left cprog on 1-3-2005. Don't know when I am coming back. Thanks to those who helped me over the years.

  3. #3
    Used Registerer jdinger's Avatar
    Join Date
    Feb 2002
    Posts
    1,065
    I program for Windows only (no console stuff) and all I've ever used is C++. Learning C first won't hurt you and it will probably make learning some of the basics of learning C++ a little easier.

    Personally, I'd just go with C++.

  4. #4
    The Earth is not flat. Clyde's Avatar
    Join Date
    Mar 2002
    Posts
    1,403
    Is there anything you can do in C that you can't do in C++?

    At the moment, i don't understand why ANYONE would EVER bother learning C.

    I mean if you can do everything that you can do in C with C++ and you also get classes, and (supposedly) easier notation, C seems... well a waste of time.

  5. #5
    ¡Amo fútbol!
    Join Date
    Dec 2001
    Posts
    2,138
    Supposedly C is a little faster. I have no experience though with this and cannot validate it.

  6. #6
    Registered User xlnk's Avatar
    Join Date
    Mar 2002
    Posts
    186
    in my opinion, once you have learned C++, you basically have learned C. The use the same basic concepts, accept for the OOP. C syntax is a slight different, but it wil do the same thing. I'm learning entirely in C++, and have no problem writing a program in C.

    Windows programming is basically C, but can be half 'n half with C++.
    the best things in life are simple.

  7. #7
    Registered User
    Join Date
    Aug 2001
    Location
    computers/ theatre, travelingstudentL>- Northern California NativeNorthern California3D&Tie-DyeStudent1>. Admirer of C Bangalore Net surfingTeacher >/ >0 nagpurteaching >1  >2
    Posts
    61
    C is a slight bit faster than C++ at the follwoing times:
    - allocation and de-allocation, C does not go through a constructor or destructor. If you allocate a structure in C and then call a function to do some initialization on it, then you are doing the same as a constructor, just with out one level on the call stack.
    - during method calls if they are nested deeply, on a multi-CPU machine, this can cause the process to be assigned to a different processor which can cause a performance degredation to load the registars.

    The speed will make no difference unless you are doing real-time programming and then only if the hardware can not go fast enough. Remember any one can write slow code in C or C++, if speed is a necessity, then make sure your algorithms are efficient and if using C++, check the efficiency of you method calls and how deep the call stack gets during each one, that is one of the easiest ways to pick up speed.

    The primary project I have been working on is done in C on a six CPU Silicon Graphics machine. We are still finding ways to make the code run faster so that the program can do more and still be real-time.

  8. #8
    _B-L-U-E_ Betazep's Avatar
    Join Date
    Aug 2001
    Posts
    1,412
    Learn C if you want to get chicks.

    j/k

    ***Ducks the plates thrown by Prelude, Penny, and CG***

    ***Hides behind -KEN-****
    Last edited by Betazep; 04-03-2002 at 07:46 PM.
    Blue

  9. #9
    Code Goddess Prelude's Avatar
    Join Date
    Sep 2001
    Posts
    9,897
    >At the moment, i don't understand why ANYONE would EVER bother learning C.
    Well, a goodly portion of programming is maintaining older code. Since virtually the entire world is programmed in C, you would do well to know how it works. All features aside, C and C++ are two different languages with similar syntax is some aspects and completely different functionality in others. Treat C and C++ with the same objectivity you would with COBOL and Java. The more languages you know, the more useful you are to companies, it's just that simple.

    >***Ducks the plates thrown by Prelude, Penny, and CG***
    No no no, plates are far too expensive these days to be throwing around.

    -Prelude
    My best code is written with the delete key.

  10. #10
    _B-L-U-E_ Betazep's Avatar
    Join Date
    Aug 2001
    Posts
    1,412
    >>>No no no, plates are far too expensive these days to be throwing around.


    Shaaa.... not if they are the rubber variety!
    Blue

  11. #11
    The Earth is not flat. Clyde's Avatar
    Join Date
    Mar 2002
    Posts
    1,403
    Thanks for the advice people

    I think i'll swap over to C++, I'm currently reading K&R and i'll finish it, but i'm going to try and get used to using the C++ notation.

  12. #12
    Registered User Strider's Avatar
    Join Date
    Aug 2001
    Posts
    149
    Don't forget the laziness factor, better known as Source Lines of Code(SLOC) per Function Point. Here is a good site for comparing SLOC between the various languages:

    http://www.softwareestimator.com/IndustryData1.htm

    David
    One Ring to rule them all, One Ring to find them,
    One Ring to bring them all and in the darkness bind them
    In the Land of Mordor where the Shadows lie.

  13. #13
    Registered User geekfrog's Avatar
    Join Date
    Apr 2002
    Posts
    14
    a book i read said that it was actually harmful to learn c before c++.
    ----------------------------------------
    I'm using Borland C++ compiler v5.5

  14. #14
    Code Goddess Prelude's Avatar
    Join Date
    Sep 2001
    Posts
    9,897
    >a book i read said that it was actually harmful to learn c before c++.
    Only if you don't understand that the two are different languages. People who say that are just stupid or don't understand things as well as they would like us to believe.

    -Prelude
    My best code is written with the delete key.

  15. #15
    Meow Pendragon's Avatar
    Join Date
    Sep 2001
    Location
    Swindon, UK
    Posts
    723
    a book i read said that it was actually harmful to learn c before c++.
    Yes, I've heard that one too... in a C++ book no less.
    The gist of it was that if you learn C before C++ then you have to get out of the 'bad habits' that you learned in C.

    The 'bad habits' I take as being the procedural design style of C when faced with OO in C++. It seems to be a common myth that one needs an OO language to implement an OO design (I've got to admit, when put like that it does seem to make at least some sense!) and, although languages such as C++ and Smalltalk provide many features that encourage this style of design, one can benefit equally well from the use of objects in imperative languages such as C.

    C perhaps isn't as bad as some authors make it out to be. Although there are obvious advantages to using an OO language to implement an OO design (memory allocation etc) it's not impossible to implement this design style in a procedural language.

    Here's where I get around to saying that my first language was C++ and not C though I have little trouble with writing in C...
    ...and although learning C first will help you get to grips with the basics of C++ that's where the similarities end in my opinion.

    Pendragon
    Last edited by Pendragon; 04-04-2002 at 04:26 PM.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Am I too late to learn programming?
    By maccat in forum A Brief History of Cprogramming.com
    Replies: 17
    Last Post: 02-17-2009, 08:49 AM
  2. Looking to learn C++
    By Fuzzy91 in forum C++ Programming
    Replies: 40
    Last Post: 04-13-2006, 02:38 AM
  3. Can you actually learn c++ in 21 days?
    By Raeliean in forum C++ Programming
    Replies: 14
    Last Post: 07-27-2005, 03:41 PM
  4. You have to learn C in order to learn C++
    By gandalf_bar in forum A Brief History of Cprogramming.com
    Replies: 20
    Last Post: 07-16-2004, 10:33 AM
  5. Witch to learn first?
    By Unregistered in forum Windows Programming
    Replies: 2
    Last Post: 06-17-2002, 12:06 AM