Learn Computer Programming for Applied Math & Physics Majors

Click For Summary

Discussion Overview

The discussion revolves around the best programming languages and approaches for students majoring in applied math and physics, particularly for those with little to no prior programming experience. Participants explore various languages, their applicability to different fields within physics, and the balance between learning programming and focusing on core physics concepts.

Discussion Character

  • Exploratory
  • Debate/contested
  • Technical explanation
  • Conceptual clarification

Main Points Raised

  • One participant suggests starting with Python and SciPy for scientific computation, citing their efficiency in handling tasks with fewer lines of code.
  • Another participant mentions that the choice of programming language may depend on the type of physics one intends to pursue, recommending Mathematica for theoretical work and Python or Excel for data analysis.
  • Some participants advocate for learning C++ for its capabilities, while others argue that Python is more accessible and sufficient for scientific applications.
  • A viewpoint is presented that understanding algorithms is more crucial than low-level programming knowledge, suggesting that assembly language is not necessary for most programming tasks.
  • There is a discussion about the importance of understanding how computers operate, with some arguing that a basic knowledge of assembly can enhance programming skills, while others contest its relevance.
  • Several resources, including links to Python tutorials and books, are shared to assist in self-learning programming.
  • Participants express differing opinions on the complexity of C++ compared to Python, with some highlighting the ease of use of Python for beginners.

Areas of Agreement / Disagreement

Participants do not reach a consensus on the best programming language to learn first, with multiple competing views on the merits of Python, C++, and the necessity of understanding low-level programming concepts. The discussion remains unresolved regarding the optimal approach for beginners in programming for physics applications.

Contextual Notes

Limitations include varying definitions of what constitutes a "good" programming language based on personal criteria, the differing needs based on specific physics disciplines, and the unresolved debate on the importance of low-level programming knowledge versus algorithmic understanding.

KelCatrell
Messages
15
Reaction score
0
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.
 
Physics news on Phys.org
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!
 
I vote C++.
 
AUMathTutor said:
I vote C++.
Sadist!
 
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
 
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?
 
Oh, and thanks a ton for the quick replies! And the easy links! Quite impressive
 
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 doesn't really matter what language you use.

So my advice would be to learn just a bit of assembler. It doesn't 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.
 
  • #10
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 language.
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.
 
  • #11
FredericGos said:
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 doesn't really matter what language you use.

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.

So my advice would be to learn just a bit of assembler. It doesn't 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.

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.

But the point is, that by that time, you can pickup any language far easier than starting programming in say python.

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
 
  • #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
 
Last edited by a moderator:
  • #13
cool, thanks for the link to the e-book! I will be using that for sure! :)
 
  • #14
  • #15
chroot said:
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.

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.
 
  • #16
AUMathTutor said:
Why would you advise against c++? Is it because it's faster, offers more low-level capabilities, or is more widely used by developers worldwide
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"
 
  • #17
There is a free ebook called http://www.htdp.org/" 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:

Similar threads

  • · Replies 6 ·
Replies
6
Views
3K
  • · Replies 12 ·
Replies
12
Views
2K
  • · Replies 16 ·
Replies
16
Views
4K
  • · Replies 3 ·
Replies
3
Views
3K
  • · Replies 3 ·
Replies
3
Views
2K
  • · Replies 3 ·
Replies
3
Views
2K
  • · Replies 3 ·
Replies
3
Views
1K
  • · Replies 5 ·
Replies
5
Views
2K
  • · Replies 6 ·
Replies
6
Views
2K