1
$\begingroup$

I was wondering which programming language is most used in the geosciences? I have now started programming with Python but I am reading more and more about R! I would like to ask the experienced scientists which language they use and especially why? I would also like to know if there is a general consensus on this question in the climate and earth science community!

$\endgroup$
7
  • 3
    $\begingroup$ I don't think this is a question for Stack Exchange because it's 100% opinion-based. But FWIW, I wrote this on the subject last year > agilescientific.com/blog/2021/4/8/… $\endgroup$
    – kwinkunks
    May 24 at 13:13
  • 4
    $\begingroup$ I agree it's an interesting question, but Stack Exchange is not a discussion site. $\endgroup$
    – kwinkunks
    May 24 at 13:33
  • 1
    $\begingroup$ @kwinkunks I know nothing of earth science, and I even only just joined this community. I just wanted to chip in on this conversation: assume the question was "Python or Assembler, which one should I use?", would you then also say it's opinion based? No, of course not. No one in their right mind would advise Assembler, because Python has a bunch of useful libraries for this kind of stuff. A harder, but similar question is Python vs. R. It's a question that can be answered by rational arguments such as easy of use and available libraries. Also: what is the industry standard? $\endgroup$
    – Opifex
    May 24 at 23:12
  • 2
    $\begingroup$ I find this question not to be opinion based. Remove "commonly" and we have a question that might be hard to answer but has a definitive answer: Which programming language is the most used in geosciences? $\endgroup$
    – J. Fregin
    Jun 6 at 16:09
  • 2
    $\begingroup$ I think the intention of this question is valid, but the way it's being asked is too broad and presumptive. It should mention the range of tasks you want to accomplish programmatically, and offer your observations of programs you've run into (e.g. python and R). Then ask "Which programming language is most used in the geosciences to accomplish these tasks and why". $\endgroup$
    – f.thorpe
    Jun 8 at 0:47

3 Answers 3

6
$\begingroup$

In my opinion, python is a more established global language that is used by many more disciplines/users, compared to R. This can be advantageous because examples/tutorials are everywhere and you can accomplish many programmatic tasks in one environment. On the other hand, R has a very strong user-base that is specific to data analysis and display. So, most of the users are in science or math disciplines and know how to get those tasks done well. Specific to geosciences, python has historically been linked to GIS work, which is an important legacy. The python packages (e.g. geopandas) handle GIS work very easily and quickly. But, if you want to get some really nerdy display stuff done with live data, most of my colleagues would recommend R for on-the-fly calculation and display.

$\endgroup$
5
$\begingroup$

Python implemented weather models also exist - PACE Weather Model.

I am going to take a slightly different view than the other answers. For weather forecasting models Fortran 2018 with it's strong HPC links is the best solution out there.

But what about post analysis of data ? Here due to the easy availability of libraries such as numpy and scipy(and well tested as well) python is the best alternative out there. No doubt such alternatives do exist in the R world too but I have just not seen any large scale adoption of that language in the meteorological community. Thre is an AMC AMC Annual Python Conference dedicated to advances using python language.

Finally from a personal perspective existing libraries that deal with weather model code (finite differences or spectral models such as GEMPAK or SPHEREPACK) are in fortran. But an individual researcher can easily use a utility such as f2py to combine the best of both languages and incorporate these libraries into their work.

In fact the libraries numpy and scipy themselves use C and the Cython interface to speed their libraries.

$\endgroup$
4
  • $\begingroup$ Is PACE running operationally anywhere? $\endgroup$
    – Whir
    May 24 at 10:29
  • $\begingroup$ @Whir you can ask them. The docs clearly state this is a work in progress. OP's question was not about operational code. Which programming language was most used in the geosciences was the question. I have given a reasonable answer. $\endgroup$
    – gansub
    May 24 at 11:23
  • $\begingroup$ I have not given you any reason to defend your view. It was just a simple question out of curiosity. $\endgroup$
    – Whir
    May 24 at 18:09
  • $\begingroup$ @Whir Aah ok. Apologies then. So you know in meteorology things take a while to go from research to operational work. I know of no operational usages of PACE. But some pirivate companies or research institutions may well be running it. Best is to ask the authors as I mentioned initially. $\endgroup$
    – gansub
    May 25 at 0:56
4
$\begingroup$

Essentially there is no consensus. To some degree it comes down to personal preference but it also depends on the application - what needs to be done.

Python is a very popular language and for smaller scale scientific usage it is a good language. The main negative concerning Python is it's speed of processing. Its speed of calculation is slow. If you have a large data set or need to perform complex calculations, I would not recommend Python. Python is a good language for proof of concept purposes or small tasks. For larger data sets or for complex calculations, a faster language is required. Weather forecast modeling is not done using Python.

In some situations Fortran is still used. Despite its age and most people complaining about its style of programming, it still has applications. Failing that, heavy duty computations are sometimes done using C or C++.

Complied languages tend to be faster than interpreted languages. A newer, scientifically orientated, language which is generating interest is Julia. It's slightly slower than Fortran and C, but much faster than Python.

The R language was initially written as a statistics analysis package, and that is still its forte.

A Comparison of Programming Languages

Speed in Matlab vs. Julia vs. Fortran

$\endgroup$
5
  • $\begingroup$ This is a good condensed answer, but I would add that the major disadvantage of R is its terrible way of handling dependencies - even though some argue it is its strength, it is really a hassle compared to python, nodejs and even java. Weather models are to this day still mainly Fortran, but Julia have some features that makes it interesting in geosciences, namely that you can take the derivatives of the code directly (arxiv.org/abs/1607.07892) $\endgroup$
    – Whir
    May 23 at 20:13
  • $\begingroup$ Agree with this well. Weiss you mention models, solid ones are computing intensive... so would think most are in languages like Fortran and C (they certainly used to be). Whereas simplistic ones I worked on used programs like matlab for ease of work. $\endgroup$ May 23 at 20:50
  • $\begingroup$ @JeopardyTempest I strongly recommend NOT to use matlab. You can't do anything serious with parallelization. It costs a fortune that no company with just a little technological sense should be willing to pay with so many open-source alternatives. I know matlab is often used at universities and the new staff we get in that relied on matlab are also the ones with a huge knowledge gap that they need to put a lot of efforts into minimise. $\endgroup$
    – Whir
    May 24 at 10:29
  • 7
    $\begingroup$ "Python is slow" is, respectfully, a rather superficial take. Python is demonstrably fine for lots of large, computationally intensive tasks. For example, it's used all over the place in computational geophysics and astrophysics on ginormous datasets. Code is faster to write and debug than Fortran or C, and besides the numerical stuff is implemented in Fortran via LAPACK, LINPACK etc, just like it is in MATLAB and of course most Fortran programs. Add Numba, Jax, Dask and all the CuPy stuff, and the speed of native CPython is just a huge non-issue. $\endgroup$
    – kwinkunks
    May 24 at 16:24
  • $\begingroup$ @Whir I certainly wasn't suggesting matlab... back 20 years ago the shiny new programs like Mathematica and Matlab were things some of the researchers were dabbling in. It still goes to show the wider idea that there are many programs people use, and for my major professor back in the day, Matlab was key, and it still has its uses in other fields it sounds like. But I am a supporter of more open software. $\endgroup$ May 24 at 20:03

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