I am currently majoring in materials science and minoring in physics. I wanted to learn a programming language which will be useful for me in the long run. Whihc programming language should I prefer?
If you intend to study material science , in my view the best language for this type of studies are both Fortran and C (C++), the great advantages is that many well optimised libraries are available for free (lapack, blas,..) thus allowing large scale numerical studies.
python is a good choice for general purpose, given its graphics and data structure capabilities etc. there is work going on to integrate python drivers with computing routines in other languages. for heavy computing C++ or Fortran 2003; the latter can do object-oriented programming if you need it very much like C++; in addition VASP, Quantum Espresso, and large swaths of Gromacs are in fortran. LAMPPS and much of Gromacs (may be Amber too) are in C++. so my suggestion is python as general purpose, and then f03 or c++ depending on what you use mostly (if it's vasp then f03, if lampps then c++). of course if you pla n leave academia and may be take up programming jobs etc, then c++, but also other exotics such as php java or php are probably better.
For small programs I recommend VBA, the Visual Basic included in Excel. Despite its name it is a well-structured language and there is no trouble with input-output because the Excel sheet can used to this end. For example, instead of programming graphs numeric results can be converted to graphs in Excel. VBA is not suitable for really time consuming tasks because of its low efficiency, but those should be left to a professional programmer anyway. Of course, the best language for handling input from instruments for experimental scientists is a different question
Personally, I would recommend you to learn Python. And possibly JavaScript although it is a scripting language, technically. Python is a modern language, has many scientific packages available, and is taught as the first programming language to students at some places if I can recall correctly. JavaScript is essential if you want to do any web browser-based visualization/simulation. However, note that most answers to your question here would likely be biased by users' personal preferences.
I would recommend C (or C++) and Matlab. If you can invest some time to formally learn a language, you should start with C(or C++). Languages like Python (the current trend) can be learnt easily and within a short span of time. The advantage with C (and actually Fortran, although I do not recommend) is that a large pool of standard codes already exist.
Since you are interested in studying material science. I recommend you to learn Fortran language the best to do simulations and modeling within the code that you will develop for your system. later you can develop any interface between your code and other packages to master what you want to do...by doing this you will learn physics and material science too.... Wish you all the best.
Python, is a good general purpose language. However, as surprising as it may sound, you should learn a functional language ( Common Lisp, Scheme,Clojure,Wolfram Language (also known as Mathematica), Racket, Erlang, OCaml,Haskell). Personally i have studied Racket.
To my opinion, this language is particularly adapted to scientist. It's allow very, quickly to implement your research. Without going deeply into details of programming like C, Java, or even Python. There is a closed bind between the formal mathematical expression and the code LISP. For example you can derive from a theorem, the code and the code can inspire you to define the prove of your theorem.
Matlab is quick and powerful. It is also very good specially at simulation (simulink, is very powerful and completed with libraries for power electronics, mechanics, multiphysics, etc). However is very expensive.
However, if you work is data science (statistics, data analysis, data visualization) I would definitely choose Python and its data analytics ecosystem (scipy/numpy/matplotlib, pandas, scikit-learn, etc., etc.). Python is free, has a vibrant community, and has literally tons of libraries for almost everything you imagine: I would say it is, by far, superior to Matlab regarding the richness of libraries. A small drawback is that it is a bit slower than Matlab, but there are many possibilities and libraries able to do computation with multiple cores, GPU, cluster computation, and so. If you are proficient at this (I'm not :( ) it can fly. With distributions like Anaconda or Enthough Python Distribution (free for academic purposes) you will be able to install a powerful and expandable data analysis package in less than 15 minutes.
When I say that the best language is FORTRAN, I mean a number of problems solved through programs ABINIT, QUANTUM ESPRESSO and others. These are in particular problems in molecular dynamics, energy and phonon spectra of crystals, including methods MBPT, BSE etc. However, they are not problems solved by means of Matlab.
Most of the legacy code is in FORTRAN and C/C++ but world is moving towards easy-to-use languages like python and julia. Python's pymatgen module serves the ab-initio studies requirements quite well. Check them out at http://pymatgen.org/ . Analaysis of physical properties using finite elemnet methods can be done using fenics module with ease. Check it out at https://fenicsproject.org/ . With these two modules apart from numpy, scipy, pandas and matplotlib (https://www.scipy.org/stackspec.html), I find it sufficient to work entirely in python. Julia is another strong candidate which is emerging as a strong contender but its new and do not have good ecosystem of supporting modules yet. BTW, I am also a beginner in computational physics for material science. SO please do not take this as an expert advice. I learnt these languages for the purpose of doing these calculations and even wrote books from scientists point of view. Check them out at http://bookmuft.com/my-books/ . Keep on learning new things, you never know which one will become critical. For now python is your best bet.