Use C or C++???

This is a discussion on Use C or C++??? within the Linux Programming forums, part of the Platform Specific Boards category; I'm trying to get into Linux more and I'd like to start programming for it. I have a decent background ...

  1. #1
    Registered User CompiledMonkey's Avatar
    Join Date
    Feb 2002
    Location
    Richmond, VA
    Posts
    438

    Use C or C++???

    I'm trying to get into Linux more and I'd like to start programming for it. I have a decent background in Linux but not so much in C or C++. What I'd like to build is a RSS reader to be used in the Linux console. I'm debating on which language I should use. I know Java really well, but I kinda want to learn something new. Also, I don't want Java to be a dependency for my users. Whatever I choose to use, the project will be open source, so anybody can check it out and modify it however they want.

  2. #2
    ZAK
    ZAK is offline
    Registered User
    Join Date
    May 2002
    Posts
    13
    In general both languages are used in Linux, if you want to do low level system style programming C will be the beast of choice if you want to just interface with already written libraries C++ is great. For a good introduction to Linux programming see this free book http://www.advancedlinuxprogramming.com/alp-folder I used it to help me learn the POSIX thread standard... but it has other good stuff as well...plus it's free to boot.
    "Computer Science is no more about computers than astronomy is about telescopes"
    - E.W. Dijkstra

  3. #3
    Registered User
    Join Date
    Dec 2003
    Posts
    50
    For Linux console apps, C is certainly a good choice. C++ is also okay.

  4. #4
    ZAK
    ZAK is offline
    Registered User
    Join Date
    May 2002
    Posts
    13
    C++ in some cases can get as low as C, however, object oriented design like C++ will cause a lot of unnecessary over head when writing low level routines...C has traditionally been the *nix language of choice for system level programming. C is considered by some to be a high level assembly language because of it ability to address hardware using some what more readable constructs.
    "Computer Science is no more about computers than astronomy is about telescopes"
    - E.W. Dijkstra

  5. #5
    ZAK
    ZAK is offline
    Registered User
    Join Date
    May 2002
    Posts
    13
    Ok, what happens when C++ is compiled is that all of those class will take up more memory and will compile to more code then when C is used the extra code is just overhead of enforcing the nature of the constructs that's all. It was a while ago when I study the over head problem and the speed gap is closing so it may be not as much of a concern. I can't really give you definitive metrics on the actual amount of overhead and how it affects current day...this is just how it was explained to me.
    "Computer Science is no more about computers than astronomy is about telescopes"
    - E.W. Dijkstra

  6. #6
    & the hat of GPL slaying Thantos's Avatar
    Join Date
    Sep 2001
    Posts
    5,681
    becasue i don't see the overhead. Could you explain where there overhead would be please?
    Can you see air? Just because you can't see something doesn't mean its not there

    Example
    Code:
    #include <stdio.h>
    
    int main(void) {
      printf("Hello World");
      return 0;
    }
    size when compiled with gcc: 4814
    size when compiled with g++: 5156

    After being strip-ed
    gcc: 3020
    g++: 3352

    Generally speaking c++ brings in a larger library and produces slightly larger code. If you are writing code that needs to be small then this becomes an issue.

  7. #7
    & the hat of GPL slaying Thantos's Avatar
    Join Date
    Sep 2001
    Posts
    5,681
    overhead has a lot of different meanings

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