Richard Pawson FBCS describes ‘Elan’ — the first new language to be designed specifically for teaching programming in British schools since BBC Basic in 1981.

In 2016, after working almost 40 years in the computing industry I very suddenly became a schoolteacher — teaching computer science A-level at Stowe School. One of the several big shocks awaiting me was that the way programming is taught in British schools today really hasn’t changed since computers came into most schools in the early 1980s. Given that programming — in the modern sense — is only about 80 years old, that’s like teaching a physics curriculum from, say, 200 years ago!

In the intervening years I have written many free teaching resources, made available to teachers via the BCS-run Computing At School (CAS) forum, all designed to encourage a better approach to teaching programming. Last year, however, I decided that one of many hurdles to progress was the existing programming languages, and it was time to write a new one. ‘Elan’ is short for ‘educational language’ but also echoes the English word ‘elan’ meaning style, flair or panache. (No, I don’t drive a Lotus). The language is embedded within a radical IDE, all running entirely within a single webpage.

Frame-based editing

The hurdles to getting a new language adopted are enormous — especially in schools. Our first goal was that even though Elan was to be a radical and forward-looking language, on first exposure it should seem familiar, not frightening. Elan is easy on the eye — favouring keywords over punctuation. We focused on how code is verbalised in the classroom: a teacher does not tell pupils to ‘type playGame open, close brackets’ — they say, ‘call the playGame routine’. In Elan, the pupil has only to pick up on the keyword (call) to know how to start coding the statement (Figures 1 & 2). In fact, they need only type the letter ‘c’ — because the Elan editor will immediately insert a ‘call frame’ — which is like a template for that statement type (Figure 2). But unlike the code ‘snippets’ you find in many professional IDEs, these frames aren’t just transient: they maintain the integrity of each code construct. If you create a ‘while’ loop, not only does the frame create the field for the condition, and ‘end while’, automatically, it ensures that neither can be deleted.  And no, this isn’t an AI-driven co-pilot: the Elan editor is just enforcing the grammatical rules of the language. The upshot is that you simply cannot create a syntax error. You can create a ‘parse error’ within a single ‘field’ — a user-editable part of a frame — but this immediately causes the field to go red, and the location of the error (unlike with many syntax errors) is immediately obvious (Figure 3).

Figure 1 Wherever 'new code' may be entered, the user sees a list of possible code 'frames' that may be created in that context. Usually they need type only the starting letter (in some cases, two) to create that frame.
Figure 2 Having typed 'c' a 'call’ frame is inserted, containing fixed keywords (an/or punctuation) and 'fields' — 2 here — where the user must (amber). or may (grey) add further detail.
Figure 3 When entering or editing a field the user is given immediate feedback using a coloured background to indicate that a field is incomplete (top), valid (middle) or invalid bottom — along with prompts (white text) and help (?). (Colours are configurable

Functions versus procedures

From this description you might think that Elan is an elementary programming language. It isn’t — it just makes it easy to get started. At the other end of the learning curve it is just as radical. For example, most school level programmers, and an alarming number of university graduates, think that the only difference between a function and a procedure (if any) is that a function returns a value — missing the fact that a proper function must create no side-effects and depend upon the state of nothing except the parameters it is passed.

For you

Be part of something bigger, join BCS, The Chartered Institute for IT.

Elan enforces this: at the simplest level the user is not offered the option to insert a ‘print’ statement into a function, nor the option to call any procedure (though the reverse is fine). If pupils learned this distinction from the start, not only would it make it much easier to transition to functional programming later on, but from the start they would find themselves chasing down fewer hard-to-pinpoint bugs. Because if function ‘foo’ is correct, and function ‘bar’ is correct then a combination of the two is guaranteed to be correct (this is not true for procedures, because their side effects or external dependencies may interfere with one another).

Automated testing

And how can a pupil know that any function is correct? In Elan, unit tests are a first-class feature of the language, designed to be so easy to learn and use, that pupils can learn to write tests from the very start of learning to program (Figure 4). Every Elan test:

  • Has very simple syntax: ‘test … end test’. You may specify a name for each test, but you don’t have to — because coining a unique, descriptive name for each test is surprisingly hard work.
  • Can be written anywhere in the code, including immediately underneath (or above) the function it is testing — not in a separate project, file or class. There’s no danger of Elan tests creeping into executable code, because tests can only be called by the in-built test runner.
  • Can test multiple cases, resulting in tests that are both more compact and easier to read. Most unit test frameworks discourage this because test execution stops at the first assert to fail. Elan continues and shows the result of each assert alongside it (Figure 4).
  • Runs automatically every time your code changes and compiles. The sense of reward is palpable — even to an experienced programmer, let alone a beginner. And whenever you load a program, if it contains tests, these tests will be run automatically, reminding you that the code you were working on yesterday is still running — or not.
Figure 4 Spot the coding mistake! Tests are very simple to write in Elan, and run automatically whenever the code compiles, showing results alongside each assert.

Profiles and anti-plagiarism

Elan allows a teacher to configure the availability of all language constructs for a particular year group, set, or individual. A unique capability of these ‘profiles’ is the optional ability to specify that a user may load only Elan code files they have written themselves — a built-in guard against plagiarism and AI-generated code. This is enforceable because the system-generated comment at the top of each file contains a hash of the code. Elan code files are saved as plain text, but valid code can only be generated by the Elan IDE.

Character-mapped display

Elan is forward-looking in many more respects than listed here — for example in its approach to OOP. In one respect only, it is deliberately backward-looking: graphics. I hear many complaints from teachers about how hard it is to get pupils started with GUIs, and even when they get the hang of it, they learn very little programming in the process. Elan emulates the simpler ‘character mapped displays’ of the 8-bit micros of the 1980s. Writing ‘retro’ games such as Snake, Blackjack, or Tetris is not only straightforward with this approach but you learn far more programming in the process. The graphics aren’t as glitzy as modern offerings, but the games are no less engaging. The beta version has a few built in demos — though they won’t exist in release 1.0, because if they did the pupils would be playing them throughout every lesson!

Everything about Elan is free and open source. It is currently at public beta stage, garnering feedback from teachers and other stakeholders. Release 1.0 is expected April 2025. You can try it for yourself by visiting https://elan-lang.org/beta — which also has links to explanatory videos.

Figure 5 The Elan IDE runs within a browser. It includes easy-to-use character-mapped graphics – shown here to draw playing cards. The code pane shows the code in collapsed view. If there were parse or compile errors, the appropriate ‘+’ symbols (left) would change colour to show the user where the problem(s) may be found.

About the author

Richard Pawson FBCS started his career at Commodore in 1977. After spells in journalism, robotics research, electronic toy design, consulting, software development, and teaching, he now writes free resources for teaching computer science, and is a regular contributor to the BCS-run Computing At School.

Topics