Paul Krill
Editor at Large

Microsoft’s DeviceScript brings TypeScript to IoT

news
Jun 13, 20232 mins

DeviceScript is a subset of TypeScript that compiles to a custom VM bytecode. The experimental project also includes a Visual Studio Code extension.

IoT | Internet of Things  >  A web of connected devices.
Credit: Natalya Burova / Getty Images

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.

Paul Krill

Paul Krill is editor at large at InfoWorld. Paul has been covering computer technology as a news and feature reporter for more than 35 years, including 30 years at InfoWorld. He has specialized in coverage of software development tools and technologies since the 1990s, and he continues to lead InfoWorld’s news coverage of software development platforms including Java and .NET and programming languages including JavaScript, TypeScript, PHP, Python, Ruby, Rust, and Go. Long trusted as a reporter who prioritizes accuracy, integrity, and the best interests of readers, Paul is sought out by technology companies and industry organizations who want to reach InfoWorld’s audience of software developers and other information technology professionals. Paul has won a “Best Technology News Coverage” award from IDG.

More from this author