Programming Language for Physicists: Which is Most Important?

In summary: The libraries are often updated with the latest Fortran compiler and toolset releases.In summary, a good language for a physicist would be C, with C++ and Java being good alternatives. Additionally, a course in numerical methods would be very beneficial, as would knowledge of object orientated programming.
  • #1
go quantum!
54
0
As computers become each time more important to do computations in physics, it is important to know which programming language would be the most important for a physicist. What do you think?
 
Technology news on Phys.org
  • #2
Learning a little C gives one a leg up on just about all other languages...except BASIC.
 
  • #3
Whit programming languages there is something called the "learning curve". The languages with an initial steep learning curve (like assembler and C) have some advantages over languages with an initial low curve. Stay away from BASIC. It might look easy to start with but when you want to get technical the learning curve rises badly and it's not really geared towards mathematics. C and C++ has tons of good libraries for performing more serious math. (e.g.: Linear Algebra: http://www.boost.org/doc/libs/1_45_0/libs/numeric/ublas/doc/index.htm) Learning languages like C and Perl will make all the other languages look easy. I'm talking purely structural languages. Not functional ones like e.g. Miranda. Taking the time to climb the initial steep curve will pay off.

For science you should probably check out C, LISP and functional languages like ML and Miranda for pure math. Both C and Perl have good thourghly tested libraries for performing math. Perl even have libraries for playing around with quantum mechanical concepts like entanglement (http://packages.debian.org/unstable/perl/libquantum-entanglement-perl) . Also I'm under the impression that Mathematica is a good ally although I've never used it myself.

But yes, stay away from BASIC. It might look like the easiest to start with but you wil be punished later on when you want it to do complex stuff.

If you know C you can easily learn any other highlevel structured language.
 
Last edited:
  • #4
Makes you wonder what we will be coding in when the software arrives for the true quantum computer. Brave new world.
 
  • #5
More important than any language, in my opinion, is a course on numerical methods. There should be emphasis on, among other things, handling floating point arithmetic and roundoff. Math libraries such as the ones included in Mathematica, Maple, and Matlab mitigate this, but it's always good knowledge to have if you really require precision and speed. By the way, I dabbled in Mathematica during a weekend, and I found it to be one of the worst languages I have ever worked with.
 
  • #6
I primarily use C, C++ and Maple for modelling. Fortran is also one to look into.
 
  • #7
go quantum! said:
As computers become each time more important to do computations in physics, it is important to know which programming language would be the most important for a physicist. What do you think?

For a lot of mathematical modeling, a platform like MATLAB, Maple, or Mathematica would be good since it provides tonnes and tonnes of libraries that do very sophisticated computation with relative ease.

However there are times when you might be using a customized platform (as is often the case) and the platform will already be in some code like C++ which has the ability to be optimized over the whole repository to give good performance.

In the latter case, I would recommend learning C, then C++, and then getting experience working on large and well structured repositories (ie complex and large code projects) . Really really good repositories will give you hell of a lot of experience and viewpoints that often take people many many years to master: you won't get it overnight, but it will speed up the learning process dramatically.
 
  • #8
More than learning a specific language you should try to learn object orientated programming (C++, java, etc..).

Honestly I'd start with java just because the code is run through the JVM which makes it easier to debug. If there is a compile error java is very specific as to what that error is whereas c++ is not so forgiving. Plus documentation for the java api is fairly straight forward to read.
 
  • #9
Matlab is more of a tool than a programming language. It's a very high level application that incorporates many mathematical tools that a physicists or engineer can use. It's used quite a bit by the electrical engineers at the companies I've worked for. If you need to get answers to problems quickly, Matlab is probably the best tool.

A classic programming language would make more sense if the user needs some custom graphical user interface, or if some mathematical process needed to be repeated and/or peformed quickly. At one of the companies I worked for, one of the engineers preferred Visual Basic when he needed to quickly generate a program with a custom user interface, that also involved some math, since he could "draw" the user interface using drag and drop tools, then have Visual Basic generate the code for him. I have the impression that Visual C++ can do similar things, but apparently it's a bit simpler with Visual Basic, or it's just what that engineer was comfortable with.

Shops that have a large library of Fortran code that would take too long to convert, and/or shops where specific speed oriented extensions made to Fortran, will still use Fortran.

Bottom line, is which language you use will depend on what kind of work you are doing and what company or school you're doing the work at.
 
  • #10
Learn Fortran and C++, both are still used very widely in both academia and industry. Other languages like Java, Perl and Python are scripting languages and are not compiled per say for speed, they may be easy to learn and run, but they are very slow in comparison to compiled languages. Matlab is a very widely used tool, and more and more prevalent in industry, matter a fact I use it daily as a scripting tool for plotting gobs and gobs of data that I generate at work. I know people who use it for hard core computation, but it is again slow in comparison to C++ and Fortran.

Now if your looking for a language, Java does not have a steep learning curve and you'll be able to learn the basics quickly. Learn how to program then move up to another language. I did it the other way around, C++ then Java and the reason I did that was to be forced into the more modern OOP paradigms. It has helped my skills immensely.

Now, before everyone jumps on me about Fortran, we use it everyday, some of our codes are built around legacy codes that are written in Fortran and will never be updated to C/C++. We have to link with Fortran libraries and deal with it, would we like to get these code updated, sure, but we don't get paid for that and our collaborators won't do it on their own. Whenever a legacy code is updated, there are errors, unintentional, but they are there, outputs are different, even sightly, but they are significant wen there is a trust factor built over years of use. Learning Fortran is a valuable skill, all of my young scientists and engineers have to learn it eventually because us old-timers will eventually retire.
 
  • #11
Dr Transport said:
Now, before everyone jumps on me about Fortran, we use it everyday, some of our codes are built around legacy codes that are written in Fortran and will never be updated to C/C++.
This is an important point. Groups such as Dr Transport's are funded to make new discoveries. They rarely are funded to rewrite old, trusted legacy code in a modern language. The conversion can be very expensive and will almost certainly be erroneous.

Learning Fortran is a valuable skill, all of my young scientists and engineers have to learn it eventually because us old-timers will eventually retire.
Another salient point. Sometimes the sole reason a project stays with Fortran is because the head of the project has said "we'll switch to <insert other language> over my dead body." You don't have to wait until he dies. Just until he retires. Its amazing how many projects switch from Fortran to C/C++ shortly after some old-timer retired.
 

1. What is the main programming language used by physicists?

The most commonly used programming language among physicists is Python. It is a high-level, versatile language that is easy to learn and has a large and supportive community.

2. Can physicists use any programming language, or are there specific ones designed for their field?

Physicists can use any programming language, but there are specific ones that are designed for their field. For example, FORTRAN and C/C++ are popular languages for scientific computing and data analysis in physics.

3. Are there any advantages to using a specific programming language for physics?

Yes, there are advantages to using a specific programming language for physics. These languages often have built-in libraries and functions that are tailored for scientific calculations and simulations. They also have efficient numerical capabilities, which are important for handling large amounts of data.

4. Is it necessary for physicists to have a strong understanding of programming languages?

While having a strong understanding of programming languages is not a requirement for physicists, it can greatly benefit their research and data analysis. Being able to write and modify code allows for more efficient and accurate analysis of complex data sets.

5. Are there any resources available for physicists to learn programming languages?

There are various resources available for physicists to learn programming languages, such as online tutorials, books, and workshops. Many universities also offer courses specifically designed for physicists to learn programming languages for their research needs.

Similar threads

  • Programming and Computer Science
Replies
4
Views
603
  • Programming and Computer Science
Replies
16
Views
1K
  • Programming and Computer Science
2
Replies
65
Views
2K
  • Programming and Computer Science
Replies
8
Views
866
  • Programming and Computer Science
Replies
15
Views
1K
  • Programming and Computer Science
Replies
7
Views
634
  • Programming and Computer Science
12
Replies
397
Views
13K
  • Programming and Computer Science
Replies
6
Views
1K
  • Programming and Computer Science
Replies
7
Views
1K
  • Programming and Computer Science
Replies
1
Views
462
Back
Top