So, you want to introduce coding in class but with so many programming languages out there how do you choose the one that’s right for you and your students? We asked Associate Professor James Curran, Director of the Australian Computing Academy and co-founder of Grok Learning, for help.

Since 1954, when IBM’s John Backus invented the first widely-used programming language, FORTRAN (FORmula TRANslation) for scientific and engineering calculations, many weird and wonderful programming languages have been developed for coding.

As a teacher, how do you choose which programming language is right for you and your students? Here, I’ll discuss which programming languages are suitable for each band of the Australian Curriculum: Digital Technologies and for extra-curricular computing activities.

But first, what is a programming language?

A programming language is a language for describing instructions that a computer can follow to solve a problem. Like natural languages, such as English or Mandarin, programming languages have a grammar (or syntax) that programmers must learn. Unlike humans, computers cannot understand a program if the syntax is even slightly incorrect. They will complain with a ‘syntax error’.

Compared with our brains, the CPU in a computer can only perform simple instructions, but it can do them very fast. For example, a CPU can add two whole numbers together billions of times per second, but it cannot recognise a handwritten digit. To recognising handwriting, programmers must break the task down into many simple instructions for the computer to follow.

Coding in the Australian Curriculum

The Australian Curriculum: Digital Technologies (AC:DT) mandates that all students learn to write programs from Years 3-4 through to Years 7-8, with an elective subject for Years 9-10.

In Years 3-4, students should learn to “implement simple digital solutions as visual programs with algorithms involving branching (decisions) and user input” (ACTDIP011); and in Years 5-6 use “iteration (repetition)” (ACTDIP020) in their programs. Put simply, students should be able to write programs that take and display information, perform calculations, make decisions, and repeat steps. In Years 7-8, students must also “implement and modify programs with user interfaces involving branching, iteration and functions in a general-purpose programming language" (ACTDIP030) and in Years 9-10 “implement modular programs, applying selected algorithms and data structures including using an object-oriented programming language” (ACTDIP041).

Nearly all popular languages provide the bolded concepts above. The curriculum makes a key distinction between visual programming (in Years 3-6), general-purpose programming (in Years 7-8), and object-oriented programming (in Years 9-10).

Let’s compare programming languages with a simple task: asking the user for their name (user input/interface), storing their name in a variable, and displaying the message “Hello”, followed by their name. These are concepts common to the programming content descriptions in AC:DT.

Visual programming

Visual programming involves dragging and dropping instruction blocks together to form a program in a graphical development environment. The advantages of visual programming are: students don’t need to learn syntax and cannot create syntax errors; students can see what blocks (instructions) are available; and, blocks often hide complex logic or operations in a single block.

Scratch and Blockly are popular visual programming languages. They have a similar style of blocks, but their functionality and environments are very different. Other visual environments include Alice and Lego Mindstorms.

While visual programming is excellent for beginners, it is too slow and cumbersome for writing substantial programs. Visual environments are usually limited in their functionality, making data analysis difficult and restricting the kinds of problems that can be solved.

Blockly (Years 3-6)

Blockly is the visual programming language used by several systems, including Code.org, Made with Code, MIT App Inventor, and our own Grok Learning. Each system uses a different set of blocks but they use similar blocks for most coding concepts, including branching and iteration. Each system runs on any modern browser, for desktop and tablets, including iPads.

The example below is from Grok Learning. In this program, the green ‘ask’ block prompts the user for their name with the message “Enter your name?” and then waits for the user to type in their name. The user’s name is then stored in the variable called ‘name’ by the grey set variable block. Finally, the purple ‘print’ block prints "Hello" followed by the name stored in the variable.

Depending on the system, the input and output can be text-based, graphical, or another device (such as an Android device or a BBC micro:bit). Many systems provide markers that automatically check whether the student’s code is correct.

Scratch (Years 3-6)

Scratch is a graphical environment for developing interactive games and multimedia developed at MIT. It runs on desktop or tablet browsers that can run Flash. Unfortunately, this excludes iPads. A version for younger kids (Scratch Junior), is available for iPad or Android tablets. Students can store and share their projects online.

Scratch is event based (the code runs in response to a user action, here a ‘click event’ on the green flag). Events are used in interactive programs, such as graphical user interfaces, websites and games, to respond to user input. The output changes the properties of one or more characters (sprites), such as their position, orientation and size; or background images and sound. Students find the interactive graphical programs they develop very motivating, and it appeals to a wide range and ability of students. Scratch is highly recommended as a first programming language for Years 3-4 and less experienced Years 5-6 students.

