Thread: C vs C++ - No, not another war-thread

  1. #1
    Ex scientia vera
    Join Date
    Sep 2007
    Posts
    477

    C vs C++ - No, not another war-thread

    Yes, I know, this horse has been beaten to the brink of insanity, but here I am anyway. I've read some of the C vs. C++ threads I've found using search, but I have a question that's a bit too specific for those I've found.

    Here's the deal - When I started programming a few years ago, I used C++. However, I finally realized that I was just using the "C part" of it. I never really used classes, because back then, I didn't feel like delving deep into the language. Hell, I never even used vectors, which are one of the most handy features of the language.

    So I went to C, which also suited my needs a bit better to be honest. I was into exploit development, playing around with buffer overflows and the like locally and remotely on my other box on the network.
    I feel that my grasp on C is a firm one, perhaps not THE firmest one, but I can do what I need to do.

    However, as I started school, I finally saw the need to actually learn a language that I would be able to use as a professional programmer were I to become one(Which is the plan when I finish school). One aspect of that is to be able to develop GUI applications for the Windows platform and due to a lack of visual resource editors for C, I've not been able to stick with it, as coding every aspect of the GUI, manually entering coordinates for child windows in the parent windows and so on makes me mad.
    Am I just missing those editors? I've tried using Visual Studio Express, but it doesn't really seem to be 'compatible' with my C code - gives errors if I use arrays for typedef'd microsoft types which are really just character pointers.

    So, here's my question:

    - Is C still, well, able to compete on the market? If you use C, do you do so professionally, and if you do, what does the company you work for use it for - Is there a lot of work?

    - If you program in C, do you do a lot of GUI programming for the windows platform, and if you do, do you do it all manually or use some resource editor I've missed out on?


    All answers, tips and the like will be extremely welcome. Also, do not hesitate to beat me senseless if I'm just worried over something trivial.

  2. #2
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Location
    Inside my computer
    Posts
    24,654
    Yes, C is still used, but GUI programming becomes much easier with C++ due to classes. I believe you need to dig deeper into C++ instead because it really provides so much more than C and it's also more standards compliant than most C compilers (however, not even C++ is fully standards compliant, but that's beside the point).
    But I believe there are different markets for both languages. If you choose C, you will work with type X projects and if you do C++, you'll work with type Y projects.
    Last edited by Elysia; 01-30-2008 at 07:29 AM.
    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.

  3. #3
    Hurry Slowly vart's Avatar
    Join Date
    Oct 2006
    Location
    Rishon LeZion, Israel
    Posts
    6,788
    For GUI on Windows there is C# today...
    And for real work there is C.
    All problems in computer science can be solved by another level of indirection,
    except for the problem of too many layers of indirection.
    – David J. Wheeler

  4. #4
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Location
    Inside my computer
    Posts
    24,654
    You mean big, bloated, slow, retarded applications that are developed with C#.
    I'm sorry, but I'll stick to C++ and MFC.
    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.

  5. #5
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    I work for a company that develops an OS in C++ for the embedded market.

    We use C++, but I have yet to use std::vector in any of my work.

    We also use third party code (e.g. device drivers) that are developed in C.

    Linux & Windows kernels and many utilities on top of it is still using C.

    Many embedded OS's are written in C, and applications in the embedded space are a mix of C and C++.

    Graphical user interface functionality is often done in C++, for the very obvious reason that C++ is very good at "repeat and rinse" type things, meaning that there are an almost infinite number of "GUI objects" that all operate on a very similar principle of create, draw, interact, close. This matches object oriented programming fairly well.

    --
    Mats
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

  6. #6
    Ex scientia vera
    Join Date
    Sep 2007
    Posts
    477
    Hmm, maybe I shouldn't be obsessing over choosing one language or the other..

    I should rather be using one language for one task and the other for another task?

    Thanks for the advice. I think I'll continue learning C++ then.

    EDIT:

    Are there any visual resource editors similar to Visual Studio's one for C?
    Last edited by IceDane; 01-30-2008 at 08:53 AM.

  7. #7
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    I should also point out that I got this job (Senior Software Engineer) based on C skills [near zero C++ experience in professional use, and not very much from using C++ "as a hobby"], even tho' all work is essentially C++.

    If you have lots of knowledge of C, then you have probably already used C++ style solutions, at least in the form of function pointers inside structures and such things.

    --
    Mats
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

  8. #8
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Location
    Inside my computer
    Posts
    24,654
    Quote Originally Posted by IceDane View Post
    I should rather be using one language for one task and the other for another task?
    The thing is that once you know C, you know C++. You may not know all the fancy class stuff, but you can still do C++, and if you know C or low-level C++, then you do both types of works. Theoretically anyway.

    Are there any visual resource editors similar to Visual Studio's one for C?
    Go for C++ when it comes to GUIs. Win32 is a pain and Frameworks build (at least I believe so anyway) upon C++.
    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.

  9. #9
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    28,413
    We use C++, but I have yet to use std::vector in any of my work.
    Do you use custom container class templates instead, or avoid template code altogether?
    Quote Originally Posted by Bjarne Stroustrup (2000-10-14)
    I get maybe two dozen requests for help with some sort of programming or design problem every day. Most have more sense than to send me hundreds of lines of code. If they do, I ask them to find the smallest example that exhibits the problem and send me that. Mostly, they then find the error themselves. "Finding the smallest program that demonstrates the error" is a powerful debugging tool.
    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  10. #10
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    Quote Originally Posted by laserlight View Post
    Do you use custom container class templates instead, or avoid template code altogether?
    Yes, somewhere between those too - we have a number of container classes, but none of them do exactly replace std::vector - after all, it's an embedded OS, and applications aren't necessarily written in "standard C++" - there is nothing preventing the implementation of STL on top of the OS, just that:
    1. I work more "inside" the OS than outside it.
    2. There are other container types that are more appropriate for how the OS works.

    --
    Mats
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

  11. #11
    and the hat of sweating
    Join Date
    Aug 2007
    Location
    Toronto, ON
    Posts
    3,545
    Quote Originally Posted by Elysia View Post
    You mean big, bloated, slow, retarded applications that are developed with C#.
    I'm sorry, but I'll stick to C++ and MFC.
    Didn't you just contradict youself there?
    Last time I checked, MFC was big, bloated, slow & retarded.

  12. #12
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Location
    Inside my computer
    Posts
    24,654
    Not retarded nor big, bloated perhaps, but never retarded.
    And it is no way as slow as the big (20+ MB!), bloated, slow and retarded Dot Net Framework.
    MFC is fine for apps without sacrificing big performance.
    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.

  13. #13
    Malum in se abachler's Avatar
    Join Date
    Apr 2007
    Posts
    3,195
    Quote Originally Posted by IceDane View Post
    - Is C still, well, able to compete on the market? If you use C, do you do so professionally, and if you do, what does the company you work for use it for - Is there a lot of work?
    C is used quite frequently for microcontrollers, PLC's and drivers as well. It's not a dead language by any means.

  14. #14
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,659
    > Hmm, maybe I shouldn't be obsessing over choosing one language or the other.
    A good idea. Think like a carpenter and choose the best tool(s) for the job.

    A short answer would be "C++ when you can, C when you must".

    > I should rather be using one language for one task and the other for another task?
    It's what some large projects do, they use multiple languages.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  15. #15
    Code Goddess Prelude's Avatar
    Join Date
    Sep 2001
    Posts
    9,897
    >Is C still, well, able to compete on the market?
    It depends on the market. For areas where C excels, definitely. For areas where C isn't likely to be the best choice, probably not.

    >If you use C, do you do so professionally, and if you
    >do, what does the company you work for use it for
    I do use it professionally, often side by side with C++. I work for a company that develops compilers and programmer support libraries.

    >If you program in C, do you do a lot of GUI programming for the windows platform
    I personally don't work with graphics at all, and as far as I can tell, our GUI people use more productive tools for their interfaces.
    My best code is written with the delete key.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 72
    Last Post: 01-26-2009, 01:03 PM
  2. Terminating secondary thread from another thread
    By wssoh85 in forum C++ Programming
    Replies: 13
    Last Post: 12-19-2008, 05:14 AM
  3. Thread Prog in C language (seg fault)
    By kumars in forum C Programming
    Replies: 22
    Last Post: 10-09-2008, 01:17 PM
  4. Critical Sections, destroying
    By Hunter2 in forum Windows Programming
    Replies: 4
    Last Post: 09-02-2003, 10:36 PM
  5. Replies: 12
    Last Post: 05-17-2003, 05:58 AM