Thread: C or C++

  1. #61
    spurious conceit MK27's Avatar
    Join Date
    Jul 2008
    Location
    segmentation fault
    Posts
    8,300
    Quote Originally Posted by sean View Post
    I think that makes it the perfect OS language. Using it for a user-friendly end-user app, however - is probably not the best choice
    Hmmm...what's the difference? The language does not affect the "user-friendliness". If you are comfy with the idea of writing an OS/kernel in C, "end-user apps" should be a snap...
    C programming resources:
    GNU C Function and Macro Index -- glibc reference manual
    The C Book -- nice online learner guide
    Current ISO draft standard
    CCAN -- new CPAN like open source library repository
    3 (different) GNU debugger tutorials: #1 -- #2 -- #3
    cpwiki -- our wiki on sourceforge

  2. #62
    Registered User
    Join Date
    Sep 2001
    Posts
    4,912
    Of all the people I've met who would feel comfortable writing an OS/kernel in C, I can't say that any of them struck as being a good interface designer! The difference I see is that in one you're basically writing an interface to control the hardware, and any advantage counts, where as in the other you'll probably err on the side of faster development, and you're more likely to take a much more OO approach and use a language that lends itself to such a purpose. Additionally, I sometimes find that the libraries you use affect the "style" and feel of your code just as much as the language you choose.

  3. #63
    spurious conceit MK27's Avatar
    Join Date
    Jul 2008
    Location
    segmentation fault
    Posts
    8,300
    Quote Originally Posted by sean View Post
    The difference I see is that in one you're basically writing an interface to control the hardware, and any advantage counts, where as in the other you'll probably err on the side of faster development, and you're more likely to take a much more OO approach and use a language that lends itself to such a purpose.
    Yeah, faster development (vs. "performance") I could see as a factor, if you mean opting for a much higher level oriented language. But I don't think using C will lead to an inferior interface, that is really up to you. An "OO approach" could just as easily lead to gimpy cookie-cutter style stuff.

    Additionally, I sometimes find that the libraries you use affect the "style" and feel of your code just as much as the language you choose.
    Probably, but if you are talking about, eg, GUI libraries, etc., most of those are available for multiple languages. The "style" of the library is a constraint, but that is independent of the language. Of course, C is a little shy on libraries like this, but I think most of the major ones (gtk, SDL, etc) are there.

    Recently I made an ncurses app for a site I work on, to make it easier for me and a few other people to accomplish certain routine tasks on the server. Ncurses is pretty much state-of-the-art when it comes to terminal apps -- the work is done via ssh login, so no GUI. But I didn't use the C library, I used Curses::UI for perl, which is a OO library. Totally, the factor there is development time. And the perl library contains things like ready-made widgets that are not part of the base C library. However, I believe there is a parallel Curses "user interface" lib for C.

    I think I would have ended up with the same thing either way. Possibly, the C version might have been slightly better because I would have had to make a text editor widget myself, to my own specs. As is, the ready-made one is fine, but it is not EXACTLY what I would have done, if I had to do it myself.

    Also worth note: virtually the entire GNU OS (aka linux) including the GUI front ends are in C (they also like python). Linux is I guess not traditionally known for user friendliness, but really there is nothing wrong with most of the individual apps...
    Last edited by MK27; 11-12-2009 at 10:00 AM.
    C programming resources:
    GNU C Function and Macro Index -- glibc reference manual
    The C Book -- nice online learner guide
    Current ISO draft standard
    CCAN -- new CPAN like open source library repository
    3 (different) GNU debugger tutorials: #1 -- #2 -- #3
    cpwiki -- our wiki on sourceforge

  4. #64
    Registered User
    Join Date
    Sep 2001
    Posts
    4,912
    But I don't think using C will lead to an inferior interface, that is really up to you. An "OO approach" could just as easily lead to gimpy cookie-cutter style stuff.
    Yeah - I agree with that. You definitely can make an excellent interface in C, and I generally like the more linux-y interfaces - but that's because I choose functionality and keyboard usage over animations and effects any day. I'm just saying that if your primary purpose if making a nice interface to a typical program, C probably wouldn't be your first choice unless your were already intimately familiar with it - like most of the GNU folks, I'm sure!

  5. #65
    Registered User
    Join Date
    Aug 2008
    Location
    Croatia
    Posts
    36
    C || C++?

    I guess it really depends on how far you want to go with programming.
    If you want to learn computer science, C is by far better choice. Mostly because it's so transparent, easy to translate to machine code in your head (some call it "portable assembly").
    Also its strong relationship with Unix and Unix-like systems....all the code, manuals are written in C...so if you want to study OS....C is the way. Then there's just a large amount of code out there written in C..it's syntax is practically used as pseudo code in many books, tuts...
    Also, it makes so much more sense to learn procedural programming before any higher level, OO language.
    I started with C++, then realized that I don't understand what it does...sure I wrote some Hello World programs, but was not sure how it worked. Then bought KNR, moved on Unix platform and my knowledge began to grow rapidly.
    C is the culture.

    C++ and others are practical need to write less code faster. More acceptable for bigger applications, programs where efficiency is not that important, easier to understand and maintain....really great languages. And if you don't care about the "black box" and you just want to see the window floating on the desktop or you only care about solving practical problems...C is not the best choice.

    There...I hope I made a choice a bit easier.

  6. #66
    Registered User
    Join Date
    Aug 2008
    Location
    Croatia
    Posts
    36
    Quote Originally Posted by sean View Post
    I was just reminded of my all-time favorite Linus Torvalds quote:

    I really like that - because it's exactly what I like about C. A good C programmer ought to be able to look at any construct and have a good idea how that command would be represented in Assembly - and yet you can combine those constructs into a higher-level programming style. I think that makes it the perfect OS language. Using it for a user-friendly end-user app, however - is probably not the best choice - but one that I think everyone should at least be able to understand.
    I completely agree with Linus here.
    Like I wrote in the post before....if you did some assembly before, C seems like an "upgraded" ASM.
    If ASM codes are 1:1 related to machine codes, then C is like 1.5:1.

  7. #67
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Location
    Inside my computer
    Posts
    24,654
    Mind you, C++ does not sacrifice efficiency. It is even more efficient than C at times. Otherwise you bring up good points.
    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. #68
    Malum in se abachler's Avatar
    Join Date
    Apr 2007
    Posts
    3,195
    Quote Originally Posted by dotunix View Post
    C || C++?
    Actually I prefer C | C++

Popular pages Recent additions subscribe to a feed