36
$\begingroup$

MATLAB, Python and R are commonly used in bioacoustics. Whilst all three languages are excellent choices, it is difficult to ask entrants into bioacoustics to learn all three. I have tried to put together a table with a summary of what each language is good/bad at - any thoughts on the scores/ additional rows to add?

MATLAB Python R
How easy/intuitive is it to get started Excellent (totally integrated code and IDE) Medium/Good(Spyder IDE is great but build environments can be confusing) Good/Excellent (R Studio)
Open source No Yes Yes
Price Very expensive (but often paid for in academia) Free Free
Documentation Excellent (consistently comprehensive help files) Good (help depends on package) Good (help depends on package)
Speed (i.e.compared to C/C++/Java and Julia) Slow Slow Slow
Audio functions e.g. opening files etc. Excellent (includes X3 libraries) Excellent Excellent
Signal processing functions Excellent (includes GUI toolbox) Excellent (scipy.signal) Good
Deep learning tools Good Excellent (the default language for Deep Learning) Medium?
Statistics Medium (patchy at best) Medium? Excellent (designed for stats)
Package Management Less choice but easy and integrated Lots of packages - can be confusing Easy in R studio but lots of competing packages
Building UIs (graphical programs) Easy and integrated More complex (and perhaps powerful) with lots of different packages e.g. Tkinter, wxPython, dash (like R shiny) and PyQt. Easy with R shiny
Use with PAMGuard Well developed library to read PAMGuard output Library planned for 2023 Well developed library to read PAMGuard output
$\endgroup$
15
  • 3
    $\begingroup$ How about another row for "Usage with PAMGuard", and one for "Usage for real-time analysis"? $\endgroup$
    – sm1
    Jul 25 at 13:27
  • 4
    $\begingroup$ How about amount of data each can handle (if that's quantifiable)? I prefer R, but sometimes when I have to big a dataset I have to hop over to Matlab to get the job done. $\endgroup$ Jul 25 at 15:40
  • 2
    $\begingroup$ It is not clear to me what is meant under "Speed" in the table, how this would be measured for a language, and why it would be "slow" for all. $\endgroup$ Jul 26 at 17:12
  • 1
    $\begingroup$ Thank you for adding the Use with PAMGuard row. I guess we can thank Doug for this row. $\endgroup$
    – sm1
    Jul 26 at 19:47
  • 3
    $\begingroup$ Consider "GNU Octave" as an open-source MatLab alternative. It's essentially a MatLab clone. Although no GUI toolbox/UI builder or deep learning libraries that I'm aware of. $\endgroup$
    – Rasmus
    Jul 27 at 14:11

8 Answers 8

20
$\begingroup$

I think the most important thing to consider is the task the entrant will actually have to tackle and how it fits with the actual design purpose of the languages. By design purpose I mean the task the language was made to solve. It is often also the task the languag is best at.

  • If the task would be doing statistical analysis and making statistical graphics then R is best out of the box. R was built specifically for statistical analysis and it is very good at it.

  • When you would be doing various things like machine learning, statistics, numerical modeling all at the same time then Python would be most suitable as it is a sort of "swiss army knife" language. The design purpose of Python was to be easy to learn and easy to read general purpose language ie with no particular single purpose in mind. You can do statistical analysis in Python but it is not as nice as in R. You can do numerical modeling in Python but it is not as comfortable as MATLAB.

  • The initial design purpose of MATLAB is in its name "MAtrix LABoratory" and therefore it was made with the aim of numerical modeling in mind.

Also important to consider is the languages used within a research group the entrent will join. If there already exists a good library written in MATLAB then you should learn MATLAB.

$\endgroup$
3
  • 2
    $\begingroup$ I believe "MAtrix LABoratory" should have a Capital T for the 3rd letter. (Too small to suggest as an edit.) $\endgroup$ Jul 27 at 19:19
  • $\begingroup$ unintuitively, it's actually derived from MAtrix LABoraTory $\endgroup$
    – amara
    Jul 29 at 12:25
  • $\begingroup$ @amara: Do you have a reference for that assertion? I'm curious, as the brief history on mathworks.com doesn't mention such a detail. $\endgroup$
    – J W
    Jul 29 at 12:34
12
$\begingroup$

I agree with David, there has always been a split between people on the conservation/ecology side of bioacoustics and those on the engineering/computer science side of things (the same trend holds true across conservation tech from my experience). It's basically down to undergrad/grad curriculum - any biostats class you take, at least in American universities, is guaranteed to be in R. Python was what the coding/programming students took, and when you are young still trying to figure things out it doesn't feel intuitive to take something that seems so distant from your area, despite the fact it does/will. One of my big regrets from undergrad/grad school is not taking Python courses.

So just from this, what people find "easy" and "intuitive" depends on their training, the research lab they were in/people they were surrounded by, etc. The reason I started to (still in the process...) learn Python was because I need to run ML models and if you're doing ML, especially deep learning, Python is the gold standard and R does not really have an environment for that (I think 'medium' is generous in your table, personally). But for the ecological modelling, R is great. I agree with the previous comments from Mirko that it depends on the use case you have and what specific functionality is required for that goal.

$\endgroup$
3
  • 1
    $\begingroup$ The way I've always described it is that R is a hammer and Python is a saw, but I'm so much more comfortable using a hammer that I'll end up using it for a job better suited for a saw. $\endgroup$
    – dtsavage
    Jul 27 at 3:13
  • $\begingroup$ R has both https://www.tidymodels.org/ and https://mlr3.mlr-org.com/ for ML along with their predecessors caret and mlr. I know there's more popularity and likely support for scikit-learn but R does have an environment (assuming that means maintained packages) for ML. $\endgroup$ Jul 27 at 19:19
  • $\begingroup$ I guess I should have specified that Python is particularly good for deep learning, specifically, as in beyond scikit-learn and into tensorflow, keras, pytorch, etc. $\endgroup$
    – Carly Batist
    Jul 29 at 17:50
10
$\begingroup$

I would also argue that Python is NOT easy/intuitive to set up. It requires downloading the languge and a script editor to use, and the best editor to use varies based on the goals of your project. Many pre-packaged tool-kits also require you to have Anaconda, which is its own headache. There are just multiple steps, and it isn't entirely clear what you need for a project until you reach a level of compedency with the language and its structure. If it has been a few months since I used Python, I still reference this Django Girls tutorial to make sure that I'm not missing anything, and again, that doesn't cover Anaconda.

Secondly, I think the real question may be Python v Matlab, while R is really best for data organization and statistics. I know a lot of data scientists are keen on Python packages such as numpy and pandas, but they still have nothing on R as far as I am concerned.

$\endgroup$
1
  • 2
    $\begingroup$ Good point. It can be very confusing. Think I will change the first column toGood/Medium to reflect that R is easier to set up… $\endgroup$
    – user213
    Jul 27 at 7:52
9
$\begingroup$

Comment: signal processing in Python is pretty neat with lots of stuff covered in the scipy.signal module (custom FIRs, standard band/high/low pass filters etc).

About speed: 'slow' in comparison to what? 'Close-to-metal' languages like C/Cpp etc aren't really the daily coding language for most bioac researchers is my guess. Also, at least in Python the heavy-lifting of numerical routines is often done by optimised calls to established C/FORTRAN libraries (cBLAS, LAPACK) - and my suspicion is the same is done in R too.

Another column to possibly add is which fields/communities use which language. I often find that commercial products like MATLAB are predominantly used by university engineering departments and companies. I wonder if there's such a segregation of language usage even within bioacoustics (conservation bioac people using more open-source tools vs uni based researchers using commercial tools?).

$\endgroup$
4
  • 2
    $\begingroup$ Thanks @Thejasvi. I will chnage Python signal processing to excellent. I guess all languages are slow compared to Java/C/C++ etc, however, also Julia which a is more a daily language. Although there is some optimization I consistently find other languages have a x10 or greater processing performance - that can (sometimes) be important when analysing large datasets. Interesting thought on the language segregation - I imagine you are correct but I have nothing but anecdotal evidence on that. $\endgroup$
    – user213
    Jul 25 at 9:20
  • 1
    $\begingroup$ @JamieMacaulay Nice question, but on the speed issue, given some of the rows offer a relative assessments anyway, are you able to differentiate between the different types of "Slow"? $\endgroup$
    – EcologyTom
    Jul 25 at 17:53
  • 1
    $\begingroup$ Yeah, I guess slow compared to C/Java. I agree it seems a bit silly to compare, however, there is a new language, Julia, which is as easy to use as R/Python/MATLAB but as fast as Java/C - therefore I thought it was worth mentioning that these are relatively slow languages. Not sure how they compare exactly, but anecdotally, I've never found one to be particularly faster than the others. $\endgroup$
    – user213
    Jul 26 at 8:02
  • $\begingroup$ I agree with this assessment. When it comes to signal processing, MATLAB is notably faster than R or python in trials I have profiled. Comparing in relative terms for how it's used in the field, I wouldn't call MATLAB 'slow'. $\endgroup$ Jul 27 at 18:08
9
$\begingroup$

I would add a row that describes graphics, especially interactive graphics. Whenever I try to work with python (or jupyter) I fall back to Matlab for easy use. OK, I'm somewhat spoiled.

I also would add a row that describes easy extension of functionality. For Matlab you have only some basic choices (that also cost something), but if I see all the free packages that one could download for python I get confused.

Consequently I would add a row on consistency of SW packages. With all the different competing packages, that require different versions for dependencies, learning becomes difficult. Especially, as it is so easy to "conda install ..." and then nothing woks anymore, because of version mismatch. IMHO, Python, (Ana/mini)conda is a little bit too flexible.

I also would add a row on API for calling c/c++ extensions.

I definitely would like to see how R behaves under these aspects

Edit: One other aspect to consider is availability of easy to use bioacoustic examples (as we are here on bioacousic SE)

$\endgroup$
2
  • 3
    $\begingroup$ As an R user who then started using Python, I can attest that honestly one of the hardest things to figure out was package managers/environment managers/version control/etc. $\endgroup$
    – Carly Batist
    Jul 25 at 20:59
  • 1
    $\begingroup$ Good ideas! I think graphics wise there are good options for Python and R (shiny apps shiny.rstudio.com). C/c+ can be called by just about anything these days. $\endgroup$
    – user213
    Jul 26 at 8:03
6
$\begingroup$

A lot of the choice simply comes down to one's comfort zone. My research group works primarily in R, not necessarily because R is the best choice in some objective sense but because we are all ecologists and R is the language most of us know best (and is, therefore, the language most of us feel most comfortable teaching to others). Different fields will have different backgrounds and areas of comfort.

$\endgroup$
1
  • 1
    $\begingroup$ Yes, totally agree - however, students often come to large institutes where folk are using all three languages. I guess this is a guide to try and help them figure out where to start in that case. $\endgroup$
    – user213
    Jul 27 at 7:51
4
$\begingroup$

I like it. I would add two more rows:

  1. Dedicated bioacoustics tools

  2. Scalability (scaling up data analyses to terabyte-scale datasets often requires moving computation to high performance computing “clusters”, parallelizing tasks, and in the case of Deep Learning, moving work to GPUs.)

$\endgroup$
3
  • 2
    $\begingroup$ Thanks - Those are good ideas except I don’t have a good list of all the bioacoustics toolboxes for all and I have never tried scaling any of these beyond running on multiple processing cores. If you can provide the info I could add? $\endgroup$
    – user213
    Jul 27 at 7:50
  • 1
    $\begingroup$ Though your comment is useful, it is not an answer. As such you should rather add it as a comment to the question. $\endgroup$ Jul 28 at 16:39
  • $\begingroup$ Agreed, and as of today I have enough "reputation" to make comments :) @JamieMacaulay here's a list of bioacoustics software github.com/rhine3/audiomoth-guide/blob/v1.4.4/resources/… I'm not sure about scalability in R or MATLAB, though I don't think they generally scale as easily as python $\endgroup$
    – Sam Lapp
    Jul 29 at 23:20
4
$\begingroup$

Anyone looking to learn one language of the three should choose R or Python over MATLAB in current year, for the simple reason of how much dealing with licenses is a nightmare for portability of computing, sharing methods, and experimentation.

For a seasoned bioacoustician, and from an institutional point of view, all three have their uses and should be be made available as such.

$\endgroup$