Wanting to begin programming in general and for Linux.

This is a discussion on Wanting to begin programming in general and for Linux. within the Linux Programming forums, part of the Platform Specific Boards category; So, I'm new to programming. I'm not sure whether or not I should use C or C++. I used to ...

  1. #1
    Registered User
    Join Date
    Mar 2008
    Location
    PEI.Canada
    Posts
    3

    Wink Wanting to begin programming in general and for Linux.

    So, I'm new to programming. I'm not sure whether or not I should use C or C++. I used to know some C and found it... 'simpler' than C++.

    What is the best of the two?

    Anyway, I was thinking C because the Linux kernel is programmed with such.

    Also, I am currently running PC Linux OS (very cool, IMO ).

    Anyso, whatever advice you have will be much appreciated.

    Later. :3

  2. #2
    Captain Crash brewbuck's Avatar
    Join Date
    Mar 2007
    Location
    Portland, OR
    Posts
    7,159
    The problem with simple is that it's simple.

    C is simple to understand, but you also have to do practically everything "by hand." C++ is much harder to fully understand, but gives you more powerful tools.

  3. #3
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    You'll be needing a LOT of C knowledge before you can tackle the Linux kernel code.

    As stated, C is a lower level language, and many of the things that are easy to do in C++ becomes a whole lot harder in C. And to fully understand C++ you obviously should understand and know the basis of C too - as nearly everything you can do in C can be done in C++, which of course means that some people WILL do that.

    --
    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.

  4. #4
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,337
    What sort of programming interests you?
    Writing user applications or kernel / device driver work?

    Have you learnt how to program yet?


    The analogy is learning to drive vs. choosing your car.

    It's all very well buying a Ferrari, but without knowing how to use it, all you're going to do is wrap it round the nearest tree.
    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.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

  5. #5
    Registered User
    Join Date
    Mar 2008
    Location
    PEI.Canada
    Posts
    3

    Wink Well...

    I want to do application programming and game programming via OpenGL. I know the basics of C, and very, very little C++. Also, OS programming interests me, but yeah, I do need a lot more knowledge before I can tackle that.

    Anyway, what are some good books do you think are worth recommending?

    Also, which would be better for my needs, C or C++? I know I've asked it before, but now that you know what I wish to do, perhaps you could help me to decide.

    Anysuch, thanks again.

  6. #6
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,337
    http://www.rafb.net/efnet_cpp/books/
    Remember to separate learning the language (C++) from the APIs (say OpenGL).

    If I were starting today, I think I'd go with C++ first.
    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.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

  7. #7
    Registered User
    Join Date
    Mar 2008
    Location
    PEI.Canada
    Posts
    3
    Ok, C++ it be.

  8. #8
    Banned
    Join Date
    Nov 2007
    Posts
    678
    My first language was Java. Then I started doing C. And to my dismay, it lacked everything.
    Then I learned C++. Since they talked about Java being secure, and I was more interested in hacking
    (in my school days), and C++ allowed you system level access.

    Then came the myth buster:
    Java, C++ - Two books - Same number of pages
    I was done with Java book in say 2-3 months, was writing GUIs, networking code, applets, games etc.
    2-3 months later I was still confused about the basic syntax of C++. Let alone about learning an API to make C++ worth something practical.

    But I like your selection, your guts, your enthusiasm. Good luck with C++!

  9. #9
    Registered User
    Join Date
    Apr 2008
    Location
    USA
    Posts
    22

    Arrow

    C is an intermediate language which means that it resides somewhere between a true high level language (HLL) and assembly for the sake of this argument. C++ is the encapsulation of C functions into groups within libraries as they would apply to system objects and it is this wrapping of C that makes C++ a true HLL. C++ could compared to acting like a make file with linking instructions for managing the compilation of a C application's system code.

    The stepwise top down structure that basically presides over the systematic breakdown of C++ (atomic level) is as follows:

    1.) C++ [ high level language:encapsulates C ]
    2.) C [ Intermediate language: uppermost to assembly ]
    3.) Assembly [ True intermediate language:uppermost to binary ]
    4.) Binary [ Machine lingo in ones and zeros I/O:instruction sets ]

    C is what Unix was originally written in and BSD/Linux distros pretty much follow suit. C++ is the best choice out of C and C++ because you will inevitably learn C anyway while learning C++. Addressing C++ first will eliminate double work and suppress the confusion that allot of C developers encounter when trying to migrate to C++.

    An example of some of the confusion that exists between C and C++ could be summated with the following example:

    C's print to the console output is printf while in C++ it is std::cout. What's more confusing is the fact that you may use both printf and std::cout in the same method. The point that remains is that you would have to use/include the header files for both C and C++ in the pre-processor directives region of your file that contains the printf and std::cout function methods.

    To make a long nightmare short, get several books regarding:
    - general C++ programming
    - the standard template library for C++ (STL)
    - C++ Templates Design
    - the Boost Library.

    There will be around four to five thousand pages of reading in short order here, but it will be well worth the effort and extremely fascinating. OpenGL will simply fall into place after a good walk around the block with the previously mentioned subject matter under your hat.

    You will not regret the commitment.
    Last edited by TheRaven; 04-30-2008 at 03:37 AM.

  10. #10
    Registered User
    Join Date
    Apr 2008
    Posts
    890
    You're completely new to programming? Start with Python.

  11. #11
    Registered User
    Join Date
    Oct 2001
    Posts
    2,129
    I don't agree with the concept of "learning languages". If you want to learn C, learn C. If you want to learn C++, learn C++. If you want to learn assembly, Python, Pascal, or Perl, learn those. But don't learn something because you want to learn something else. That's silly.
    Last edited by robwhit; 05-01-2008 at 11:03 AM.

  12. #12
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    Also, I'd like to point out that languages is very small part of learning to program. Learning how to solve problems using a computer is much larger part of the learning experience. Once you know how to solve a problem in C, you can solve the same problem in Pascal, Fortran or Cobol by learning the language, but no matter how much you know the syntax and semantics of a language, if you don't know how the problem itself should be solved.

    A similar example would be to know exactly how a diesel engine works, and how you change wheels on a lorry (truck or whatever you like to call a big transport vehicle), but you haven't even got a driving license for a car - so you can do all the work to make the vehicle ready to drive, but you can't actually use it. [And remember, part of learning to drive is learning what is the right ways to do certain maneuvers in different situations, such that you comply with laws and customs of the country where you are driving, such as stopping at red lights (except in Italy ), overtaking on the correct side (except in certain US states), etc, etc].

    The process of learning how to write software is a much more difficult part than understanding the language.

    --
    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.

  13. #13
    Registered User
    Join Date
    Apr 2008
    Posts
    890
    Quote Originally Posted by robwhit View Post
    I don't agree with the concept of "learning languages". If you want to learn C, learn C. If you want to learn C++, learn C++. If you want to learn assembly, Python, Pascal, or Perl, learn those. But don't learn something because you want to learn something else. That's silly.
    Well, actually I'd recommend more CS background before jumping into any programming language. But I'd still recommend a scripting language without the nits of memory management, compile/link, etc, if someone wanted to learn basic programming.

    I'm not recommending learning Python to help learn C, I'm recommending it to help learn basic programming. Scope, flow of control, data structures, functions, classes, etc.
    Last edited by medievalelks; 05-01-2008 at 12:16 PM.

  14. #14
    CSharpener vart's Avatar
    Join Date
    Oct 2006
    Location
    Rishon LeZion, Israel
    Posts
    6,424
    But I'd still recommend a scripting language without the nits of memory management, compile/link, etc, if someone wanted to learn basic programming.
    Brrr... And someone continues to use this basic programming when switch to more fastidious language...

    as a result I need to support the C code where reading from file is done char by char into the temp buffer and calling strcat to append the read char to the destination buffer...

    [sarcasm]Thanks for such advices...[/sarcasm]
    The first 90% of a project takes 90% of the time,
    the last 10% takes the other 90% of the time.

  15. #15
    Registered User
    Join Date
    Oct 2001
    Posts
    2,129
    Quote Originally Posted by medievalelks View Post
    Well, actually I'd recommend more CS background before jumping into any programming language. But I'd still recommend a scripting language without the nits of memory management, compile/link, etc, if someone wanted to learn basic programming.
    What? That's what programming is all about!
    I'm not recommending learning Python to help learn C, I'm recommending it to help learn basic programming. Scope, flow of control, data structures, functions, classes, etc.
    If you only needed to learn the concepts, then the choice of language is completely irrelevant, since you'll never be needing to make a program after you learn how.
    Quote Originally Posted by vart View Post
    as a result I need to support the C code where reading from file is done char by char into the temp buffer and calling strcat to append the read char to the destination buffer...
    That made me laugh.

Page 1 of 2 12 LastLast
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