Microsoft recently submitted a research paper introducing Static TypeScript (STS), a subset of TypeScript targeting low-resource embedded devices, to the Managed Programming Languages and Runtimes 2019 (MPLR 2019) international conference. STS programs may run on devices with only 16 kB of RAM faster than embedded interpreters would, which would extend battery life of these devices.
STS is a syntactic subset of TypeScript, built specifically to target microcontroller units (MCUs), and compiles to machine code that runs efficiently on MCUs in the target RAM range of 16-256kB.
eval, prototype-based inheritance, the
arguments keyword, or the
.apply method. The
this pointer and the
async function expressions, or file-based modules.
STS also departs from TypeScript typing conventions. Static TypeScript has nominal typing for classes, while TypeScript uses structural typing. This implies in particular that an
interface cannot have the same name as a
class, a non-
class type cannot be casted to a
class, classes cannot inherit from built-in types,
An HackerNews user expressed his enthusiasm:
Extremely interesting idea. Sounds like many of the things they get rid of are some of the more problematic features of JS anyway. The end result is fairly Swift-y; a loosely OOP static language that has closures and really convenient hash-map syntax.
STS programs may be deployed on embedded devices with a web browser or manually, that is, without any app or driver installation. The research paper explains:
Compiled programs appear as downloads, which are then transferred manually by the user to the device, which appears as a USB mass storage device, via file copy (or directly through WebUSB, an upcoming standard for connecting websites to physical devices).
Zuniga emphasizes the importance of browser-based deployment and simulation for young pupils learning physical computing, an important target audience of MakeCode:
STS comes with a simulator that runs in the browser and so programs can be tested there before they run on hardware. For educational purposes, we found diagnosing issues on hardware to be really hard for students, so we try to catch and present errors as early as possible.
Going forward, Microsoft envisages STS having a significant impact on the Internet of Things (IoT):
We see statically typed languages such as STS playing an important role in the future of IoT, allowing embedded devices to run more efficiently—faster and, as a result, with reduced energy requirements—as well as providing programmers who aren’t embedded developers with an easier, higher-level alternative to the lower-level languages generally used to program these devices.