Microsoft proposes Static TypeScript for embedded systems

Microsoft is proposing a subset of TypeScript, the company’s popular typed superset of JavaScript, and its compiler/linker toolchain for use in embedded computing.

In a paper titled, “Static TypeScript: An Implementation of a Static Compiler for the TypeScript Language,” Microsoft researchers describe a Static TypeScript system and the challenges of implementing embedded programming platforms in the classroom. Static TypeScript is considered useful for educational purposes while amenable to static compilation for small devices.

With Static TypeScript, a program is compiled to machine code in the browser and linked against a precompiled C++ runtime to produce an executable that is more efficient than the prevalent embedded interpreter approach. Battery life is extended and devices with as little as 16KB of RAM can be supported. An alternative to embedded interpreters, Static TypeScript is the core language supported by the MakeCode Framework used to build applications for microcontroller devices.

Features of Static TypeScript include:

  • Use of nominal typing for statically declared classes and support for efficient compilation of classes via classic techniques for v-tables.
  • A toolchain that runs offline, once loaded into a browser, with no need for a C/C++ compiler. The toolchain compiles Static TypeScript to ARM Thumb machine code, for linkage against the C++ runtime in the browser.
  • Generation of compact machine code, suitable for application domains such as game programming for low-resource devices.
  • No need for app or device driver installation when deploying Static TypeScript user programs to embedded devices. Access to a browser is all that is necessary. Compiled programs appear as downloads, to be transferred manually to a device.
  • The Static TypeScript runtime uses a mark-and-sweep garbage collector.

Researchers do not intend to expand Static TypeScript to support all of TypeScript. Only features useful in the embedded context would be added, based on user feedback.