Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

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

  1. Mar 9, 2015 #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.
     
  2. jcsd
  3. Mar 9, 2015 #2

    DrClaude

    User Avatar

    Staff: Mentor

    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.
     
  4. Mar 9, 2015 #3
    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.
     
  5. Mar 9, 2015 #4

    rcgldr

    User Avatar
    Homework Helper

    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.
     
  6. Mar 9, 2015 #5

    FactChecker

    User Avatar
    Science Advisor
    Gold Member

    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.
     
  7. Mar 9, 2015 #6
    Thanks all. I know learned a little about MATLAB and C++ before. For C++, could you please recommend some text books which is clear written and easily followed. I find many textbooks are not aimed to beginners, so they are very hard to read.

    Thx.
     
  8. Mar 9, 2015 #7

    rcgldr

    User Avatar
    Homework Helper

    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
     
  9. Mar 9, 2015 #8
    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.
     
  10. Mar 10, 2015 #9
    I recommend Python, its easy to grasp and understand. However if you believe yourself to be reasonably adept I would look into JavaScript :)
     
  11. Mar 10, 2015 #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
     
  12. Mar 10, 2015 #11
    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.
     
  13. Mar 10, 2015 #12

    jtbell

    User Avatar

    Staff: Mentor

    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/Programming-Principles-Practice-Using-2nd/dp/0321992784/ref=sr_1_2
     
    Last edited by a moderator: May 7, 2017
  14. Mar 10, 2015 #13
    C is hard to learn because functionnal programming is not realy 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.
     
  15. Mar 10, 2015 #14
    ^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: May 7, 2017
  16. Mar 10, 2015 #15

    jtbell

    User Avatar

    Staff: Mentor

    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.
     
  17. Mar 10, 2015 #16
    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.
     
  18. Mar 11, 2015 #17
    in my major, ocean engineering, we use fortran and matlab mostly.
    such as Princeton Ocean Model (POM), etc.
    good luck!
     
  19. Mar 11, 2015 #18
    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.
     
  20. Mar 11, 2015 #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.
     
  21. Mar 16, 2015 #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 realised 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.
     
Know someone interested in this topic? Share this thread via Reddit, Google+, Twitter, or Facebook




Similar Discussions: New beginner's help -- learn which programming language to enrich my knowledge?
Loading...