Take the 2-minute tour ×
Computational Science Stack Exchange is a question and answer site for scientists using computers to solve scientific problems. It's 100% free, no registration required.

I'm entirely new to the notion of computational science, and am looking for a good starting point.

I understand that there's no objectively best language, but I'd like to learn a language that has an unarguably strong and prominent presence in regards to computational science — one considered to have exceptional capability and efficiency.

To start, I was leaning towards modelling related to atom bonding and interactions, with a requirement for graphical representations/simulations.

Do some languages tend to be better for some fields than others (i.e. physics vs. pure math)? Or is choosing a language based on other factors?

I've heard the name Fortran being thrown around a lot.

Suggestions?

share|improve this question

We're looking for long answers that provide some explanation and context. Don't just give a one-line answer; explain why your answer is right, ideally with citations. Answers that don't include explanations may be removed.

1  
C++ and Fortran are well known languages in the community. Recently, you can see a rise in the use of dynamic languages. Often you choose your library and not your language. –  vanCompute Feb 3 '13 at 15:08
5  
I'm reminded of the dictum that Real Programmers can write Fortran in any language. –  hardmath Feb 3 '13 at 18:42
1  
Here is a very similar question with lots of answers: scicomp.stackexchange.com/questions/304/c-vs-fortran-for-hpc –  Ondřej Čertík May 8 '13 at 8:25
1  
"I understand that there's no objectively best language" - precisely, so why not learn to be language-agnostic, so that you can write in whatever language thrown at you? –  J. M. May 8 '13 at 9:01
1  
You have to master English. Without it, you won't get anywhere in Computational Science. –  Johannes May 9 '13 at 14:13

6 Answers 6

up vote 12 down vote accepted

Mostly it comes down to the numerical libraries available to you that will help to accomplish your task. C/C++ have a large number of numerical libraries implemented for them, but being low level languages are not the best to prototype something quickly.

I think to get going quickly towards a solution, I would recommend using something like Matlab or Mathematica. They have large toolset and are very high-level. Most likely, your implementation there will not scale for production use, but it could be a nice playground for trying out different methods. Once you know a path to take, you can always implement something in C/C++ more efficiently.

share|improve this answer
3  
Many people--both inside and outside academia--don't really trust code unless it has at least some minimal automated testing suite. I don't know what the tooling is like for such things in matlab and mathematica, but there are several nice packages for more mainstream languages like Python and C++. –  cjordan1 Feb 4 '13 at 17:54
3  
MATLAB has MATLAB xUnit, but Python and C++ have more (and, in my opinion, better) testing suites. –  Geoff Oxberry Feb 5 '13 at 1:15

Python!

  1. Start off directly using the numpy library, small scripts, and the ipython interactive shell.
  2. Get more advanced with the help of numerous free books and tutorials.
  3. Get more productive using scipy as a frontend to highly performant numerical routines and matplotlib for visualization
  4. Take advantage of well developed and powerful modules for scientific computing as Krypy, FeNiCS and lots of others
  5. Notice, that the smooth transition between flat and object oriented programming and the inherent modularity of Python make larger projects easy to handle.
  6. Make your code as fast as C or Fortran by simply rewriting critical parts in cython. You can also easily include routines written in Fortran or C.

This paraphrases what I think is the best way to approach a problem in scientific computing. Start with getting a hand on the problem by playing around with toy examples in small scripts. Become more systematic and set up a suite of code. Then make your code work!!! Finally, if necessary, do code optimization. Don't reinvent the wheel and don't do premature optimization.

(Additional plusses: Python comes for free - no license issues, large community e.g. on stackoverflow, modules for good programming as unit testing or logging ... )

share|improve this answer

Try Python as described for instance in the book Python Scripting for Computational Science.

share|improve this answer

Python can be a great starting point. Following resource is a great starting point.

http://www.openbookproject.net/thinkcs/python/english2e/

share|improve this answer

Fortran: Matlab like, easy to learn and use and quickly get productive but only good for numerical computing

C++: Difficult to master (will take you years) but used a lot outside of numerical computing (job security)

Python: Recommended a lot these days but too slow for non-trivial work. You'll have write all your underlying computationally expensive kernels in C and then call them from Python which means that you'll have to learn (at least) two languages

share|improve this answer
1  
I would argue that the learning curve for Fortran and C++ are somewhat similar. I picked up sufficient skills in both to solve the simpler end of problems in a matter of a few months each coming from a background of java, matlab, and c#. Depending on what languages someone knows, I could see c++ being much easier to learn than fortran since most large codes out there are written in dated versions. –  Godric Seer May 8 '13 at 13:51
    
@Godric: At ~600 pages the Fortran 2008 standard is less than half of C++11 (~1300 pages) –  stali May 8 '13 at 14:57
1  
@stali, Yes, but for instance I work with approximately a quarter million lines of legacy code written in Fortran77. So I had to learn the style of 77 to be able to work with it, 90-95 to make maintainable changes to it (since common blocks are attrocious), and then '08 to not be stuck over a decade in the past. Fortran, while an old language, has underwent enormous changes over the past decades, and unless you are starting from scratch, learning its legacy is non-trivial. –  Godric Seer May 8 '13 at 15:46
    
@Godric: Yes but the OP is starting from scratch. I dont think anyone is writing or learning pure F77 these days. Just call F77 routines when you have to (e.g., LAPACK subroutines). The only major revision in F2008 is co-arrays, something which C++/Python simply dont have. There are maybe 2-3 compilers that support coarrays so I dont see how you are stuck a decade in the past while using F2008. Perhaps you meant F2003. –  stali May 8 '13 at 18:05
2  
I would disagree with the statement that Python is "too slow for non-trivial work". Indeed, if you write your matrix-vector multiplications (and the like) purely in Python, you're going to have a bad time. The abstraction to some more efficient languages has already been done for you though: NumPy, Scipy probably have all you'll ever need. Or one of the other 50,000 packages. –  Nico Schlömer May 10 '13 at 12:17

Short answer
Learn about the basics of object oriented code through python, and learn about the basics of computer science through C. When you're at least pretty okay with both of those other languages learn C++, because you can do pretty much anything in C++ and make it run quickly (though it takes forever to write).

Longer answer
So, here's the thing: for your first project you'll be in somebody's lab working on somebody else's code. In which case they'll be the one choosing the programming language. Which I personally think is kind of great!

I mean, as a beginner you're not really going to know your ass from you elbow for a while, and, especially when you don't know what you're doing, learning to program can be borrring. Thus, it's good to have the structure and limits that come from working on somebody else's code, and it's good to have the motivation and excitement that can only come from working on a real project.

Still, regardless of whatever language your lab uses (especially if it's Matlab), you should probably learn python, C, and C++. In particular, if you're not coming from a computer science background you MUST read Kernighan and Ritchie's "The C Programming Language". It's 35 years old and gives the distinct impression that its authors were programming on punch cards, but it is that rarest of birds: a timeless computer science book. It will make many things a great deal clearer.

share|improve this answer
    
+1 for this conceptual approach. –  Jan Nov 5 '13 at 6:21

protected by Geoff Oxberry May 9 '13 at 19:01

Thank you for your interest in this question. Because it has attracted low-quality answers, posting an answer now requires 10 reputation on this site.

Would you like to answer one of these unanswered questions instead?

Not the answer you're looking for? Browse other questions tagged or ask your own question.