C or C++

This is a discussion on C or C++ within the Linux Programming forums, part of the Platform Specific Boards category; Hmm here is the time and time again asked question. Which do you prefer. I'm starting to get into Linux ...

  1. #1
    ___
    Join Date
    Jun 2003
    Posts
    806

    C or C++

    Hmm here is the time and time again asked question. Which do you prefer. I'm starting to get into Linux programming and away from the whole Windows scene and I have heard on a lot of forums that C is the way to go in Linux. What's your uptake on that?
    "When I die I want to pass peacefully in my sleep like my grandfather did, not screaming and yelling like the passengers in his car."

  2. #2
    twm
    twm is offline
    root
    Join Date
    Sep 2003
    Posts
    232
    I really don't bother much with C++, the language as a whole seems too bloated and awkward. C is much cleaner in my opinion.
    The information given in this message is known to work on FreeBSD 4.8 STABLE.
    *The above statement is false if I was too lazy to test it.*
    Please take note that I am not a technical writer, nor do I care to become one.
    If someone finds a mistake, gleaming error or typo, do me a favor...bite me.
    Don't assume that I'm ever entirely serious or entirely joking.

  3. #3
    Registered User
    Join Date
    Oct 2002
    Posts
    21
    Although all of my programs thus far have been in C, I am learning C++ at the moment and I'm quite impressed. It's a bit of a bloated monstrosity compared to C, but very powerful.

    I really do like the OOP approach, so I can see myself going the way of C++ in the future. Since C++ is a superset of C, you really have the best of both worlds.

    In my opinion, if you are deciding between C and C++, unless you are planning on kernel hacking or the like, I see no reason to not go with C++.

    ~arker

  4. #4
    Registered User
    Join Date
    Aug 2002
    Posts
    351
    C for unix system programming.

    C++ for larger-scale more conventional software development.

  5. #5
    still a n00b Jaguar's Avatar
    Join Date
    Jun 2002
    Posts
    187
    POSIX interfaces with C not C++.
    My opinion C is more than enough and very straight forward.

    But C++ is more suitable for large projects.
    slackware 10.0; kernel 2.6.7
    gcc 3.4.0; glibc 2.3.2; vim editor
    migrating to freebsd 5.4

  6. #6
    template<typename T> threahdead's Avatar
    Join Date
    Sep 2002
    Posts
    214
    i prefer C.

  7. #7
    Rez
    Rez is offline
    Registered User
    Join Date
    Nov 2002
    Posts
    82
    C is too conventional. C++ is a whole lot more versatile. C++ classes provide more comprehensive Abstract Data Type management schemes. It enables you to see the connections between aggregated data and the functions for manipulating them. One look at the class container and you can immediately see its overall capability.

  8. #8
    Registered User whistlenm1's Avatar
    Join Date
    Jan 2002
    Posts
    124
    I prefer C, at the very least experimenting with C++ for resume. As the old adage goes "Use what is best suited for the job!"
    Man's mind once streched by a new idea, never regains its original dimensions
    - Oliver Wendell Holmes

    In other words, if you teach your cat to bark (output) and eat dog food (input) that doesn't make him a dog. It would have to chase cars, chew bones, and have puppies before I'd call it Rover ;-)
    - WaltP

  9. #9
    ___
    Join Date
    Jun 2003
    Posts
    806
    I dont plan on doing large programs so I guess I'll go with C
    "When I die I want to pass peacefully in my sleep like my grandfather did, not screaming and yelling like the passengers in his car."

  10. #10
    Registered User
    Join Date
    May 2002
    Posts
    132
    Overall I prefer C, even for larger projects. I have been in contests with my friends over this very topic and I am able to program the same software in just as little time as he was able to do it with C++. C is very straightforward and just as effective, if not more.

    Mind you C++ does have the power behind it, but to me it's way to bloated to be as powerful as it could be. If it was more straight forward then I probably would switch over, but until that happens... which I highly doubt it ever will... then I'm going to stick with C. If companies don't want to hire me because I'm "outdated" or something along those lines, then $$$$ em

  11. #11
    Registered User
    Join Date
    Nov 2002
    Posts
    126
    I usually prefer to code in C++ just because I like the object oriented approach. You may prefer to code in procedures instead of objects, in which case C might be the better choice. As far as C++ being bloated, there is a little more overhead in C++ programs, but it's nothing to get your undies in a twist about for the majority of programs. Plus, it's not like you have to code your project strictly with one or the other. The best thing about C/C++ is that they work really well together. A lot of times I write the interface stuff for my programs in C++, and for the real meat-and-potatoes speed demon functions I use C or even assembly if I'm up to it. One huge disadvantage for C++ is that it usually takes about 5 times longer to compile than C code does.

  12. #12
    Obsessed with C chrismiceli's Avatar
    Join Date
    Jan 2003
    Posts
    501
    I usually (well always) like to program in c, it is more straightforward, and the Linux kernel was written in C. So when I do all my kernel hacking and device driver writing, I need to use C.
    Help populate a c/c++ help irc channel
    server: irc://irc.efnet.net
    channel: #c

  13. #13
    .
    Join Date
    Nov 2003
    Posts
    307
    The language you choose/use should be related to the task at hand. Not which one you 'like'. (like = knows_well) && (like != best_choice)

    There is a spectrum of language implemenatation levels.
    At the bottom is ASM. Since quite literally anything can be written is ASM you might think it's the best choice. Not necessarily.
    It is hard to debug, and hard to read. Productivity is VERY low using ASM.

    In the middle are interpreted languages like Python and Perl, and shell script.

    Near the other end of the spectrum are scripting languages or database languages like SQL, that sit on top of virtual machines.
    (A database engine is a virtual machine, it's where the idea came from) One line of code can execute 100,000 of lines of ASM.

    You ought to pick the one that does what you need and gives you the best productivity and is the most maintainable. If you plan to stick with only one (a big mistake longterm), consider C++.

    For maintenance coding (like kernel changes) you have to use what the guy before you used. You really should not consider anything else in this case. For all-new development, go for the most productive tool.

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