New beginner's help -- learn which programming language to enrich my knowledge?

Click For Summary
SUMMARY

The discussion centers on the best programming languages for physics undergraduates looking to enhance their skills. Participants recommend starting with Python due to its simplicity and applicability in scientific computing, followed by MATLAB for its interactive capabilities. C++ is suggested for intensive computing tasks, leveraging libraries like Boost and OpenCV, while Fortran remains relevant for specific engineering applications. The consensus emphasizes choosing a language based on personal goals and the current tools used by peers in academia.

PREREQUISITES
  • Basic understanding of programming concepts
  • Familiarity with scientific computing applications
  • Knowledge of MATLAB for mathematical problem-solving
  • Awareness of object-oriented programming principles
NEXT STEPS
  • Learn Python for beginners through resources like the MIT OCW 6.00 course
  • Explore MATLAB and Simulink for engineering simulations
  • Study C++ with recommended textbooks by Bjarne Stroustrup
  • Investigate cloud computing solutions for intensive computational tasks
USEFUL FOR

Physics undergraduates, engineering students, and anyone interested in programming for scientific applications will benefit from this discussion.

christliang
Messages
8
Reaction score
1
I am a physics undergraduate and is going to pursue a physics Ph.D. degree from 2015 Fall.

I am thinking about learning some programming language to enrich my knowledge. Also, I hope this kind of skill could enlarge the scope of my future career. Please give me some advice on which language should I start from.

THX.
 
Technology news on Phys.org
There are numerous threads on the subject, simply search "which language".

The bottom line is that it doesn't matter. Choose C, Fortran, Python, or whichever else for which you can find a compiler and a good book to learn from.
 
  • Like
Likes   Reactions: shade rahmawati
First learn Matlab then you have a lot of choice.
I personally use C++ for intensive computing. You have good library, Boost, STD, QT for graphics, OpenCV for computer vision... You can build powerful and reusable code with template méta-programming. You can use assembler code, SIMD intruction for parallélisation (SSSE3 is very usefull for intensive computing).
I know less Fortran and Python. Java is good only for multi-platform, don't use it for math.
 
  • Like
Likes   Reactions: FactChecker
For engineering / math / ... type students and engineers, Matlab is popular software tool due to it's ineractive ability to solve mathematical problems without going much into actual programming, You can pick up what programming you need over time. To learn programming as opposed to using a high level tool like Matlab, the language doesn't matter that much, but I would suggest finding out what the current graduate students are using at your school and use what they use.
 
  • Like
Likes   Reactions: FactChecker
I second the Matlab recommendation for physics and engineering applications. Also check out Simulink. It is a diagramming tool for simulations that is also made by Mathworks and is well integrated with Matlab. Both have extensive libraries for application areas.
 
Thanks all. I know learned a little about MATLAB and C++ before. For C++, could you please recommend some textbooks which is clear written and easily followed. I find many textbooks are not aimed to beginners, so they are very hard to read.

Thx.
 
christliang said:
For C++, could you please recommend some textbooks which is clear written and easily followed.
You could just start off with simple programs, like copying a file (read a file and write to another file). Perhaps a sort program that generates an array or vector of random integers and using std::sort to sort the integers. A program to find primes via sieve method.

Here's a link to a very old learning exersice that includes some basic concepts of programming, although dealing with the limitation on branching is more of a puzzle aspect than a programming method.

simple programming training puzzle
 
rcgldr said:
You could just start off with simple programs, like copying a file (read a file and write to another file). Perhaps a sort program that generates an array or vector of random integers and using std::sort to sort the integers. A program to find primes via sieve method.

Here's a link to a very old learning exersice that includes some basic concepts of programming, although dealing with the limitation on branching is more of a puzzle aspect than a programming method.

simple programming training puzzle
OK. I think it may be a good way to start. You know, there are many textbooks in my native language(Chinese) that only describe the concepts and do not use many words to show the details of some simple programs. So, I hope you can write some names of books.
 
I recommend Python, its easy to grasp and understand. However if you believe yourself to be reasonably adept I would look into JavaScript :)
 
  • Like
Likes   Reactions: camila
  • #10
I would strongly suggest starting out with Python, which is simple as well as enlightening about topics encountered in most other languages. Once you learn Python, MATLAB will be easy to learn. Try NOT to start with C. It is an excellent language ( my favorite) without doubt, but not the best starting language. I have come across quite a few people who ran away from programming because they started with C
 
  • Like
Likes   Reactions: camila
  • #11
sarvesh0303 said:
I would strongly suggest starting out with Python, which is simple as well as enlightening about topics encountered in most other languages. Once you learn Python, MATLAB will be easy to learn. Try NOT to start with C. It is an excellent language ( my favorite) without doubt, but not the best starting language. I have come across quite a few people who ran away from programming because they started with C

Yes, it true... I tried to learn C one year before, but it really didn't leave me a deep impression...

Ok, I think maybe python is a good language for a beginner like me.
 
  • Like
