These days it’s not uncommon for psychology researchers to work on projects that involve some degree of technical know-how, whether it’s for building experiments or performing data analysis. With such technical experience becoming increasingly necessary in psychology, many researchers are now considering programming as a very relevant skill to learn.
Unfortunately, it can be difficult knowing where to start when learning to program. I’ve spoken to many psychology researchers who are interested in learning but don’t know where to begin or are unsure which programming language is best suited for their needs.
In this article I’ll go over which programming languages are best suited for psychology researchers and how each language can be adapted to help you achieve specific research goals. If this still feels like too much to process I’d suggest trying not to overthink it as any of these languages will be sufficient for getting you started.
What this article is not
This won’t be a technical article, instead I simply want to make sure that you have a solid understanding of which programming languages are best suited for psychology researchers.
Hopefully this will rid you of any doubts about choosing which language to learn and will give you peace of mind in knowing you’ve made an informed choice.
Which programming language is best to learn?
There is no single answer to this question. Generally speaking, any language should teach you the fundamentals of how programming works. These fundamentals will be applicable to most other languages you decide to learn thereafter. Having said that, different languages do specialise in different areas so if you have a particular interest or focus then this post will hopefully narrow down the scope of which language is best for you.
The benefits of learning to program
Programming can be extremely desirable to future employers and can boost your CV. Programming also teaches new and interesting ways to solve problems through logical thinking. Knowing any of the languages I’ll discuss here will also give you a head start in applying your skills outside of the research environment, which is handy if you ever decide to switch career.
Top five programming languages for psychology researchers
Before jumping into my recommendations, I’d like to quickly comment on the topic of how to actually start learning to code. Some people like to dive right in at the deep end and just start coding. This might work for a few individuals, but I’ve found this often puts people off coding because they get stuck too quickly and become frustrated. My advice would be to take things slow, start right from the beginning and learn the core concepts (e.g. data types, variables etc.) before taking on your first project. Any decent programming tutorial will do, but the point is to learn how to walk before running straight into a brick wall of code that doesn’t make sense!
With that out of the way, let’s take a look at my first recommendation.
HTML organises content
<p> some text </p>
CSS adds styling
var str1 = ‘Hello’;
var str2 = ‘ world!’;
var res = str1.concat(str2);
The final output
There are other solutions similar to Inquisit which I have discussed in a previous article here.
Python is one of the most popular programming languages in the world, and for good reason. Its simple syntax makes it a good choice for beginners. Python is also a general-purpose language with lots of versatility. This is great for psychology researchers because it covers two very important aspects of research, building experiments and analysing data.
Python is often used for making GUI desktop applications making it well suited for building psychology experiments. This process is made easier with PsychoPy which is a software package designed specifically for building experiments in Python. PsychoPy uses much the same syntax as core Python but with added features that streamline your workflow. This makes it easier to display stimuli, record user input, and store results.
Python is also great for data analysis and is a top choice for many data scientists. Most of the time you’ll see data being analysed with Python in a coding environment called Jupyter Notebooks. This is simply an interface that makes it more convenient for loading datasets and organising your code. The general workflow involves loading in data (usually a csv file) and typing commands for inspecting and analysing your data. I think this is a great option if you want to transition away from SPSS.
R is primarily used for data analysis. It’s up there with python as one of the most popular choices, and people often argue over which one is better for analysing data. I won’t dwell too much on that argument here, but see below for my own brief viewpoint.
R is great for all types of analyses, whether you’re building a simple linear model, conducting complex Bayesian statistics, or running machine learning algorithms. The syntax of R takes a bit of getting used, but after a short time learning you’ll see that it’s not really that bad and can be picked up rather quickly. R particularly shines when performing more complex stats like multi-level models that can be rather cumbersome in other environments such as SPSS. One tip is to use a software package called RStudio to organise your code better.
Interestingly, there’s a bit of an R revolution occurring. An increasing number of psychology academics are transitioning their data analyses over to R as a replacement for more traditional analysis packages like SPSS. There’s good reason for this, not only is R completely free but it’s also incredibly flexible. An abundance of downloadable packages means that R can handle almost any analysis you throw at it.
I tend to agree that there are many advantages to using R, although many researchers have spent their entire careers getting used to the convenience of SPSS and may not find the transition towards a programming workflow so smooth. Only time will tell how the R revolution will change the face of data analysis for psychology research.
RStudio is an interface that makes it easier to organise your R code
R vs. Python: Which language is best for data analysis?
Everyone has their own opinion on this. The truth is they are both great for analysing data so don’t stress about the choice. R has the advantage of being popular for psychologists, and it’s gaining momentum, so you are more likely to be able to collaborate with your colleagues on projects. On the other hand, Python’s worldwide popularity and general-purpose nature makes it a great choice for building all kinds of applications (it’s not just restricted to data analysis) and there are plenty of tutorials and resources out there to help you get started with Python.
Out of all the languages I’ll discuss in this post, MATLAB will arguably be the most well-known to psychology researchers. You may have even been taught a bit of MATLAB as part of your psychology degree. The reason MATLAB has more of a history in psychology research is because it can be used for building experiments as well as analysing data. It’s even widely used in neuroscience for analysing brain images, giving it an edge in this department over other programming languages.
Building experiments in MATLAB is achieved with the help of a package called Psychtoolbox. This gives you access to a convenient collection of functions for streamlining the entire process of building an experiment. In other words, Psychtoolbox makes it easier to set everything up including displaying on screen stimuli, recording user input, and storing participant results.
MATLAB is also a popular choice for data analysis because of the way it efficiently handles your data. In MATLAB all variables are stored as multidimensional arrays making it more efficient when performing matrix computations for linear algebra. This may not be the type of analysis you’ll be conducting (although it might be), but the point is that MATLAB has a powerful set of core features and built-in algorithms that make it appealing for analysing and processing large amounts of complex data.
The downside is that MATLAB requires a license to use, so it doesn’t have the added appeal of python or R as a free product. The good news is that if you’re using MATLAB as an academic your institution may provide a license already, so you don’t have to pay anything yourself.
C# is another general-purpose programming language that can be used for building many different types of applications. For psychology researchers, C# can be especially useful for building highly interactive online and offline experiments, in both 2D and 3D. In fact, C# is a big player in the indie video-game market. You could think of psychology experiments as being a lot like games themselves, with participants interacting with elements of your experiment in all kinds of different ways.
The beauty of using C# for building experiments is that you can achieve complex animations and impressive effects more easily compared to other programming languages. The ease with which you can build such experiments (or games) is achieved with a software package called Unity. This is just an environment that makes it much easier to add all the content, features, animations, and effects to your application. You build the visuals of your experiment in the Unity editor and write C# code to add functionality. When you’re done, you can even compile your experiment to work on both desktop and cross-platform mobile which saves you from having to learn how to code for both iPhone and android!
For those of you who are a bit more into the programming side, C# may be interesting to you because of the way it encourages code organisation. C# is typically written in an object-oriented style which some consider to be a more natural way of organising code into discrete entities that represent the way we think about the world.
C# and Unity are free so it’s a great choice if your experiment requires more complex animations. Just be aware that data storage will also need to be handled, so I’d encourage you to check out Firebase for a great database solution.
I said at the start of this post that there is no ‘best’ language. While this is certainly true, I thought it might still be beneficial to give you my own personal take on which languages I tend to favour. Everyone has their own personal favourites, and these are just my opinions that you may agree or disagree with.
I’d suggest choosing either Python or R. They are both great at analysing data, so it doesn’t really matter which one you go with.
These were my top programming language picks for psychology researchers. I’ve given you five choices to consider along with my own personal preferences. Hopefully you can now make more of an informed choice about which language to choose.
Good luck starting your programming journey!