Programming Language for Physicists: Which is Most Important?

Click For Summary

Discussion Overview

The discussion revolves around the importance of programming languages for physicists, exploring which languages are most beneficial for computational tasks in physics. Participants share their experiences and opinions on various languages, including C, C++, Fortran, MATLAB, and others, as well as the relevance of numerical methods and programming paradigms.

Discussion Character

  • Debate/contested
  • Technical explanation
  • Conceptual clarification

Main Points Raised

  • Some participants suggest that learning C provides a foundational advantage for understanding other programming languages, while others caution against BASIC due to its limitations in more complex applications.
  • There is a discussion about the "learning curve" associated with different languages, with some arguing that languages with a steeper initial learning curve, like C and C++, offer long-term benefits.
  • Several participants emphasize the importance of numerical methods and handling floating point arithmetic, noting that while libraries in languages like MATLAB and Mathematica can help, foundational knowledge is crucial.
  • Some contributors advocate for the use of MATLAB, Maple, or Mathematica for mathematical modeling due to their extensive libraries, while others argue that traditional programming languages are necessary for custom applications.
  • Fortran is mentioned as a critical language in both academia and industry, particularly for legacy code, with some participants highlighting the challenges of transitioning from Fortran to modern languages.
  • There are differing opinions on the utility of Java, with some suggesting it is easier to learn due to its debugging capabilities, while others prioritize C++ for its performance and object-oriented features.
  • Participants express varying views on the role of scripting languages like Python and Perl, noting their ease of use but also their relative performance limitations compared to compiled languages.

Areas of Agreement / Disagreement

Participants do not reach a consensus on which programming language is the most important for physicists. There are multiple competing views regarding the advantages and disadvantages of various languages, as well as differing opinions on the necessity of learning specific languages based on individual needs and contexts.

Contextual Notes

Some discussions highlight the dependence on specific applications, project requirements, and the existing codebase when choosing a programming language. The conversation also reflects the challenges associated with legacy code and the potential errors involved in transitioning to newer languages.

Who May Find This Useful

This discussion may be useful for physicists, engineers, and students interested in computational methods, programming languages, and numerical analysis in scientific research and applications.

go quantum!
Messages
54
Reaction score
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
Learning a little C gives one a leg up on just about all other languages...except BASIC.
 
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:
Makes you wonder what we will be coding in when the software arrives for the true quantum computer. Brave new world.
 
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.
 
I primarily use C, C++ and Maple for modelling. Fortran is also one to look into.
 
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.
 
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.
 
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.
 

Similar threads

Replies
86
Views
3K
Replies
4
Views
3K
  • · Replies 25 ·
Replies
25
Views
2K
  • · Replies 102 ·
4
Replies
102
Views
4K
Replies
16
Views
3K
Replies
65
Views
5K
  • · Replies 8 ·
Replies
8
Views
3K
  • · Replies 43 ·
2
Replies
43
Views
8K
  • · Replies 6 ·
Replies
6
Views
4K
Replies
38
Views
4K