1. Limited time only! Sign up for a free 30min personal 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!

What are the important programming languages in theoretical physics?

  1. May 25, 2013 #1

    QuantumCurt

    User Avatar
    Education Advisor

    Hey everyone, new member here, and I was hoping I could get some insight into this question. I'm a physics major in a community college right now, with plans to transfer to a university and double major in physics and math, and eventually go into theoretical physics. I'd really like to minor in philosophy, but I know how important programming is for theoretical physics (and any other scientific field for that matter), so I'm planning on learning a couple of programming languages through a combination of self study and elective courses.

    I'll be taking a calculus based computer programming course in C++ before I transfer, and after transferring I'll be taking an Intro to Computer Science course as part of the math major. What other types of CS courses should I be taking after transfer? Should I take more C++? I've gathered that Python is a fairly important programming language in theoretical physics. Should I take courses in discrete structures or data structures?

    Any help would be much appreciated! :)
     
  2. jcsd
  3. May 25, 2013 #2

    micromass

    User Avatar
    Staff Emeritus
    Science Advisor
    Education Advisor
    2016 Award

    If you've never done programming before in your life, then C++ is going to be a bit tough. Languages like python are very userfriendly and are ideal for a first language. So I recommend starting with that. Java is a language very similar to C++ but also quite easier. So that would be another good language to try out.

    I know I'm not answering your question about which are the important languages. But when you first get into programming, then I think the usefulness of a language is not so important. After all, a lot of programming languages use the same basic principles, and it is only the syntax that is different. So I would try to focus on understanding the basic principles first.
     
  4. May 25, 2013 #3

    QuantumCurt

    User Avatar
    Education Advisor

    No, I have never done any programming before. Unfortunately though, I'm in a community college with a fairly limited number of options within the CS department. Most of the courses are geared more towards networking and database maintenance type courses.

    This C++ course is actually a course within the math department. This is the course description- "The syntax of a high-level programming language is studied and applied to problems in mathematics, science and engineering. An emphasis is placed on the structured development of algorithms to solve these problems. The programming language features that lend themselves to problems in these areas such as special variable types, library and user defined functions, and subprograms are dealt with in more detail. Applications involving methods of finding roots of functions, numerical techniques of integration and differentiation, vector and matrix operations included."

    The only prerequisite for it is Calc I, which I'm taking this coming fall. I actually won't be taking this C++ course until the year after this coming year, so I would actually be taking this course at the same time as Calc III, so I'll be well beyond the math prerequisite. This C++ course is part of the transfer requirement that I'll have to complete to go to U of I Urbana-Champaign, which is my target transfer school.

    How hard would it be to start self studying a simpler language like Python in my spare time? Given that I still have quite a bit of time to get prepared for the C++ course, do you think self studying a language like Python would be adequate preparation for future programming courses? I'd love to take more CS courses before I transfer, but my schedules are already going to be crammed for the next couple years. Taking more courses would mean overloading, which I'd like to avoid at this point if possible.
     
  5. May 25, 2013 #4

    micromass

    User Avatar
    Staff Emeritus
    Science Advisor
    Education Advisor
    2016 Award

    Self-studying Python is really very doable. It's the perfect language for self-studying, so you shouldn't have much troubles. You should probably get a good book for python too, but I can't really recommend any.
     
  6. May 25, 2013 #5

    QuantumCurt

    User Avatar
    Education Advisor

    Thanks for the replies! I'll do some browsing around and see if I can find any good books for Python.

    Does anyone else have any recommendations for a good book to self study?
     
  7. May 25, 2013 #6
    Vern ceder's python book is a good concise intro, and many of my non-CS friends like it. I learned it using Lutz and Ascher, which is longer and not so well received. IMO, both are fine for beginners.

    Edit: Visual Basic is also another good one for a first language. For VB, Visual Basic Unloaded is a good textbook.
     
  8. May 25, 2013 #7
    There is a book called "Think Python" by Allen Downey. I used it as my intro to CS class and I loved it. As a bonus, it's actually available online for free as part of the authors request (non-illegal source). You could probably google it to get a pdf.
     
  9. May 25, 2013 #8

    QuantumCurt

    User Avatar
    Education Advisor

    Is this the Vern Ceder book you're talking about? https://www.amazon.com/Quick-Python-Book-Second/dp/193518220X

    It's got a ton of positive reviews from what I'm seeing. I'll definitely be keeping that one in mind. Thanks for the suggestions!

    Thanks for the suggestions! I looked up "Think Python," and I managed to find a .pdf for it.

    http://www.greenteapress.com/thinkpython/






    So what do I need to start programming? I assume I need to get some software. I'm pretty much clueless beyond that...lol...I've never done much with my computer aside from browsing the internet, so I don't even really know where to begin.
     
    Last edited by a moderator: May 6, 2017
  10. May 25, 2013 #9

    QuantumCurt

    User Avatar
    Education Advisor

    Should I repost this thread in one of the computer subforums? I hadn't dug very deep through the layout here when I posted this. One of the computer subforums may be more appropriate. I don't want to double post the same thread though.
     
  11. May 25, 2013 #10
    If you want to start programming in python, you'll need a shell to run it in. Going to python.org and getting the free offered software is one way. Or you could pick up other third-party (don't pay for it!) software out there. I personally use enthought canopy (google search it) which comes with a bunch of scientific packages.

    It may take a bit to get used to using it, but easy lessons are probably up on youtube for help on getting started.
     
    Last edited: May 25, 2013
  12. May 25, 2013 #11

    QuantumCurt

    User Avatar
    Education Advisor

    Thanks! I'm at python.org, and I'm trying to figure out which version I should download. It sounds like 2.7 is the last 2.x release, and they're transitioning over to the 3.x platform entirely now. Should I download Python 3.x, or will I be better off with 2.x for now?

    edit- It looks like the "Think Python" book you recommended is assuming the use of Python 2. In the first chapter it mentions that statements will need to be translated for Python 3. So, I'm thinking I should just stick with Python 2 for now?
     
    Last edited: May 25, 2013
  13. May 25, 2013 #12

    QuantumCurt

    User Avatar
    Education Advisor

    Although it looks like the only difference they're showing in the "First Program" section is....

    Python 2

    print "Hello, World."


    Python 3

    print ("Hello, World.") with the parentheses nothing that "print" is a function.

    Easy enough to translate. Is this going to get more confusing as I go on though, and make me wish I'd just stuck with 2.x?
     
  14. May 25, 2013 #13
    It really doesn't matter what you start with. There isn't a fundamental, architectural, or big conceptual difference between the two. Most of the differences are syntax related, and new conventions for things you could already do before.

    Python <2.7 has/had a lot of momentum, so you might find more prebuilt software tools available for it (along with learning resources), but all of these things are going to be available for Python 3 in the future:

    http://python3wos.appspot.com/ (popular libraries that have been translated to python 3)
     
  15. May 25, 2013 #14
    "Think Python" was written with python 2.7 in mind, so that may be an important factor.
     
  16. May 25, 2013 #15

    QuantumCurt

    User Avatar
    Education Advisor

    Well I'm trying to install Python 2.7.5, and I'm getting some kind of error. Help!!

    During the installation process, I'm getting a box pop up that says "Could not write value to key \software\classes\.py\ Verify that you have sufficient access to that key or contact your support personnel."

    Then if I click ignore, it's giving me the same message with other directories. I don't know what's going on here.

    edit-Well, I appear to have the Shell, the Command Line, the Module Docs and the manuals all working. So...I don't know what the deal with the installation issue was.
     
  17. May 26, 2013 #16

    Vanadium 50

    User Avatar
    Staff Emeritus
    Science Advisor
    Education Advisor

    A discussion on how to program in Python probably belongs in the CS section.

    Getting back to the original question, it is much more valuable to know how to program than how to hack something together in a particular language. If you understand programming, picking up a language is easy. The converse is not true.
     
  18. May 26, 2013 #17
    Agreed. If you're required to learn C++ for a course, I would go as far with C++ as you feasibly can. When it comes to programming, the programming techniques you know are far more important than what language you know them in. Once you know how to do things in one language, it's usually pretty straightforward to learn them in another language. Learn to be a good programmer in whatever language happens to work with your studies, and if you find out you need language X for job Y, you shouldn't have much trouble learning to apply your good programming skills in that particular syntax.

    As an additional note, I would lean towards C++ over Python if you're going to be doing a lot of programming because C++ kind of forces you to learn a little bit more about that hardware and what's going on in the background behind your code. You can learn more with C++ I think, but the downside is that it's a little more unwieldy and harder to learn than Python. If you're going the C++ route, I would personally try to take courses rather than self-teach.
     
  19. May 26, 2013 #18

    QuantumCurt

    User Avatar
    Education Advisor

    Thanks so much for the replies. I really feel like I've got a much better idea of what I need to be doing now. I'm not going to be taking this C++ class until spring 2015, and I won't be taking any other CS classes until after transferring in fall 2015. So, I've got plenty of time until then. I've already worked through the first two chapters of Think Python (pretty simple stuff so far). I'll definitely be spending as much time as I can learning the basics of CS. I'm going to try and get reasonably comfortable in a couple different languages before I take any formal classes.

    I'll just continue working on Python for now, and then I'll pick another one to start working on after I get comfortable with that. Since I'm going to be taking a C++ class, I'll probably hold off on doing anything with that for a while. By the time I get to it, I should be fairly comfortable with programming in general.

    Thanks for all the help!!
     
  20. May 27, 2013 #19
    I'm not an excellent programmer by any means, but I've recently gotten up to speed as necessary for my research work. So far in a biophysics lab and a particle physics lab, I have needed a working knowledge of python and C++.

    Importantly, the biggest stumbling block was not one languages syntax over the others, but rather coming to grips with the basic concepts of programming (functions, variables, program structure, even objects and classes for OOP). After that the other stuff came much more easily.

    As a somewhat advanced suggestion, I've been told to investigate Lisp and/or Scheme at some point. Neither language has a large enough following to be your main language, but the way they are designed powerfully changes your way of thinking (in a good way).
     
  21. May 28, 2013 #20

    QuantumCurt

    User Avatar
    Education Advisor

    Thanks for the reply. From everything I've been able to find, it sounds like Python and C++ do tend to be a little bit more widely used than some other languages in physics. But, from what everyone here, and elsewhere, has been telling me...it's really going to be more important to just get a solid grounding in CS/programming in general. So, I'm going to focus on teaching myself Python for now, and try to expose myself to as many languages as I can over the next year and a half or so before I start taking some formal CS courses.
     
Know someone interested in this topic? Share this thread via Reddit, Google+, Twitter, or Facebook




Similar Discussions: What are the important programming languages in theoretical physics?
Loading...