A common question from people starting out with the Raspberry Pi is “which programming language should/can I use?”

The answer is “pretty much any of them”. Assuming you’re using Raspbian, or some other recent Linux based distribution, it’s likely that there is at least one compiler/interpreter available for any language you want.

The exceptions to this are some of the newer, proprietary, OS-specific languages, like Swift. Notably, the .NET framework languages are available, due to some incredible work by the Mono project teams.

To make the point, I thought I’d list the April 2018 Tiobe Index of the top 20 languages and their availability for Raspbian.

But first, here are two languages to consider strongly when you're starting to program on the Pi, which don't appear on the Tiobe top-20 index.

Bash/shell

You have Bash available already, almost anywhere you go in Linux world. It’s what you get on most Linux machines when you open a terminal. Bash is a the most popular of the Shell languages - there are many others, but for starters, learn Bash.

Scratch

This is a Pi specific language. It comes as standard with most installs and is intended as an ideal starter language for anyone learning to program, who has a graphical display available.

There is a Pi specific Scratch learning site which is a good place to start.

Anyway, onto the Tiobe index list...

1. Java

installation: apt install default-jdk

That’ll get you the default Java environment (Java8 for Jessie/Stretch versions of Raspbian). If you want a specific JDK version, do apt-cache search openjdk and pick the version you want.

Dunno what else to say really - it’s Java. It’s not amazingly cool or modern, but it works and loads of people use it to build loads of stuff. If you’re a professional coder, you probably know it to some extent.

2, 3, 18. C, C++, Objective-C

installation: apt install clang and/or apt install gcc

I’ve listed these 3 as the same “language” because as far as installing compilers for them - they are the same.

There are two main compilers in the Linux world these days, Clang/LLVM and GCC. Linux distros often make a decision on one of these to be the default that they use for compiling their world. Raspbian appears to have gone for installing both by default, so you probably already have both of these unless you chose a very minimal install option.

Actually neither of these is “just” a C compiler. Both have grown over the years to support a ridiculously large number of languages via various modules that an army of very bright and keen developers maintain and improve continuously.

4. Python

installation: apt install python for Python 2, apt install python3 for Python 3

You definitely have Python 2 already installed if you’re using Raspbian. Python 3 is the new version (well, it’s pretty old and stable by now), so you should probably use it for any new code you write. Python 2 is only needed because it was used to help build the Debian world, along with C, many years ago.

If you are new to Raspberry Pi programming, or programming in general, and the graphical Scratch language I mentioned above doesn’t appeal - then Python is probably the best place to start. There’s a huge number of tutorials, articles, guides and code out there to help you along.

5. “C#”

installation: apt install mono-complete

Although C# is part of the Microsoft .NET stable of languages (I’ll be mentioning more of them below) and as such is only really intended to run on Microsoft’s OS and integrate with Microsoft products, a few bright sparks have managed to reconstruct large parts of the .NET ecosystem separately, outside of Microsoft’s control.

That reconstruction project is called Mono and covered both a large chunk of the .NET libraries and a number of the languages. So, thanks to Mono, you can both write new stuff in .NET languages, and run some existing .NET stuff, without becoming completely dependent on Microsoft’s warm embrace.

And yes, those quotes seem to be necessary, Markdown gets a bit muddled by hash signs.

6. VB.NET

installation: apt install mono-vbnc

See, I told you we’d be mentioning Mono again as part of .NET languages. I haven’t checked, so it may be that mono-vbnc is installed as part of the mono-complete package I mentioned in the C# section.

7. PHP

installation: apt install php5

Yup, you read that right, ‘5’. Although PHP 7 has been out for a while now (since the end of 2015) it appears the default Raspbian package is still version 5. So if you want to use PHP seriously on a Pi, you probably need to do a bit of apt source fiddling to get a version 7 repository in your lists.

8. Javascript

installation: apt install nodejs

This will install Node JS, which is a JS interpreter for writing code to run on the local machine, rather than being downloaded and run in a browser. If you just want to write JS to run in a browser, just install your preferred browser instead.

Other server-side JS engines do exist, and some other languages have JS engines embedded within their tools (e.g. Java - Nashorn and Graal). But Node is the most common, there’s a wide range of tutorials, articles and guides about it and it’s acknowledged as a very speedy and reliable engine (as far as Javascript goes).

9. SQL

installation:  it depends 

SQL is more a family of languages, each one specific to a database, or family of databases. Although there is set of SQL standards, each DB tends to have its own little variations and interpretations on those standards - or in some cases, just plain screws things up.

So there’s no single installation process, you’ll get it as part of the DB you chose to use. Picking which DB to use is a whole other can of worms!

10. Ruby

installation: apt install ruby

Ahh, back on easier ground again. Ruby 1 is currently the default install, although the ruby2.1 package will install Ruby 2 (surprise!).

11. Pascal (in various forms)

installation: apt install fpc or use GCC (see number 2)

I think of Pascal as a kind of spiritual ancestor to Python. It’s a fairly simple language to start using, it used to be a common language for teaching programming and it’s been modified, extended and re-purposed in so many ways that you find bits of it everywhere.

