Microsoft unveils DeviceScript: Bringing TypeScript to low-resource IoT devices

Microsoft is breaking new ground in the IoT realm with its groundbreaking technology called DeviceScript, an extension of the TypeScript language tailored for tiny IoT devices.

Introduced as an open source project by Microsoft Research in May, DeviceScript caters to microcontroller-based devices with limited resources, including popular hardware platforms like ESP32 and RP2040.

DeviceScript offers the power of TypeScript to low-resource microcontrollers. By compiling to custom VM bytecode, DeviceScript enables execution in highly constrained environments. The entire VM, including the floating-point library and Jacdac SDK, compiles to a mere 10KB of code, ensuring optimal performance. Speaking of Jacdac, it serves as Microsoft’s comprehensive hardware and software stack for microcontrollers and peripherals.

While DeviceScript shares similarities with TypeScript, some adjustments have been made to accommodate the limitations of low-resource environments. For instance, strings are represented as Unicode rather than UTF-16, tree shaking is optimized for resource conservation, and subnormals are not supported. Nonetheless, the core semantics of JavaScript remain intact, facilitating a familiar programming experience for developers.

To interact with sensors, actuators, and other hardware components, DeviceScript leverages the abstraction provided by Jacdac services. In this model, sensors act as servers, while scripts act as clients that connect to and interact with the sensors. By creating clients, known as roles, developers can easily communicate with the required services.

DeviceScript integrates seamlessly with the Visual Studio Code editor through its dedicated extension. This extension empowers developers to build, deploy, debug, and trace DeviceScript code effortlessly. It also includes device monitoring capabilities, providing valuable insights into the device’s behavior. For those preferring other IDEs, the DeviceScript command-line interface allows compilation from various environments, including containers like Docker, expanding flexibility and ease of use.

Getting started with DeviceScript is hassle-free, thanks to comprehensive instructions available on the project’s website. Developers can explore the rich possibilities of extending TypeScript to tiny IoT devices and capitalize on the potential offered by the DeviceScript ecosystem.

Leave a Reply

Click here to opt out of Google Analytics