This is not a fair, even-handed review of all possible languages for all purposes. The intended audience is undergraduate psychology students who cannot code.
What is coding?
Why learn to code?
Excellent arguments are made in this person’s blog post “Why every (psychology) student should learn to code“. The main points are:
- If you want to conduct research at MSc or PhD level onwards, then coding is highly advantageous, if not essential.
- If you don’t want to conduct research, then it will (probably) benefit you anyway.
But you should go read that blog post… Common to both 1 and 2, is that having this ability on your CV will really make you stand out. There are lots of people who have degrees in Psychology, Neuroscience, or similar, but the combination of having a degree like that and knowing how to code is rare. I would also add, this grandiose sounding, but not actually overblown statement:
Coding teaches you how to think.
Then again, so do a lot of other things. But if I’ve not convinced you, then here are some people in a flashy video who agree…
Too many options, help!
There are many programming languages out there, so how are you to make an informed decision? Well don’t let that array of options cause some paradox of choice-induced indecision. Learning a programming language is not like getting married. Once you’ve learnt the core ideas of how to code in one language, you can pick up another language pretty quickly. That said, there are some core programming concepts (such as object oriented programming) which are not available in some languages, such as BASIC. I taught myself to program (as a lot of my friends did) when I was 8 using BASIC on an Archimedes A3000, a computer that was popular in schools at the time. As you can tell from this video, BASIC played it’s role for that generation, but now it’s dated and not a serious option.
It’s taken me much longer than it should have to understand the concepts behind OO programming – I wish I’d done this learning at the start. So you don’t want to learn a programming language which is too simple – you won’t be served in the long run.
Before getting down to details of what language, it’s insightful to place them all on an axis of ‘level of abstraction’. On one end of the continuum you have a person who wants to make the computer do something. These humans speak English, or something similar. At the other end is the computer. It moves electrons around to compute stuff. There is a large gulf between the two, and bridging this gap is the job of the programming language.
There is no single correct programming language. It depends on what you want to do. If performance and efficiency are your key aims, then you’d want a programming language which is as close as possible to the raw computations conducted by the CPU. An example of such a low level language would be Assembly language, where the instructions you write are really not very far off of speaking binary. I did this a while back and it was intellectually very interesting. It also makes you feel like Neo in the Matrix, but if you want to get something done, and not disappear up your own arse, then do not even consider Assembly language. Here is a 1 hour video tutorial of Assembly Language, which I forbid you to watch. The only time you really need this is when you are working on time-critical, resource limited situations, like a guided missile system or a interstellar satellite for example. Maybe a quant in the City writing high frequency trading algorithms might use Assembly, but probably not, it would take too much time away from counting their money.
I’m not going to review all the options here, I am steering you towards a solution that will get the job done. But, we know so far that we do not want a very low-level language. Ideally we would be able to use a very high-level language and actually speak into the computer in English and it would do what you want. Maybe this will happen one day, but at the moment, nope. So what you want then is a high-ish level programming language where the job of translating the ideas in your head to instructions the computer can understand is as simple as possible.
Options I am removing from consideration are C++ and JAVA. These have their place and are very very popular. But for me they represent solutions which are too low level. They are fast etc, but that is swamped by the extra overhead you have in writing the code. You want a higher-level scripting language. You want to be able to flesh out what is in your mind into some working code quickly.
Here is the palette of possible languages I am suggesting that would be good to learn as an undergraduate psychology student. You can go off and investigate these for yourself, but here is an ultra-brief overview.
R is a widely-used and respected free programming language used for statistical data analysis. This is great if you want to code so you can analyse data using more cool methods than everyone else using SPSS etc. Why are we still teaching undergraduates SPSS? Maybe I will investigate and report back in the future.
Matlab is a non-free package. I have used it for about 15 years, and it’s served me well. It’s easy to learn and very flexible for many different purposes. But as I’ve mentioned previously, I’m saying goodbye to Matlab.
Again, not a free language. This is new, and perhaps not even released yet. It has some cool functionality, some of which may be novel to Wolfram, but I am not sure.
In a previous post I mentioned why I am learning Python. I think it’s got some nice features which will serve me well, buy also suspect that it would be a good first language.
What is your goal?
As I said, there is no single best programming language. It entirely depends on what your aims are.
Aim: I just want to do awesome stats and maybe ‘big data’
One way might be to start with what you know (maybe SPSS) and then learn it’s scripting language (called syntax). However, you would technically be known as a ‘loser’. Instead a sensible option would be to investigate R. But, Python lets you do everything you can do in R and more [citation needed :)].
Aim: I want to do ALL the things.
Types of programmers
I’m going to finish off by providing some links to get you started with. But before, let’s just get clear that there are different types of coder.
As soon as you start, you will be able to call yourself a coder. But at this first stage you can wear a badge that says “user of packages.” This is a little like if you are trying to build a tower out of lego. You have a number of types of lego blocks at your disposal, these blocks are packages that other people have written and have made available for others to use. There are many types of blocks, and you can construct elaborate castles by using the blocks in different combinations. But then you might need to to do something that cannot be done with the existing set of blocks. Then you need to start developing your own blocks, or packages, and now you have taken a step up to become a developer of packages.
Many people will just keep their own packages to themselves, but the beauty of the whole approach is that many people develop things of use, and then make them available to the wider community. This is part of the nice, open-source, human aspect of coding: everybody wins. Large or very popular packages are often built, maintained, and upgraded by teams of people distributed over the planet.
Some people then go on to become ‘core developers’ and work on improving and upgrading the actual language itself.
How to learn
Here are a few pointers to get you going.
Where to learn Python
- My previous post on getting started installing Python
Where to learn R
You can do it 🙂