Haggis for anyone?

haggis2goOverview

Within the N5 Curriculum for Excellence in Scotland, it has been decided that pupils will use the Haggis pseudo code to define a programming problem, without the need for any specific programming language. This overcomes the problem of teachers not agreeing on a standard programming language. Personally having tried most programming languages, I would have recommended Pascal as being the nearest to pseudo code, and where there are many tools that can be used, but I do actually see the sense in not actually telling teachers which programming language they should use. As an academic, it doesn’t matter too much about the programming language that has been taught, as we will teach them the ones that industry currently uses. What does matter is that pupils should understand how to design programs, and produce code which solves a given problem – you can call it problem solving if you want – but it is one of the key skills for a computer scientist/engineer. If you are interested, the specification is here and you can try Haggis2Go Here.

Bright Red Digital Zone

brightred_logoYou may know of Bright Red Publishing, who they are a great company and who have the vision to not only create books for all the new N5 material, but, at the same time, create the Web-based material for them. We now work with them in trying to create a scaleable and robust Web infrastructure, where it becomes easy to port content from the books into a Web space, and how to encourage deep learning of the material in the books. If you are interested, it is here.

Haggis Pseudo Code Analyser

I’ve spent the last decade or so writing simulators for networking equipment, such as with my Cisco router simulator. For these I started off with Adobe Flash, then move the move to Microsoft .NET, and finally onto ASP.NET MVC. I must admit I think I made the right choice each time, as Flash proved not to be scaleable, then the move to .NET was a good one for a while, but as the world move to Web interfaces, the final move to ASP.NET MVC was the best move yet. Here are the .NET versions, and here is the MVC ones.

The Haggis pseudo code analyser is still under development, and there lots of this to do, but the figure below show the first attempt. Click here if you want to go to the site, and it is free to use just now, so just register if you are interested in try it out. If you have any constructive feedback, please send me it, as I’m keen to continue the development of the page.

hag

There’s a lot of work to be done in providing feedback on the commands, and so on, but I thought it would be good to at least make a start on this, and continue to develop it over the year. Thus I’ve added a few simple tutorials, which, at least, show the basic principles of the language, and perhaps how it could be used in the future. If you are interested, I basically convert to code into C# code and then run it. It will be simple to show the programming language output for Pascal, C, and many other languages. For just now, I’ve stuck with C#, as it’s the easiest to run on the server. I’ll add a code export option soon, so that users can see the generated code. For just now, there’s too many things that could go wrong with the conversion, so I’ve left it off.

Example 1

The following shows a simple example of sending a string to the display (Try):

haggis # LIST
haggis # SEND "hello" TO DISPLAY
haggis # SEND "goodbye" TO DISPLAY
haggis # LIST 
     SEND "hello" TO DISPLAY
     SEND "goodbye" TO DISPLAY
haggis # RUN 
     hello
     goodbye

Example 2

The following shows a simple example of setting a value and then displaying it (Try):

haggis # CLEAR
haggis # SET c TO 10
haggis # SEND c TO DISPLAY
haggis # LIST
 SET c TO 10
 SEND c TO DISPLAY
haggis # RUN
 10

Example 3

The following shows a simple example of setting a string to a variable and then displaying it (Try):

haggis # CLEAR
haggis # SET c to "goodbye"
haggis # SEND "hello" TO DISPLAY
haggis # SEND c TO DISPLAY
haggis # RUN
 hello
 goodbye

Example 4

In this example we perform a maths function and display the result (Try):

haggis # SET c TO 9*5
haggis # 
haggis # SEND c TO DISPLAY
haggis # LIST
 SET c TO 9*5
 SEND c TO DISPLAY
haggis # RUN
 45
haggis # SET d TO 9-5
haggis # RUN
 45
 4

Example 5

In this example we will use an IF (..) THEN conditional statement to make a decision on an expression (Try):

haggis # SET c TO 15
haggis # IF (c<10) then
haggis #  SEND "Less than 10" TO DISPLAY
haggis # END IF
haggis # RUN
haggis # IF (c>5) then
haggis #  SEND "Greater than 5" TO DISPLAY
haggis # END IF
haggis # RUN
 Greater than 5

Example 6

In this example we use a REPEAT…UNTIL loop to perform some operations (Try):

haggis # SET c TO 1
haggis # REPEAT
haggis #  SET c TO c+1
haggis #  SEND c TO DISPLAY
haggis # UNTIL c>20
haggis # RUN
2
3
4
5
6
7
8
9
10
11

Example 7

Sometimes you make a mistake in a program that shows up when you run it (known as a run-time error). One example of a run-time error is where a you put the program into an infinite loop (such as the example below). To catch this we have put in a loop break such as (Try):

haggis # SET c TO 1
haggis # REPEAT
haggis #  SET c TO c+1
haggis #  SEND c TO DISPLAY
haggis # UNTIL c<0
haggis # RUN
2
3
4
5
6
7
8
9
10
11
12
... 
21
Loop terminated ....

So if you see “Loop terminated ….”, it means that the program has broken the loop before it was meant to, and that you should perhaps check your code.

Example 8

Another type of loop is WHILE … DO. Which checks the loop expression at the start of the loop:

haggis # SET c TO 1
haggis # WHILE c<10
haggis #  SET c TO c+1
haggis #  SEND c TO DISPLAY
haggis # END WHILE
haggis # RUN
2
3
4
5
6
7
8
9
10

Postscript: If you thought you were coming to a food page … so sorry .. .BTW … I love haggis (as a food too).

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s