Microsoft’s DeviceScript brings TypeScript to IoT - IT SPARK Media

Microsoft’s DeviceScript brings TypeScript to IoT


Microsoft with its experimental DeviceScript technology is extending its TypeScript language to tiny IoT devices.

An open source project introduced by Microsoft Research in May, DeviceScript brings a TypeScript developer experience to low-resource, microcontroller-based devices, including the ESP32 and RP2040 hardware platforms. A subset of TypeScript, DeviceScript compiles to custom VM bytecode that can run in very constrained environments. The VM compiles to 10KB of code, with the floating point library and a Jacdac SDK adding 30KB. Jacdac is Microsoft’s hardware and software stack for microcontrollers and peripherals.

Instructions for getting started with DeviceScript can be found at the project website. A DeviceScript extension for the Visual Studio Code editor allows developers to build, deploy, debug, and trace DeviceScript code, and also includes device monitoring capabilities. The DeviceScript command line interface lets developers compile programs from their favorite IDE. The CLI also is usable within containers, such as Docker.

DeviceScript is said to work just like TypeScript, though not all TypeScript features are supported. There are some semantic differences stemming from the limited resources available to the DeviceScript runtime, such as strings being Unicode and not UTF-16, tree shaking being quite aggressive, and a lack of subnormals. The semantics of JavaScript generally are followed.

With DeviceScript, access to sensors, actuators, or other hardware components is abstracted through Jacdac services. Sensors act as servers, and scripts connect clients to interact with them. To interact with sensors/servers, developers start clients, known as roles, for each service needed. Developers can leverage npm, Yarn, or pnpm to distribute and consume DeviceScript packages.

Microsoft is responding to pull requests and issues at the project’s GitHub repo as allowed by time and resources.

Copyright © 2023 IDG Communications, Inc.


Source link