1. Not finding help here? Sign up for a free 30min tutor trial with Chegg Tutors
    Dismiss Notice
Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Computer Programming

  1. Apr 3, 2009 #1
    OK, so I know virtually nothing about computer programming, and this fall I am starting into a double major of applied math and physics. The only computer science course that is required is the University's Intro to CS course. I am thinking that, if possible, I am going to try to do the accelerated BA/MA program for Math that the university offers, and then heading off to a PhD program for Physics. That being said, I do not think I will have many openings in my schedule for any sort of programming classes, and therefore will be teaching myself, in any sort of spare time I can get.
    From what I understand, a physicist ought to have a pretty decent knowledge of programming. My question is, where should I start for learning about programming. I have noticed Fortran mentioned on here a bunch. Should I try to learn that first, or is there a programming language, that, if known, makes it easier to learn other sorts of languages as needed?
    Thanks in advance for your help.
    Also, the names of any books that you have found to be helpful, or heard to be helpful would be greatly appreciated.
     
  2. jcsd
  3. Apr 3, 2009 #2

    mgb_phys

    User Avatar
    Science Advisor
    Homework Helper

    Depends what kind of physics you are going to be doing, the idea is to minimise the amount of programming - otherwise it will consume all your time.
    If you are mostly theoretical then Mathematica or similair.
    For data analysis, you can do an awful lot with Excel or python is now pretty popular. I suspect most lab classes have stopped the Fortran introduction.
    But if you are going to be an experimentalist you might be dragged down into details of C, assembler, DSPs, FPGA and weird and wonderful custom hardware!
     
  4. Apr 3, 2009 #3

    chroot

    User Avatar
    Staff Emeritus
    Science Advisor
    Gold Member

  5. Apr 3, 2009 #4
    I vote C++.
     
  6. Apr 3, 2009 #5

    mgb_phys

    User Avatar
    Science Advisor
    Homework Helper

    Sadist!
     
  7. Apr 3, 2009 #6

    chroot

    User Avatar
    Staff Emeritus
    Science Advisor
    Gold Member

    So begins another pointless war.

    The bottom line is this: Python and SciPy will provide an environment in which you can do more scientific computation with fewer lines of code than any other general-purpose language, on average. Does that make it the "best language?" That depends on your personal criteria.

    - Warren
     
  8. Apr 3, 2009 #7
    I am not sure yet what kind of physics I will be doing as of yet.
    In y'all's opinion, would it be more beneficial, in the long run, of having a firm grasp on C++, or just jumping into learning something like python, while having no other background in programming?
     
  9. Apr 3, 2009 #8
    Oh, and thanks a ton for the quick replies! And the easy links! Quite impressive
     
  10. Apr 3, 2009 #9
    I depends on whether you want a deep understanding of what the computer is doing when your programs are running, but a common trait of good programmers is that they understand the workings of a normal modern CPU. Once you do that, which requires a bit of assembler, It doesnt really matter what language you use.

    So my advice would be to learn just a bit of assembler. It doesnt have to take long. Just so you get the basic principles. Then, take up some C, understand what the compiler does to generate the 'assembler' you learned. Write a few programs etc. Then take up C#, C++ or java. I'd say c# is the easiest to 'pick up', java second and if you are a sadist, become a C++ expert. Then all the script/typeless languages etc.

    Then, choose your pet language and flame anybody for ever using anything else... ;)

    But the point is, that by that time, you can pickup any language far easier than starting programming in say python.
     
  11. Apr 3, 2009 #10

    mgb_phys

    User Avatar
    Science Advisor
    Homework Helper

    As a first language, especially for science I would recommend python.
    http://diveintopython.org/ is a free book on python and the best into to the langauge.
    http://greenteapress.com/thinkpython/thinkCSpy/ is a good intro to programming using python.

    How much programming you want to learn is upto you. You can do all the data analysis in a physics degree just using Excel or you can end up doing a lot more programming than a CS major.
     
  12. Apr 3, 2009 #11

    chroot

    User Avatar
    Staff Emeritus
    Science Advisor
    Gold Member

    I'd have to argue with all of this. A strong knowledge of algorithms, and when to apply them, is much more useful to a programmer than is any machine-specific knowledge. In practice, compilers are much better at creating fast machine code than are people. Assembly is pretty much a horrible choice for almost all programming tasks.

    This is the path that a computer engineer would take in learning how to design computers. The original poster is asking about using computers to solve physics problems. It would be senseless to demand that he become a computer engineer before he can begin solving physics problems.

    Yes, four years from now, he'll be quite well prepared to learn python. Of course, he's already quite well prepared to learn python, so maybe he should just start there.

    - Warren
     
  13. Apr 5, 2009 #12
    Here is Langtangen's Introduction to Computer Programming, A Python-Based Approach for Computational Science. It is used in the first semester in Norway.

    http://folk.uio.no/hpl/INF1100/INF1100-ebook-Aug08.pdf [Broken]
     
    Last edited by a moderator: May 4, 2017
  14. Apr 5, 2009 #13
    cool, thanks for the link to the e-book! I will be using that for sure! :)
     
  15. Apr 5, 2009 #14
  16. Apr 5, 2009 #15
    You completely misunderstand the point. Did I say that assembler is the most usefull for a programmer? no. And also specifically said 'if you want a deep understanding'. What I am trying to say is that, to be a truly good programmer, you need to know how CPU's do their work. The assembler part is just about lerarning how the CPU works. I never said you should use it for anything, just have a understanding of what computers are about. And since all CPU's pretty much work the same way, I can't see any 'machine specifics here'. I've seen far too many programmers falling short when problems occur just because they don't truly understand what they are doing.

    Doing programming without the CPU knowledge part is like doing physics without truly understanding calculus.

    Anyway, what makes you think that learning good algorithms and when to apply them would take less time? It takes far more time than learning how to program.

    But yes, feel free to skip the deep understanding. All this takes time yes, but 4 years is a bit exagerated. Just use enough time to learn the basics. A couple of month should do.
     
  17. Apr 5, 2009 #16

    mgb_phys

    User Avatar
    Science Advisor
    Homework Helper

    C++ is more complicated to write simple programs than python.
    Consider reading some values from a file and solving a few similtaneous equations in C++ and python+scipy or numpy.

    Probably Java or C# is now more widely used by developers - that doesn't mean they are better than C++ of course, as the old saying goes "eat sh*t, a billion flies can't be wrong"
     
  18. Apr 5, 2009 #17
    There is a free ebook called http://www.htdp.org/" [Broken] that you should read if you are unfamiliar with programming. It is a very nice book for absolute newbies using a restricted subset of scheme, that slowly builds you up to the full version of scheme. Do not use C as your first language, you will be confused. Also stay away from Java, C++, C# as their power will give you bad programming habits.

    Once you finish that book, learn a bit about low level programs in assembly and how a computer works and then learn C and C++.

    Its very easy to go from a new programmer to a good programmer but hard to go from a bad programmer to a good programmer.

    Either read the book that I recommended or learn python from a good book. Stay away from the more complex languages as a newbie.
     
    Last edited by a moderator: May 4, 2017
Know someone interested in this topic? Share this thread via Reddit, Google+, Twitter, or Facebook




Similar Discussions: Computer Programming
Loading...