Which language on the Raspberry Pi?

What language should you use on the Raspberry Pi? There is quite a choice, including Python, Scratch, Java, C, Julia, and that's not counting the web stuff like Javascript, Html and Php.
There is no definitive answer - it depends on what you want to do. If you are teaching a child the basics of programming then Scratch might be a good choice. If you are an older learner then you might go for Python or Java with Greenfoot.
If you are interested in programming the Raspberry Pi hardware then there are libraries for pretty much any language that will let you do that. 
If you want a graphical user interface then you may want to give C a miss. But not necessarily because you can tack on a GUI in almost any language these days.
So where does that leave us?
Here is a list of some of the programming languages available for the Raspberry Pi with my brief personal notes and an example program for each one (except Scratch).

Scratch This is a graphical language designed to teach kids about p…

Just Enough Python 1

Python is a great language to learn whether you're an absolute beginner or you have had some previous programming experience.

And Geany is a great program editor that lets you build and run Python programs from within the editor.
Both Python and Geany are included, by default, in the Raspbian operating system as well as being available for most other flavours of Linux.

So, if you are a beginner you should start right here at the beginning. And if you already have some programming experience, well, maybe you should start at the beginning, too, because Python is a bit different to other languages that you may have used before. 

This is going to be a very quick tutorial just to get you started with Geany. We can move on to programming with Python properly, later.


Working with Geany 

As I said Geany comes with Raspian, just go to the programming menu and click on the little lamp.

When you've done that you'll get Geany with a blank file already loaded. (In the future you will get the last file you were working on.)

It will look something like this...

The big window is the editor where we can type in our program. So type in


as you see below.

Now we need to save the file. Go to the file menu and select "Save as"

Navigate to your Documents folder and you should see that there are already some folders there. (Don't worry if your system is different to what you see below, we are going to create what we need.)

We will now create a folder for our Python programs called "Python Projects", so click on the "Create Folder" button.

 Now type in the name of the folder "Python Projects"...

And now change the name of the file to hello.py...

Now click the "Save" button.

You'll see that the contents have changed. Because you have given the file a .py extension, Geany recognises it as a Python file and colours the various parts diferently. We will see that this can be very useful.

Now we run the program. Find the paper plane symbol and click it...

A terminal window will pop up and the hello.py will run in it. It just prints "Hello" as you knew it would.

Right, that was really quick, but now you know the basics of how to use Geany to write a Python program, and then run it.

Next time we'll begin programming, for real.

You can find the next tutorial here.


Popular posts from this blog

Just Enough Python

Learn to code with C

Introduction to Python by Andrew Ng