In this case, “Free Pascal” and “GNU Pascal” are compilers for different versions of the language. FPC is focused on supporting Turbo Pascal and Delphi variants whereas GPC focuses on implementing the ISO standardised language.

There is also a Pascal specific IDE called Lazerus (apt install lazerus, natch) built by some enthusiasts of the obsolete but well-loved Delphi IDE.

12. R

installation: apt install r-base

I must admit I know nothing about this language other than it’s heavily maths/stats oriented. But hey, there’s a mass of tooling for it in Raspbian, so go for it if it does what you need. Given ‘R’ is a pain to search for, it might be worth using “cran”, “r-cran” or “cran-r” in your package searches.

13. Visual Basic

installation:  Put down the mouse and step away from the keyboard 

VB is specifically designed for Microsoft OS’s. Actually only for very obsolete Microsoft OS’s. Seriously, even MS doesn’t support this any more, please don’t write any new code in it. Pick Python, Ruby, hell even TCL/Tk rather than this.

If you need to support existing code in it, you’ll be installing a VM, installing Windows 95 on that, along with some install of Visual Studio you found in a tomb somewhere. Also, you need a dedicated support group, that probably charges by the minute. I have no idea why it’s still this high on the Tiobe index!

14. Assembly

installation: it’s GCC time again!

The Raspberry Pi is a 32bit ARM chip, so you’ll be using GCC’s 32bit ARM backend assembler. If you’re looking to bury your arms up to the elbows in hardware details the best I can do is point you at a Think In Geek tutorial about it

Alternatively you may be wanting to write assembler for a different chipset, using the Pi as your dev box. In which case you’ll be needing to find a matching GCC cross-compiling backend for your chip, and good luck to you. <salutes/>

15. Swift

installation:  It’s complicated 

Swift is Apple’s fancy language for writing iOS and MacOS apps. It’s mainly bound up with Apple’s Xcode toolchain/library suite and they really want you to do all your dev work on a Mac, not some weird, ugly, cheap thing like a Pi.

However, it looks like they have provided at least a slightly open sourced version of the language, but you still need to trick a whole bunch of stuff into thinking it’s running on a Mac (VM’s FTW!) There are instructions based on this stuff to get some kind of Swift dev environment running on Ubuntu on Intel machines, but running it on a Pi won’t be a one-liner!

16. Perl

installation: apt install perl

Just like Python, I can guarantee you’ve already got this installed. It’s one of the old world-building languages of Linux (and Unix). So you can just start using it just like you would Python (REPL, big code repositories, lax type structures and all).

Most of the Unix world was built in the old days of Perl 5 and earlier. However, for the past few years there has been a new Perl 6 version in development. This it’s essentially a whole new language and not yet widely used.

So unlike Python “2 vs 3”, where there’s no good reason to write new Python 2 code, Perl 5 is still well supported. If you want to write Perl 6 code, you’re into less travelled Perl realms and the first step is apt install rakudo.

17. MATLAB

installation:  hmm, it doesn’t work like that 

I must admit I haven’t done anything with MATLAB before. So the best I can do is point you at their pages about MATLAB Raspberry Pi support.

Basically it looks like you don’t use MATLAB on the Pi, you develop on another machine and there are tools to either connect to, or run generated code on, a separate Pi that you’re using as a subsidiary device.

18. Objective-C

We covered that up there at number 2

19. Go

installation: apt install golang

Ahh, another nice easy language to install. Go is another fairly modern language I haven’t played with, but it has a rather keen open source community at the moment. So Go have a play I guess :-)

20. PL/SQL

installation:  Nope, Nope, Nope 

PL/SQL is Oracle’s SQL based programming language. You only need this if you’re running Oracle databases and if you’re doing that, you’re not running them on Raspberry Pis!

Now you could be using a Pi as a client connecting to an Oracle DB. There are various ways to do that. So you could be wanting to push PL/SQL commands and code over that connection. But it’d be best not to, write and compile your stored procedures and functions elsewhere, then call them from your Pi client.

Other languages

There are many other languages available to use with the Pi which fall outside the Tiobe top 20. Some of these languages make sense to use for real work. Some of them are probably reasonable to use for interest and exploration, and other are just plain silly.

So I’ll finish up with a quick list of some languages I think might be worth investigating or using on the Pi - in no particular order.

Language Raspbian package
Smalltalk squeak-vm - visit the early history of OO languages
Lisp Multiple dialects. apt-cache search -n lisp, do some reading, become a wizard
Clojure clojure1.6 - it’s Lisp for the JVM, because reasons.
Groovy groovy2 - More JVM languages = better world
Lua lua5.2 - If you like Ruby, but need C, give it a try
Scala scala - If Clojure didn’t quite suit you, heeere’s Scala!
Ada gnat - Open source Ada, for all your open source defence system needs
Fortran gfortran - Fortran 95, the cutting edge of academic maths. Or if that’s “too modern” fort77 is the package for you (Hi Dan!)