Microbit development environment mainly uses 3 main programming language. Having able to switch from Block, Micropython and Javascript in Makecode environment. Remember in our past microbit article, we had covered Block and Micropython programming Let discuss on Javascript coding for MIcrobit.

arcade cartoon
arcade cartoon

Using Block to Javascript

  • MakeCode is meant for teaching programming first, and JavaScript second. For this reason, Microsoft has stayed away from concepts that are specific to JavaScript (for example, prototype inheritance).
  • Open a block project in Makecode and drag show leds and show leds block.
  • Switch to Javascript and you can find the code written.
block to javascript
block to javascript
  • Well the environment will check for any syntax and coding formatting error.
  • You can find an introduction to JavaScript with MakeCode:
    • Calling - How to use a function
    • Sequencing - Ordering statements in code
    • Variables - Remember data and save values
    • Operators - Operations to change and compare values
    • Statements - The elements of code that take action
    • Functions - Portions of code to use again and again
    • Types - The identity of data
    • Classes - Contain related data and operations together
    • Interfaces - A regular way to work with a class
    • Generics - Use different data with the same code

Static TypeScript Compiling

  • Both Blocks and Static Python are converted to Static TypeScript before being compiled to lower-level languages.
  • STS is the core language supported by the MakeCode Framework.
  • A STS program is compiled to machine code in the browser and linked against a precompiled C++ runtime, producing an executable.
  • The prevalent embedded interpreter approach, extending battery life and making it possible to run on devices with as little as 16 kB of RAM.
  • STS eliminates most of the "bad parts" of JavaScript; following StrongScript, STS uses nominal typing for statically declared classes and supports efficient compilation of classes using classic techniques for vtables.
  • STS toolchain runs offline, once loaded into a web browser, without the need for a C/C++ compiler – the toolchain, implemented in TypeScript, compiles STS to Thumb machine code and links this code against a pre-compiled C++ runtime in the browser.
  • STS compiler generate compact machine code, which unlocks a range of application domains such as game programming for low resource devices.
game box
game box

Finally, if you need to understand some basic javascript, you can refer back our old javascript article.

See you and enjoy your day ahead.


This free site is ad-supported. Learn more