In the program above, Scratch’s orange cat prompts the user for the name using a speech bubble and when they enter the name, it is joined with “Hello” and then displayed for 10 seconds.

General-purpose programming

By general-purpose programming languages, AC:DT means a text (versus visual) programming language that can be used to solve a wide range of problems. Students should code in a language they can use to solve problems, analyse data, and enhance their learning in future study and work.

General-purpose languages include C/C++, C#, Java, Javascript, Python, Ruby, Swift, and Visual Basic. Not all of these languages are well suited to teaching at school, especially for beginners.

Ideally, we want a language with clean and simple: syntax and error messages; programming concepts and documentation; libraries for a wide range of programming tasks; and one that is available across different operating systems and devices. Each language offers trade-offs for a teaching context and/or planned projects and some languages are designed for particular tasks.

For example, C/C++ is used for low-level system development, such as Arduino programming; Javascript is mostly used for coding interactive websites; and C#/Visual Basic and Swift are largely limited to developing applications for Microsoft and Apple platforms respectively.

Python (Years 7-10, advanced Years 5-6)

Python is a powerful general-purpose programming language that is very popular in school and university programming courses, and is also widely used in industry and academia. The syntax is very simple and consistent, it enforces good habits (such as indentation), and the standard and external libraries enable a very wide range of problems to be solved.

Because of its simplicity, Python has often been called executable pseudo-code; that is, as a programming language, it is very readable and (fairly) close to English.

In the Python program below, the ‘input’ function asks the user for their name with the prompt message. The returned name is stored in the ‘name’ variable, and then “Hello” and the name are displayed by the ‘print’ function. This program is identical to the Blockly program above:

In our Grok Learning system, students can see the Python code that corresponds to their Blockly program, which helps them see the relationship between visual and text programming.

Python can be used for embedded/robotics development on the BBC micro:bit. Unfortunately, Python does not have good support for developing graphical user interfaces, and PyGame, while fairly popular, is a difficult framework for writing games.

Ruby (Years 7-10)

Ruby is similar to Python in many ways, but the syntax is more succinct and esoteric. While this is great for professional programmers, it is harder for new programmers. For example, in most languages, you use parentheses to run (or call) a function, such as 'print('Hello')' in the Python snippet above. But in our Ruby example below, both ‘gets’ and ‘chomp’ are function calls, but the parentheses are optional (which is faster for experts, harder to understand for beginners):

Use of Ruby has largely been driven by the popular Ruby on Rails web framework, and while it is a general purpose language Ruby is much less popular than Python outside of web applications.

Java (only Years 9-10, if at all)

Java is a general-purpose programming language that is widely used in industry, from Android app development up to enterprise servers and website backends. It is also a complex language to learn with an enormous standard library and heavyweight development environment.

While teaching a language that is used in industry has some merit, we strongly discourage the teaching of Java (or for that matter C++, C#, or Swift) in school, because the languages are too large and difficult to master as first programming languages. Notice how much more code is required to solve the same problem as two to three lines of Python and Ruby.

Javascript (Years 7-10)

Javascript is the programming language understood by web browsers, and so nearly all interactive websites are written in Javascript. Despite the name, it is a very different language to Java. Since Javascript is focused on browsers, it doesn’t have the simple input/output functions of the other languages. Instead, Javascript code modifies and generates HTML/CSS, which changes the look and behaviour of a website as the user interacts with it:

Javascript programming is largely event-driven, like Scratch, which can make it difficult to follow. In the example above, the ‘main’ function runs when the user clicks the ‘run’ button, asking the user for their name in a pop-up dialog box, and then updating the contents of the paragraph to be “Hello” followed by the name.

Summary: Weighing up the options

For primary school teachers, the choice is quite clear. Scratch is very popular as a first programming language with good reason. It inspires a wide range of students with opportunities for creative programming in many different ways. Blockly activities provide a more systematic exploration of the programming concepts and usually include some form of automated marking to confirm the student's code is correct.

For secondary school teachers, there are many languages to choose from. We believe Python is an excellent all-round language – powerful and flexible, yet accessible for beginners. Python’s one weakness is that creating graphical user interfaces or games in this programming language is not very easy, in which case I’d suggest pairing Python with Javascript in a later year, so it gives your students the best of both worlds.

Happy coding!