The BBC Micro:bit Which Language?
Written by Sue Gee & Mike James   
Monday, 16 May 2016
Article Index
The BBC Micro:bit Which Language?
JavaScript or Python
Repeating The Mistakes Of History

Microsoft Touch Develop

Touch Develop, a programming environment pioneered by Microsoft and open sourced in February 2015  shares many of the characteristics of the Block Editor. You can enter any code you want by selecting from menus that appear at the bottom of the screen - or you can just type in the code without any help. 

touchdevelop

 

Using the menus makes it possible to build programs on restricted devices - say using a touch screen, hence the name of the system. It also provides an easy transition from menus to full speed typing of code.  

The biggest problem in using Touch Develop is in finding what you are looking for. The organization and layout of the menus if far from intuitive but you get used to anything after a while and once found you tend to remember where things are.  

The Touch Develop editor is the least restrictive of all of the easy entry editors - only MicroPython beats it for facilities. 

The most important feature is the ability to define functions which can also have parameters and return values. This makes it a good choice if you want to go further and use or teach modular programming. 

Two other possible problems are the for loop and the if statement. The for loop is limited in the same way as that in Microsoft Blocks and is just a repeat n times loop.

The if statement it also limited, but in this case limited to a bigger case than is generally needed. You can only have an if .. then .. else structure - you can't seem to get rid of the else and if you just want an if then you simply have to leave the else clause empty. 

Another big problem is the inaccurate and incomplete documentation and incomplete menu structure. For example ,you can create a sprite by selecting from the game menu but there are no options for the full range of sprite properties and methods. So, you can create sprites but after that it is up to you to figure out how they work. 

One final problem with Touch Develop is that there seems to be no way to see the entire program in graphical form or as text and there is no export command. 

Touch Develop is a reasonable choice but it has a great many rough edges, which is not what is required for a beginner's language. 

Code Kingdoms JavaScript Editor

You might think that a block editor that works with JavaScript would be a good choice because it is an important language in the real world. You can opt to view your program as standard JavaScript code and you can even edit it in this form. However, it is worth knowing that you can't type in any JavaScript command you like in the editor. You can only use the subset of JavaScript that the blocks can generate. 

 

ckjavascripted

 

In addition the limitations of the CK JavaScript Editor are quite severe. It does support functions so you can use modular programming, but I couldn't make the parameters of the function work reliably. While you can put a return into a function, there is no facility to put a return value. What this means is that you have to create global variables to get data into and out of a function. This is not good news because this style of programming has long been known to be bad for anything but very small programs. 

Despite JavaScript not being a typed language the editor makes a great distinction between a numeric and a string variable. The type seems to be deduced based on how the variable is declared in a function and how it is first initialized although as there is no detailed information it is difficult to be certain. The problem is that the editor is easily confused and often simply drops variable typing throughout a program and flags problems with the error message:

 

error

 

What a beginner is supposed to make of this is difficult to see. The solution is to re-enter the variable and hope. Sometimes re-entering the variable isn't easy or even possible because the list of variables and global variables doesn't remain in sync with what has been declared. 

Another interesting problem is the way that the system will occasionally fail to compile a program but without providing any clue as to what is wrong. The error message simply says a compile error has occurred not where the error lies.  There also seems to be no way to remove a variable once defined and renaming a variable can produce the sort of error described above. 

A final, and very strange, problem in working with complex programs in the editor is that it doesn't seem to support a horizontal scroll. If your block gets so complex that it hangs over the edge screen then you need a bigger screen.

In short, the CK JavaScript Editor is enough to bring a seasoned programmer to tears, let alone a complete beginner who might well conclude that programming is a mysterious and illogical art.  These and other strange behaviors suggest that, for the moment at least, the it is really only suitable for small programs and for programmers with lots of patience, i.e. not beginners. 

MicroPython

This is the most promising of all of the language environments. Python is a popular language and MicroPython is similar enough to be a good starting point. 

 

miropython

 

However there are some difficulties. The most important is that there is no syntax checking as you are creating a program and the first thing you know about even a gross error is when you run the program. You also need to keep in mind that you have to download the program and then copy it to the micro:bit which increases the time to find even the simplest error. What is worse, however, is that the error message appears on the 5x5 LED which makes it very difficult to read the details. 

A partial solution to the debugging problem is to enable a serial console and use the REPL. This is something that the documentation deals with, but it isn't spelled out clearly enough. It should say:

"don't even try to write anything much beyond Hello World without a serial console".

Even if you don't use it for debugging, at least you get to see the error messages on the serial console and you can read them at your leisure. 

After this the big problem is finding anything out. Most of the documentation isn't micro:bit specific and it is difficult to work out what applies and what doesn't. The good news is that it supports all of the features that makes Python a good teaching language. It has functions with parameters and return parameters. It has a good If statement and an excellent range of loop constructs. 

Of course it doesn't have a block editor like the other options and this makes it seem harder to write that very first program. It is but the effort is probably worth it. 

The MicroPython installation deserves some work because it is only a fraction off being an excellent choice for programming the micro:bit. 



Last Updated ( Monday, 16 May 2016 )