Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Did I make the right choice?

  1. Apr 29, 2012 #1
    Hey everyone.

    I recently decided which language I wanted to start programming with, C, and I also bought a book for guidance/referece. https://www.amazon.com/gp/product/0672326663/ref=oh_details_o00_s00_i00

    I have never programmed before and after doing an extrenious amount of research I have concluded that C would be the best language to start with. Also that the book would be the best to have bought for a guidance/reference.

    I was wondering if I had made the right choice on starting out with C and buying that book.

    Thanks in advance!
  2. jcsd
  3. Apr 30, 2012 #2
    The book looks okay from what amazon allows to skim through and C is definitely a good language to know. Note though, that when you're learning C, you will need to know more about the internal details than you would in, say Java. It can be a pain, unless you enjoy it.
  4. Apr 30, 2012 #3
    I'm not too worried wether or not its a pain. I've done a little with Python and I've found that I really enjoy programming.

    Once I become really good with C what would I be capable of doing? As in how will it benefit me and what exactly is the point of doing it?
  5. Apr 30, 2012 #4
    You can do ANYTHING with C, and from my limited experience (I'm still at uni), learning C makes learning everything else easier. It's close to the metal, if you are processing a string you will know about every character in that sucker, you'll terminate it yourself and you'll manually allocate and free the memory it uses. I like to think you learn some good practises coding in C. Good luck!

    If you get stuck for something interesting to code, look up Project Euler, or do some text processing (encryption, HTML parsing, compression). Graphics is fun too, but you'll need to learn some extra libraries for that (OpenGL or something).
  6. Apr 30, 2012 #5


    User Avatar
    Science Advisor

    Not quite everything unless you include inline assembler or link to libraries that have assembler routines like communicating with I/O directly.

    It's close enough though for bare metal since only with the exception of device drivers, super-optimized routines for particular chipset types or extensions, it's good enough for the kind of micromanagement required for fast software and with a good compiler, nowadays the results are good enough performance-wise.
  7. Apr 30, 2012 #6
    The only problem with C is that it teaches "bad habits" in the world of Object-oriented programming.
  8. Apr 30, 2012 #7
    Object-oriented programming? Could you please explain what you mean.
  9. Apr 30, 2012 #8
    Wait. Didn't you just say you had done a lot of research and concluded that C would be the best language to start with? I think, my friend, that your research might have been somewhat incomplete.

    Also, Google is your friend.
  10. Apr 30, 2012 #9
    Depends on what you want to do.

    C is closer to the metal, yadda yadda, but you lose some functionality and don't gain much over the equally fast but object oriented c++. Before anyone corrects me by saying c is more basic and therefore faster than c++, remember that c++ is so popular, and a lot of money and effort has gone into optimizing it, while c optimization has been pretty stagnant.

    To answer your question about object oriented programming, or OOP, first of all c is procedural i guess, and c++ is OOP. In C++ you can create a class, say a triangle class, and create different instances of triangle. These are all part of the triangle class, but operations on triangle_1 don't effect triangle_2 don't effect..... The class also defines methods or operations you can do on the triangles, like if you wanted to stretch triangle_4, or access what the base of triangle_6 is or whatever. You're modifiyng and accessing "instance variables" of the different "instances" of the "class". Each triangle is an instance of the triangle class.

    Basically OOP creates a more pretty way to keep track of many "objects", and their seperate instance variables. Otherwise you might have to do some ugly multidimmensional arrays or something, but those have there purpose, don't get me wrong.

    Most video games are written in c++ btw.

    If I'm trying to throw together a quick program, python is still great for simple scripts, to even modeling, and it's really easy.

    If I was writing an intense physics engine with 3d visualization, I'd pick c++.

    If I was writing code for a microcontroller, I'd probably use C.
  11. Apr 30, 2012 #10
    All that said, you can do anything with C :) It's just a matter (how long it takes to program) vs (how important is performance) for a task by task basis. You can't go wrong with learning C
  12. May 1, 2012 #11


    User Avatar
    Homework Helper

    C++ is an extension of C. Object oriented programs have been written in C, and procedural programs in C++. Even in the case of OOP, member functions of an object end up being procedural, so the innermost code of most well designed programs doesn't end up that much different.

    Unless you plan to be a programmer, or your studies or a future job involves programming, I'm not sure what the point is, but the same applies to a lot of subjects you learn in school, some of which are more for academic purposes as opposed to having a practical purpose.

    You didn't mention what your plans are that might involve programming.

    There's no reason that C can't be the first programming language you learn. If your studies or a future job involves programming you should find out what language is being used and perhaps start with that language, or switching to that language after spending enough time with C to get an idea of how to write programs.
  13. May 1, 2012 #12

    This may sound a little far-fetched, but I've heard from a couple of peolpe that you can do something with physics equations that involves programming? I'm not completely sure, but I found myself to be interested in what they were telling me so I decided I would give it a shot. I'm really interested in physics and by the time I start my physics course next year I was hoping I would be pretty good at programming. I am studying physics this summer, so no rush. I just think that it would be really cool, and why not persue my interest?
    Last edited by a moderator: May 1, 2012
  14. May 1, 2012 #13


    User Avatar
    Homework Helper

    For physics or engineering, you might find a very high level language like Matlab, which is more of a mathematical tool than a programming language, to be useful. There's no reason you couldn't learn both C and Matlab.
  15. May 1, 2012 #14
    Oh ok, thanks.

    I've been so lost on deciding which language to learn first. Everyone tells me something different... I will probably learn C then Matlab.

    Thanks for the help!
  16. May 3, 2012 #15
    Python has some nifty Matlab modules.
  17. May 3, 2012 #16
    Since you mentioned you were in it mostly because it'd be useful in physics, I recommend staying away from C. Matlab is a good choice, but I would still recommend (as I do to practically all beginners) to learn Python. It's a real programming language (somewhat unlike Matlab), and it's powerful yet easy (unlike C, which requires you to do all the nasty memory allocations by hand).

    This is not to say that you should never learn C or Matlab (you will most likely learn the latter in college anyway), but *starting* with Python is highly recommended.
  18. May 3, 2012 #17
    Too late, the book just arived. And I'm really interested in C, and I've done a little of Python. Would you reccomend learning C, then Python, then Matlab?
  19. May 3, 2012 #18
    No. I'd go for Python (which can easily be learned by using tutorials on the internet), then C (since you already bought the book), then Matlab (since Matlab is awesome).
  20. May 5, 2012 #19
    Alright, how long do you think it would take me to learn Python and C pretty thoroughly if I spent about an hour aday 7 days a week?
  21. May 5, 2012 #20


    User Avatar
    Science Advisor

    It depends on what you call thorough.

    One thing that you should keep in mind is that a lot of what is learned in programming has to do with debugging code and this takes a long time to do when you start off. As you get better though, the time needed will decrease though, but you will be working with larger repositories which means the problems get more complicated.

    I think you will need at least a few years minimum for this amount, probably a lot more. Again it depends on how thorough you want to be.

    You could probably learn the actual language components a lot quicker, but if you want a thorough understanding you will have to apply your programming to a number of different situations and applications to reinforce it all.

    Don't be discouraged though because you'll find that even if you have been doing stuff for a while (like say ten years), there is always stuff you don't know and that's a good thing IMO.
Know someone interested in this topic? Share this thread via Reddit, Google+, Twitter, or Facebook