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

How do I start to learn programming?

  1. Apr 22, 2010 #1
    My high school does not offer computer programming, because we are a, ah, *small* high school.
    But I want to learn how to do it. I really want to go into programming, or CE.
    I read bits and pieces, learn a bit here and there, but I really want to actually learn how. So, where do I actually start? Where's a good place to start? I don't know if I would know it already or not, but can you give me some ideas?
  2. jcsd
  3. Apr 22, 2010 #2
    You could pick up an introductory book on Java, C, C++, Python or whatever other language you prefer (I recommend C++, but I'm biased because that's what I use for most of my research). I'm sure someone here can recommend you some good books.

    I learned most of my programming skills through trial and error, and through online tutorials. For C++, you could try http://www.cplusplus.com/doc/tutorial/", or just google "<language> tutorial", and you should find a few results.

    Whatever approach you follow, if you have any questions, you can always come back here and someone will be glad to help you.
    Last edited by a moderator: Apr 25, 2017
  4. Apr 23, 2010 #3
    if you want to learn C then i recommend "kernighan and ritchie" a fantastic book. C is used mainly by the "sciences" it is excellent for calculations ( root finding of functions, matrices, you name it), so it depends what you are looking to do with programming
  5. Apr 23, 2010 #4
    Awesome. Thanks. :)
  6. Apr 23, 2010 #5


    User Avatar
    Homework Helper

    Take a summer course (or two) at a local Community College.
  7. Apr 23, 2010 #6


    User Avatar
    Homework Helper

    K&R is more of a C language definition book than a learn how to program book. What you'd proably want instead is a "primer" for C. Better still would be a training book that starts off a minimalist C program, then goes through a series of programs, each one a bit more advanced and teaching one new aspect of programming at a time. You might consider an assembly primer as well.
  8. Apr 24, 2010 #7
    Well that didn't make a whole lot of sense.
    But I do think that starting with the how/why programming works with computers is a better way to go.
    But after that, I shouldn't learn C first? I always thought that's where everyone started. (Minus HTML and java. Everyone knows that.)
  9. Apr 24, 2010 #8
    I would recommend C or C++ for the exact reasons that Kajahtava is campaigning against them: In order to program well, you have to learn about how the computer works. Ask lots of questions on the forum here: if you see a couple of ways of doing something, try to find out which is better for your particular problem and why.

    If you're making a conscious effort to learn, as opposed to simply "getting the job done", you'll come out of learning C or C++ as a better programmer, with a better understanding of computers.

    In a lot of other languages you can learn to program "well" without ever learning anything about how the computer works or why you should do things a certain way. Your programs will be slower too. For research applications it's important that my code be as fast as possible. While you're writing simple programs, a factor of 2 in performance is nothing. You'll never care if you computer takes 5 milliseconds to run instead of 10 milliseconds. But if you're ever doing complex numerical calculations (I had some programs running for weeks on a super-computer last year to calculate some results) then even a small fractional improvement in performance can be significant, meaning you take 1 week, instead of 2 to get results.
  10. Apr 24, 2010 #9
    I would have recommended it if it weren't obsolete and hardly ever used anymore, except for a few aging academics.

    I had to learn some FORTRAN to make some of my advisor's old code work with my C++.
  11. Apr 24, 2010 #10
    Now I'm just friggin confused. But it was my fault for not being specific in my OP.
    Okay. Well, I have somewhat of a grasp on Java, and I can do DOS. (Hey...I have a real old computer. :wink:)
    I eventually want to end up in game design (God, don't tell my mom I wanna work on video games...) but I know that I would have to do regular programming first. So, what's good for ending up in games?
    And I do want to know how everything works. I'm one of those annoying kids that high school teachers hate because i want to know exactly HOW stuff works. Not why. (That's why I love physics.) So I'm definitely gonna pick up a few books on computers anyway. I know ideas of how stuff works, but not a great one.
    And hey, now, I'm a pretty damn smart high school kid. :P
    Last edited: Apr 24, 2010
  12. Apr 24, 2010 #11
    Maybe I can make a suggestion that we can all agree on?

    NOT Visual Basic!
  13. Apr 24, 2010 #12
    Sounds like I'm gonna make a trip to Barnes and Noble today...
  14. Apr 24, 2010 #13
    Sorry, but C# makes me think of music. :D

    But on a serious note, what type of game aspects is it used in? Obviously it WOULD be useful/not in different aspects, so elaborate please.
    *promptly screams in confusion* This is true- I am confused.. I don't want to have to un-learn stuff that I might learn wrong, so Kajahtava's comments show the cons. That's awesome. But how much weight do they hold? (In a non-rude way) Here's the thing- I want to become a very good programmer. Extremely good. Epicly good...so, where do i start to become a very good game designer?
    And, *screams* I feel very lost. I don't this sh** you guys talk about. Or your codes.

    No offense, but this is my research. I looked on the internet, got lost, and confused, so I decided to ask here. Isn't that what this site is FOR? I'm very sorry that I'm annoying you guys, but I really want to know how to do this, and I don't want to have to learn a bunch of stuff (Study the languages completely) just to learn that I shouldn't have learned that.

    Is that bad? :frown:

    And third:
    I'm sorry that you gave a "reasonable explanation". I guess I'm dumb. Cause it didn't much help. It made me realize that this is no better than looking forever on google, where I get the same "C SUCKS DON'T USE IT" vs "C IS AMAZING DON'T EVER DO ANYTHING THAN THAT." Not that you all are saying that. But yeah.
  15. Apr 24, 2010 #14
    C/C++ will have a steeper learning curve than the rest of the languages suggested here, but as long as you put in the effort to actually learn what the code/machine is doing, you will come out of learning it a better programmer than if you learn most any other language. If you don't mind putting in the effort, and making the conscious choice to keep figuring out what is going on "under the hood", as opposed to simply trusting the computer to do what's best, then I would strongly recommend starting with one of them.

    If you're not too concerned about what the computer is doing, and want to write programs that "just work", and you have a particular subsection of game programming you're interested in, then read through Kajahtava's post, and pick the language most relevant to what you have in mind. If you want to learn more about algorithm structure, and less about the computer architecture, then go with python or perl.

    Since you say you want to become a very good programmer, then I stand by my recommendation of C or C++ combined with lots of effort on your part.
  16. Apr 24, 2010 #15

    D H

    User Avatar
    Staff Emeritus
    Science Advisor

    XBox 360, for one. Microsoft is pushing the C#/.net stuff very hard when it comes to XBox 360.

    If you learn to program on your own, you are almost certainly going to "do it wrong" -- no matter what language you use.

    I am not, repeat am not, trying to dissuade you from learning to program on your own. I learned to program on my own in high school 35 years ago. Learning from your mistakes is a powerful way to learn. One problem with learning on your own is that you don't know you are making mistakes. That's okay, though. You will still be ahead of those of your classmates in college who have never taken a computer programming class in high school and have never bothered to learn how to do it on their own.

    Yes, some of us are saying that. Every language has its pluses (and this includes Visual Basic) and minuses (and this definitely includes Visual Basic). If you want to be a computer game programmer, C/C++ and its kin are where almost everything is at these days.

    If you want to be a good programmer you will learn a lot of different languages, and not just another variant of C/C++/C#/Objective-C/Java. You should learn some completely different paradigms. Eventually you should learn Lisp/Scheme to get a flavor for a rather different way of programming. Eventually you should learn assembler because that is as close as you are going to get to the computer (machine language is even closer, but nobody does that, not for a long, long time).
  17. Apr 24, 2010 #16


    User Avatar
    Homework Helper

    You don't have to "un-learn" anything. You may end up changing your coding style or using a different algorithm to solve a problem. For example, there are various algorithms to sort data, with the two "best" being quicksort and (bottom up) mergesort. Merge sort takes double the memory space (at least for the pointers), but can be faster. As mentioned above, each job will usually have some type of coding standards, and these vary from job to job. Some jobs will be better than others.

    You need to learn the basics of programming first. For game programming, it depends on the game. Common things would be how to render a dynamic view of a 3d landscape filled with 3d objects, some (or all) of which may be moving. You'll also need some means to apply some set of physics rules on how those objects move around and how to deal with collisions. Other forms of interaction may also be involved. The most likely scenario is you'll be part of a team, and you'll be specializing in some aspect of game development. Some game designers are more artists than programmers, and all they do is implement the 3d objects used in a game.

    For most games, you'll be using a sub-set of C, and using libraries developed at the workplace to deal with the game components. You will not need to learn every function or template in standard C or C++ libraries. Unless the game is dialog based, you won't be doing much work with strings.

    As far as game designing goes, I wouldn't know. There doesn't seem to be a lot of innovation in games anymore, it's mostly enhancements of previous games with similar gameplay. Racing games, first person shooters, strategy games, adventure / puzzle games, character leveling up multiplayer games.
  18. Apr 25, 2010 #17


    User Avatar
    Staff Emeritus
    Science Advisor
    Gold Member

    Last edited by a moderator: Apr 25, 2017
  19. Apr 25, 2010 #18
    Thanks. I'm not sure how I got an argument going...

    Is Python hard to learn? I know some aren't (like Perl)
  20. Apr 25, 2010 #19
    Python is made to be simple to learn.

    Python, together with Ruby and Smalltalk follow the so called 'principle of least surprise', the languages are designed in such a way as most human users expect things will happen.

    Python is quite versatile, (as is Ruby), it are languages that are both suited for beginners as well as allowing a properly structured coding style to some degree.
  21. Apr 25, 2010 #20

    D H

    User Avatar
    Staff Emeritus
    Science Advisor

    Python is a fairly easy language to learn. There are a couple of things I don't like about Python that have a bit of a hard time seeing past. Sometimes those http://pragmatic.nationalinterest.in/2008/09/05/gok-4-coffee-stains-tea-cups/" [Broken] can be a bit hard to overlook, particularly for an old fart like me. That said, Python is a powerful yet easy to learn language.

    You mentioned earlier that you are interested in computer games. At least for now, that means either C++ or C#. The Sony game console graphics interfaces are in C++ while XBox 360 is C#. Computer games without graphics are sooo 1980s. One can only go so far with "you are in a maze of twisty little passages, all alike."

    You mentioned that you already know Java to some extent. I would suggest you stick to that for the time being. The path from Java to either C++ or C# is not all that hard to traverse. They all descend from C, after all. To do Python well you will learn some tricks and techniques that are quite specific to that language. Learning those is a bit of a waste if your goal is computer game development.

    If your goal is to be a good (topnotch) programmer it is a good idea to learn many, many different languages over your career. I have lost count of how many languages I have learned over my career. Many (most?) do not even exist anymore. That, BTW, is one reason to learn how to quickly learn to use a new programming language. Becoming an expert in one, but only one, language is, well, stupid. Languages come and go. I doubt computer games of the 2030s will be written in C++ or C# -- or in Python.
    Last edited by a moderator: May 4, 2017
Share this great discussion with others via Reddit, Google+, Twitter, or Facebook