Thread: For someone New to C should I learn C or C++ ?

  1. #16
    Registered User
    Join Date
    May 2010
    Posts
    62
    For what I know about programming learning VB is not the best thing to do before going on to C or C++. Mainly because of what VB allows you to do that is not allowed in C or C++ not to mention that as far as I know there are no aliases and pointers in VB, as well as that you will loose execution speed.

  2. #17
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Location
    Inside my computer
    Posts
    24,654
    Quote Originally Posted by cyberfish View Post
    For MCUs, I would stick with C.

    Some MCU development environments have some support for C++, but almost none supports the standard library, which is arguably 80% of what C++ is all about, and what makes C++ "nice".

    None of the standard containers will work (including std::string), for example, since MCUs don't typically have a heap to begin with (heap management doesn't make sense when you have <1KB RAM).

    With that kind of resources constraint, you don't really want C++ overheads anyways.

    I've never seen anyone doing OOP on MCUs. OOP is designed to make large programs easier to design/maintain, but has limited use when you just want to blink a few LEDs.

    This is all assuming you are talking about 8-bit/16-bit MCUs. If you are talking about bigger 32-bit MCUs like those ARM based ones... I've never actually programmed one, but people have run Linux on them, so I'm assuming they are more similar to PCs in terms of typical program complexity.
    While it's true that a lot of them are C, I would once again urge the OP to take a look at what kind of embedded controllers he/she wants to program for. Wouldn't it be a waste to learn C when the embedded controller fully supports C++?
    C++ isn't just all about OOP and the standard library either. It's also about type safety. Though I don't suppose most microcontrollers support templates.

    Quote Originally Posted by happyclown View Post
    I wanted to program, so I learnt C for 9 months. C is a beautiful language. I loved it. But I could only use it for console and text-based programs. What I really wanted was to be able to create GUI programs that I could use in Windows. So I switched to Visual Basic, and that was the best move I ever made, programming wise.

    I had learnt C on and off for about 20 years, but each time I was couldn't get past the usability hurdle. For people who require C as part of their job or studies, they have motivation to persist with it. I am only a hobby programmer, so unless I could program what I want, in the environment that I want(Windows), there was no motivation.

    Once I master VB, I will get back into C. It can do low level stuff easily, which is not so easy in VB.

    Good luck.
    First of all, C can indeed do Windows programming. Yes, it's difficult, but that's what you get for using such a low-level language.
    And secondly, since you obviously are targeting desktops and want to go with C, I'd instead recommend C++. There are nice frameworks out there that reduce the hurdle of Windows programming, as well.
    And, if you are unsure, again, the advice of trying both languages is not a bad advice at all.
    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. #18
    Registered User
    Join Date
    May 2010
    Posts
    10
    Thanks again to all for the advice and insight,

    At this point I need to do some homework.

    The arguement is strong to learn both, as I'm underestanding it:
    C for lower level stuff and C++ for higher level (graphics etc).


    Looks like two different tools related, but one is sutited better depending on the
    task you are doing, like a handsaw to cut trim or an electric saw to cut the studs.

    Yes both are semi-interchangable but depending on
    the task one really does suit better than the other.


    (maybe there is hope for this old dog )

  4. #19
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Location
    Inside my computer
    Posts
    24,654
    Yes, but C++ is a special case. It's backwards compatible with C, so even if you need to do low-level stuff, C++ is still relevant. What changes these languages is the type system and the availability. Not every platform has a C++ compiler, for example.
    Furthermore, C++ enhances C in every aspect by adding new features and improving on others, so basically it is C++, and extended version of C. So using C++ everywhere it is possible I would say is recommended. But then it's the issue of what people like. Do you like a strict type system? If so, then C++ is better than C. But if you don't like a strict type system, then C is more likely your pick of language.

    I hope you see the point.
    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. #20
    Registered User
    Join Date
    May 2010
    Posts
    10
    Quote Originally Posted by Elysia View Post
    ........

    I hope you see the point.


    Yes I think I'm starting to see the light


    Thank you

  6. #21
    spurious conceit MK27's Avatar
    Join Date
    Jul 2008
    Location
    segmentation fault
    Posts
    8,300
    Quote Originally Posted by Elysia View Post
    So using C++ everywhere it is possible I would say is recommended.
    As long as you can afford the additional mem usage, which is not insignificant.
    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

  7. #22
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Location
    Inside my computer
    Posts
    24,654
    It depends on how you use it. Naturally one must choose the approach that is appropriate for the goals.
    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. #23
    spurious conceit MK27's Avatar
    Join Date
    Jul 2008
    Location
    segmentation fault
    Posts
    8,300
    Quote Originally Posted by Elysia View Post
    It depends on how you use it. Naturally one must choose the approach that is appropriate for the goals.
    So probably more C, less ++.
    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

  9. #24
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Location
    Inside my computer
    Posts
    24,654
    If it meets your requirements, sure. But you would be loosing out on all the features that help coding and spanning up bigger systems. So it's a trade-off.
    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.

  10. #25
    Registered User
    Join Date
    Dec 2006
    Location
    Canada
    Posts
    3,229
    C++ isn't just all about OOP and the standard library either. It's also about type safety. Though I don't suppose most microcontrollers support templates.
    Templates could be supported, since it's a purely compile-time thing. However, for typical small (100-200 lines) programs for MCUs, templates don't make much sense, either.

    On the other hand, C is completely supported (except for parts of the standard library that don't make sense, like console I/O). Floating point types and arithmetic are usually supported but comes with HUGE memory, code space, and speed penalty (software emulation), so almost never used.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Quickly learn C# for a C++ expert
    By BigDaddyDrew in forum C# Programming
    Replies: 9
    Last Post: 06-06-2004, 04:38 PM
  2. The best place to learn
    By CougarElite in forum C Programming
    Replies: 15
    Last Post: 04-25-2004, 04:07 PM
  3. Novice trying to learn C++
    By dead in forum C++ Programming
    Replies: 10
    Last Post: 12-01-2003, 09:25 PM
  4. Witch to learn first?
    By Unregistered in forum Windows Programming
    Replies: 2
    Last Post: 06-17-2002, 12:06 AM
  5. Learn Win32 API or C++Builder?
    By Flucas in forum Windows Programming
    Replies: 1
    Last Post: 10-18-2001, 01:49 AM