Haggis – what should it be used for?
Mark J Tennant
March 4, 2014
HaggisCC-BY Wikimedia Commons

There seems to be much confusion about Haggis. As one of the folk who argued for it and helped to develop it, I want to set the record straight on why it is necessary and how we envisaged it being used in teaching. I’ve also included a link to a web-based checker and run-time system, so you can check any Haggis code before letting your pupils see it. Please pass on this message widely to colleagues.




This is what I’ve seen/heard about how Haggis is being used:

  • Haggis is used as a planning language
  • After a problem is refined over a number of iterations, a fully-specified program written in Haggis is the result
  • This is then translated into a “real” programming language to execute it.


Pupils are reported to be confused on two counts:

  • they don’t know why they’ve been asked to write a full program in two languages.
  • they mix up the syntax of the two languages they are being asked to learn simultaneously.




We expected Haggis to be incorporated into teaching as follows:


  1. Pupils learn to program in a “real” language of the teacher’s choice.
  2. Plans – that is, intermediate representations of the solution to a problem, at levels below the problem but above the final solution – are written in any pseudocode with which the teacher is comfortable. The key point is that a plan is written at a higher, more abstract, level than the programming language code itself. The final refinement is into the code of the real programming language, not into Haggis.
  3. Only when pupils have a secure understanding of one programming language, and can explain clearly what code in that language does, should they be introduced to Haggis – near the end of the course – with an explanation something like “You’ll see Haggis code like this in the exam, and be asked to explain it, so I’m going to make sure that you know how Haggis is different to what you’ve learned so far.”


Why did we expect/want Haggis to be used in this way?

  1. Research shows that the ability to understand programs is a key factor in developing computational thinking / programming skills.
  2. National 5 and Higher therefore include outcomes concerning the ability to read/understand code.
  3. Rigorous assessment of these outcomes requires code to appear in exam papers.
  4. SQA don’t specify one programming language of instruction – so, which language should be used to present code in exam papers?
  5. SQA adopted Haggis, a clearly defined pseudocode, as a way of presenting code in exams.


Note, crucially, the first paragraph of the SQA National 5 Pseudocode Spec says:

“Where candidates may be instructed using one of a range of languages, a clearly-defined pseudocode should enable code to be presented to them under closed assessment conditions such that they can reason about it.

Candidates are not expected to write code in the clearly-defined pseudocode, given that examiners should be able to mark solutions written in a range of languages commonly used for teaching — and so candidates can use the language of their choice”


This is the key: pupils should only need to know how to READ Haggis code – they are NEVER required to write Haggis in exams – all problem solving questions requiring the writing of code should include a phrase such as “In a language of your choice…”.


Seeing the same concept in two languages is good for embedding a deep understanding of those concepts – so showing pupils code in both your language of instruction and also in Haggis should be good educationally, as well as preparing them for the assessment. (Of course, to give them a sense of how much they’ve learned, you could see if they can explain a program they’ve seen already when it’s expressed in a third language too! Some pupils fear switching languages, but then when they have to do it, they often find it easier than they expected.)


Tools to help you with Haggis


As a teacher, you are likely to need to develop some examples and/or questions that make use of Haggis for your pupils. It is never easy to write accurate code first time which is why we need checkers. Haggis is no different, and a checker and run-time system are now available, developed by Richard Connor at Strathclyde University. These are publicly available at the following page, and for those of you interested, there is a link from the page to a formal specification of Haggis.




There are other tools out there as well – for example, Bill Buchanan at Napier University, Paul Cockshott at Glasgow University, and a pupil have all created implementations.


Any questions or comments about all this, please post them here or send them to me…

Quintin Cutts
School of Computing Science
University of Glasgow
Glasgow G12 8RZ
+44 (141) 330 5619
12 Responses
  1. Will there be exemplars produced of the 5 standard algorithms that the SQA will use in the exam to ask questions? I have noticed schools do them slightly different.

    • Yes – I would like this as well just to ensure that students have the correct info and it is consistent.

      • I will ask SQA about this. I would hope that a Higher pupil would however be able to understand each algorithm, even if it is expressed slightly differently. That might be good in itself – to produce a few different ways of expressing each algorithm – so that pupils can see that there is more than one way to skin a cat!

  2. That Haggis parser is brilliant. I think it’s funny how one of the example programs doesn’t compile, haha.

    I completely support Haggis and the need for coding in the exams. It’s the only way to ensure that pupils can actually understand code by the time they are entering university.

    Point 3 under the Expectation heading should put a lot of naysayers at ease.

  3. Looking at the Higher specimen paper, Section 2 Q2b, the answer uses a CASE statement which is missing from the Haggis syntax at the moment. Should Haggis include CASE?

  4. and I’m not convinced that sacrificing readability for efficiency (using nested IF’s instead of separate IF statements as the answer scheme suggests) is a good idea anyway.

  5. Thanks Quentin
    but surely good practice would state that you write the pseudocode before you attempt a practical solution? Your message seems to be learn how to write pseudocode once you have learned the language.
    Also in the exam, say the pupils in their written answers, use a mixture of Haggis and VB6.0 – is that acceptable

    • I suppose good practice would be to design the solution before you implement it, but we are teaching the basics here, not managing a team of experienced developers.

      For teaching purposes, it makes much more sense to me for pupils to understand programming before they can design solutions to programming problems.

      Can anyone honestly say they they managed to get pupils to properly understand pseudo code (of any form) before they understood any form of programming? I can’t imagine that scenario in reality. Heck, even in 2nd/3rd year university people were reverse engineering their pseudo code from their solutions. Even as a developer, I only ever used psuedocode to explain how a program/agent worked, rather than to design the solution.

  6. Introducing Haggis “near the end of the course” is surely too late? For me, it’s been App Inventor in S3 with lots of experimentation with blocks of code and then an introduction to pseudocode (which I have made a pseudoHaggis, if that makes sense) and then taking this pseudocode to develop programs in VB Express (still in S3). The results of this? VB Express next week – looking forward to it.
    S4 has been torture this year with assessment burden and the rapidly ticking clock, but the new course is exciting and appropriate and forces us to put pseudo code in its rightful place – before a program is coded in the environment of choice, rather than a bolt-on at the end because it’s required to pass an assessment.

  7. PseudoHaggis?!? What on earth could that be? Haggis with keyword replacement, perhaps, ie ‘in a programming language with which you are familiar ….’ Deja Vu.

  8. @Lee – you wrote: Even as a developer, I only ever used psuedocode to explain how a program/agent worked, rather than to design the solution.

    Perhaps that is because your experience allows you to ‘think computationally’ and that your design approach is so well practiced and has become so internalised (implicit) that you are no longer aware of it. We are, however, developing computational thinking skills in very young learners, and it will need careful thought on how to go about it to ensure that concepts are introduced and understood in the right way – such as teaching how we should think about coding in a structured, linear and dare-I-say-it ‘engineered’ way – viz. algorithmically. Without such a structured approach, as emphasised by Quintin, we would be expecting kids to just ‘get it’; in much the same way as understanding, eg Steinbeck as a great writer, is simply a matter of reading a couple of his books and ‘getting it’, I wonder?

    • You’re completely right and that’s exactly what I would suggest.

      My post was to show merely that learning how to code should come before learning how to design a coding solution (as Quintin states in his ‘Expectation’ paragraph), otherwise we really are expecting pupils to ‘just get it’.

Leave a reply

Your email address will not be published. Required fields are marked *

What is 7 + 7 ?
Please leave these two fields as-is:
IMPORTANT! To be able to proceed, you need to solve the following simple math (so we know that you are a human) :-)