What are the important programming languages in theoretical physics?

In summary, the individual is a new member with plans to transfer to a university and double major in physics and math with a minor in philosophy. They are planning on self-studying programming languages and taking elective courses in programming. They will be taking a calculus-based C++ course before transferring and an Intro to Computer Science course as part of their math major. They are wondering which other CS courses they should take after transferring and if learning Python would be adequate preparation for future programming courses. They ask for book recommendations for self-studying Python and mention their limited options for CS courses in their community college. They also ask for advice on what software they will need to start programming.
  • #1
QuantumCurt
Education Advisor
726
166
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! :)
 
Physics news on Phys.org
  • #2
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.
 
  • #3
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.
 
  • #4
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.
 
  • #5
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?
 
  • #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.
 
  • #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.
 
  • #8
hsetennis said:
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.

Is this the Vern Ceder book you're talking about? https://www.amazon.com/dp/193518220X/?tag=pfamazon01-20

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!

Sentin3l said:
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.

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:
  • #9
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.
 
  • #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:
  • #11
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:
  • #12
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?
 
  • #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)
 
  • #14
QuantumCurt said:
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?

"Think Python" was written with python 2.7 in mind, so that may be an important factor.
 
  • #15
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.
 
  • #16
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.
 
  • #17
Vanadium 50 said:
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.

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.
 
  • #18
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!
 
  • #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).
 
  • #20
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.
 

1. What programming languages are commonly used in theoretical physics?

The most commonly used programming languages in theoretical physics are Python, Fortran, Matlab, C++, and Julia. These languages are preferred for their versatility, speed, and wide range of scientific libraries and tools.

2. Why is Python a popular choice for theoretical physics?

Python is a popular choice for theoretical physics due to its simplicity, readability, and large community support. It also has a wide range of libraries and tools specifically designed for scientific computing, such as NumPy, SciPy, and SymPy.

3. Is Fortran still relevant in theoretical physics?

Yes, Fortran is still widely used in theoretical physics due to its speed and efficiency in handling complex mathematical operations. Many legacy codes in theoretical physics are written in Fortran, and it is still being actively developed and used in high-performance computing.

4. Can C++ be used for theoretical physics?

Yes, C++ is a powerful language that can be used for a wide range of applications, including theoretical physics. It is commonly used for its speed, efficiency, and ability to handle large amounts of data. Many simulation and modeling codes in theoretical physics are written in C++.

5. What is the role of Matlab in theoretical physics?

Matlab is a high-level programming language commonly used in scientific and engineering applications, including theoretical physics. It is popular for its ease of use, extensive library of mathematical functions, and interactive environment for data visualization and analysis.

Similar threads

  • STEM Academic Advising
Replies
13
Views
2K
Replies
8
Views
1K
  • STEM Academic Advising
Replies
1
Views
2K
Replies
6
Views
958
Replies
8
Views
1K
  • STEM Academic Advising
Replies
1
Views
606
Replies
16
Views
1K
Replies
4
Views
1K
  • STEM Academic Advising
Replies
7
Views
2K
  • STEM Academic Advising
Replies
4
Views
204
Back
Top