Likes   Reactions: camila
  • #12
christliang said:
For C++, could you please recommend some textbooks which is clear written and easily followed. I find many textbooks are not aimed to beginners, so they are very hard to read.

I've never seen this book myself, but it has good reviews on stackoverflow and amazon.com, and I have some of Stroustrup's other books which are very well written. He is the original inventor of C++ and is probably the leading authority on it. Unlike his other books, this one is intended for people with no programming experience.

https://www.amazon.com/dp/0321992784/?tag=pfamazon01-20
 
Last edited by a moderator:
  • #13
C is hard to learn because functionnal programming is not really intuitive. C++ is oriented object, If you understand oriented object programming, you will define the diferrent concept needed for your project, then you can write it. Python is a new but very popular programming langage, i like it, there is a lot of libs for matrix computing, MATLAB like. BUT it depend of your personnal objective. I repeat, if it's for intensive computing you don't have the choise C++ or Fortran.
 
  • #14
jtbell said:
I've never seen this book myself, but it has good reviews on stackoverflow and amazon.com, and I have some of Stroustrup's other books which are very well written. He is the original inventor of C++ and is probably the leading authority on it. Unlike his other books, this one is intended for people with no programming experience.

https://www.amazon.com/dp/0321992784/?tag=pfamazon01-20
^This. This is easily the best programming book I've seen. I think, however, that Python is a better language for a new programmer, and I'd recommend the MIT OCW 6.00 course from Fall 2008 http://ocw.mit.edu/courses/electric...o-computer-science-and-programming-fall-2008/
It's got video lectures, assignments, readings for various subjects, and it will really guide you at applying your newly acquired programming knowledge into math/physics problems. Good luck
 
Last edited by a moderator:
  • #15
kroni said:
C++ is oriented object

C++ supports object-oriented programming, but it does not require you to write programs in an object-oriented style by defining your own classes of objects, member functions, etc. You can go a long way just using some of the pre-defined classes that are part of the standard library (e.g. iostreams, strings and vectors) which requires learning only a bit of "extra" syntax.
 
  • #16
kroni said:
I repeat, if it's for intensive computing you don't have the choise C++ or Fortran.
When it comes to intensive computing the trend goes more and more towards cloud based solutions. (e.g. Google's compute engine). That means whenever you need to do some lengthy computations you just upload your code and run it on their servers. You can rent as much computing time as you need and run it in parallel on as many servers as you want and of course you can use any language you want, including matlab. And since computing time is quite cheap, the language you use only matters if you have to do really huge amounts of calculations.
 
  • #17
in my major, ocean engineering, we use fortran and MATLAB mostly.
such as Princeton Ocean Model (POM), etc.
good luck!
 
  • #18
When it comes to intensive computing the trend goes more and more towards cloud based solutions. (e.g. Google's compute engine). That means whenever you need to do some lengthy computations you just upload your code and run it on their servers. You can rent as much computing time as you need and run it in parallel on as many servers as you want and of course you can use any language you want, including matlab. And since computing time is quite cheap, the language you use only matters if you have to do really huge amounts of calculations.

You can't say that ! Computing power is not a solution to intensive computing, i think that Cloud Computing must be used as last solution. Recently i traduce a MATLAB program in C++, I use SIMD instruction, OpenMP, Intel Compiler (Linking optimisation, automatic profiling and code optimisation). I work on cache miss, "if" bad prédiction, data structure optimisation and look up table. I gain a factor 17000 on time execution. So the MATLAB code work on 4 hours when mine compute in 1 seconds. It's an extrem example but i personnaly think that before use GPU or Cloud Computing, you must ultra-optimise the algorithme, the code, the compilation.
 
  • #19
I said the language doesn't matter (for moderate amounts of computations). I never said anything about the algorithm. Of course you should use a good algorithm. And I think that cloud computing can be a great solution. Not in all cases but sometimes it is the best option. What happens if after all your ultra optimizations you program still takes weeks to solve a problem? With cloud computing you are able to rent the power of 1000s of CPUs for a short time. Sometimes you simply need a huge amount of processing power.
 
  • #20
I suggest Python because it is easy to learn and is used with physics quite often. For example look at Blender and Sunpy( on Github). There is also a lot of help available for Python.
I started with Java, but later on I realized that is not the language I was looking for. I also tried C but that is in my opinion to complicated to start with, because of pointers etc. I also suggest to try C++. C++ is also easy to learn and suitable for many purposes.
 

Similar threads

Replies
86
Views
2K
  • · Replies 25 ·
Replies
25
Views
937
  • · Replies 397 ·
14
Replies
397
Views
20K
  • · Replies 8 ·
Replies
8
Views
3K
  • · Replies 15 ·
Replies
15
Views
4K
  • · Replies 11 ·
Replies
11
Views
3K
Replies
16
Views
3K
  • · Replies 133 ·
5
Replies
133
Views
11K
Replies
16
Views
4K
  • · Replies 9 ·
Replies
9
Views
2K