What I code for making research

It all started with a small, not so known, book: The Lost Origin, by Matilde Asensi. The main character is an expert programmer, and thoughtfully applies his programming experience for decoding a perfect, code-like, language and freeing his brother from an ancient curse. At the time, I was a kid really into the whole Da Vinci Code world, and all of this considered I quickly decided that I wanted to follow the trails of Arnau, the main character of the spanish book. I just needed to make a choice: learn Aymara or become a programmer.

It was 2003, I lived in a zone with no fast internet connection, so my whole life has been dictated by the fact that all the local books store had a couple of books about programming and (strangely enough) no books on ancient and exotic southern american languages. Now, almost 20 years later from my first C manual, I’m a research fellow in biomedical engineering, and, when I’m not giving lectures or talks, I’m mostly focused on carrying out research changing programming languages as soon as i find an excuse to do it.

Now that I decided to start a blog, it seems natural to write my first post by sharing the whys and hows of my use of the different programming languages in my research, with some prediction for the future, about what I’ll try to include in my workflow in the next future.

Data Analysis

Main choice: Python
Starting point: Matlab

As a researcher, my main coding duties relate to data analysis and data visualisation. As a student, Matlab was the standard in the Master program I was enrolled in, so this was obviously my entry point to the world of scientific programming. The language is easy to use, and it makes data navigation and manipulation really user friendly; plus, it is almost a standard in the engineering world and it represents an obvious choice for students, as long as the university pays for the expensive license.

While Matlab excels at the above mentioned data navigation tasks, when it comes to make calculations on big datasets or signals, Python represents a better choice. Pure Python lacks the user friendliness that is often desirable in the university world, but its huge catalog of third party libraries (especially the Jupyter packages) quickly matches (and often surpasses) the capabilities of Matlab also in that sense. It is this variety of already implemented functionalities that makes Python shine in the world of data analysis, whatever machine learning model, filter or deep learning algorithm one needs, there is a really high chance that it has already been implemented and optimised in a Python library.

Data Acquisition

Main choice: C#
Starting point: C#
Alternatives: Python, C++

A similar task that I need to solve when coding in research is acquiring data from different kind of sensors. In order to do so, it is critical to have a fast and reliable connection to the sensor, as well as a fully functional and friendly interface for managing the data stream. All of it considered, the programming language with which I started is C#, especially for its capability of easily design fully functional Windows graphical interface and for the pre-built API that I found for the sensor I was using at the time. The main issue with C# is that it works flawlessly under Windows (being a Microsoft-designed programming language), but it lacks native graphical interfaces for the other operating systems.

Recently, I moved from working on a PC to a MacBook, so I’m guessing I would also switch the language with which I will manage sensors. Choices are the evergreen Python, as well as C++. Both languages allow for cross-platform programming, but they typically require more code to be written for this particular application

Algorithm Programming

Main choice: C, Rust
Starting point: C

This is all about efficiency and speed. At the start of my PhD, I was working on estimation algorithms for extracting the magnitude of muscle activity with optimal properties given by estimation theory. At that point, I had never encountered a condition in which my code was so complex that required some tens of minutes for the elaboration of a simple signal. While there was (and probably there still is) room for thoughtful optimisation of the code, I was writing all my code in Matlab, and it was slow by nature.

From that point on, after the development of the algorithm with the most convenient language I can think of (mostly Python), I take the time to translate most of the heavy methods to C code. While there’s typically a bottleneck given by the Python-C bridge (or whatever other bridge I’m using), this increases the speed of my code of tens or hundreds of times, keeping it under a reasonable threshold run time.

Right now, I’m thinking of switching to using Rust to optimise my algorithms, as Rust typically is easier to code and has very good concurrency and safety features. Considering the fact that C has been my first programming language I guess that this switch will be the toughest one to fully settle in my routines, and this blog, and the posts that will follow this very first will try to document also this journey in studying and applying a new technology.


In conclusion, the world of programming languages has played a pivotal role in shaping my journey as a biomedical engineering researcher. From my humble beginnings with Matlab to exploring the vast capabilities of Python, C#, C++, and now venturing into the realm of Rust, each language has served a unique purpose in my research endeavors.

Thank you for embarking on this journey with me, and I look forward to sharing more insights and discoveries in the posts to come.

Leave a Comment

Your email address will not be published. Required fields are marked *