Programming language

  • #1
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?
 

Answers and Replies

  • #2
595
0
Learning a little C gives one a leg up on just about all other languages...except BASIC.
 
  • #3
161
55
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
161
55
Makes you wonder what we will be coding in when the software arrives for the true quantum computer. Brave new world.
 
  • #5
737
0
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
chiro
Science Advisor
4,797
133
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
1,341
3
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
rcgldr
Homework Helper
8,774
572
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
Dr Transport
Science Advisor
Gold Member
2,523
649
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
D H
Staff Emeritus
Science Advisor
Insights Author
15,415
687
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.
 

Related Threads on Programming language

Replies
11
Views
1K
  • Last Post
Replies
2
Views
912
Replies
18
Views
3K
  • Last Post
Replies
13
Views
3K
  • Last Post
Replies
15
Views
4K
  • Last Post
Replies
1
Views
3K
  • Last Post
Replies
18
Views
9K
  • Last Post
Replies
15
Views
3K
  • Last Post
Replies
12
Views
3K
Top