Microsoft Introduces DeviceScript For IoT
Written by Harry Fairhead   
Thursday, 22 June 2023

Microsoft has introduced DeviceScript, an open source subset of TypeScript intended for use with low-resource microcontroller-based devices on the Internet of Things (IoT).

Microsoft Research announced the language last month, describing it as a professional TypeScript developer experience for microcontrollers such as the RP2040, the chip used by the Raspberry Pi Pico family and the low-cost ESP32. The best supported is the ESP32-C and the Pico/W works but doesn't support SPI.

devicescript

DeviceScript is compiled to a custom VM bytecode of around 10KB, which can run in very constrained environments on portable runtime. It uses Jacdac services as the hardware abstraction layer. Adding the Jacdac SDK and a floating point library adds a further 30KB to the required space. Jacdac is Microsoft's platform for quick and easy prototyping of new electronic experiences. It has hardware and software elements for working with microcontrollers and peripherals.

Jacdac services provide DeviceScript with the means to work with sensors, actuators, or other hardware components. Sensors are treated as servers, and developers can use scripts to set up clients to interact with the devices. Clients are known as roles and can interact with sensors or servers.

A Visual Studio Code Extension is also available for DeviceScript, and can be used for development, offering features including debugging, simulators, logging, and cloud deployment.

The debugger includes breakpoints, stack traces, exceptions, and stepping through code. The VS Code extension also includes a DeviceScript simulator, and a sensor and Jacdac simulator.

The extension also includes monitoring options for device management, and there's a command line interface (CLI) that can be used to compile programs. Developers can then make use of tools such as npm, Yarn, or pnpm to distribute and consume DeviceScript packages.

Microsoft says that the goal of DeviceScript is to give developers familiar with TypeScript development an easy way to start building embedded applications. The idea is that DeviceScript keeps most of the attractive features of TypeScript, but is small and efficient to run on small MCUs.

DeviceScript is a subset of TypeScript, and not all TypeScript features are supported in order to keep things small, so strings are full 21-bit Unicode code points rather than UTF-16, and advanced options such as subnormals are missing.

Is DeviceScript a sensible way to program a device?

Yes, if you already know JavaScript, but other languages are better and offer specific advantages. C is essential in any situation where speed is important, while MicroPython, which is fully object-oriented, well-supported and and has strong support for a wide range of processor, is generally considered to be easy to use.

DeviceScript is available now on GitHub. 

devicescript

 

More Information

DeviceScript On GitHub

Jacdac On GitHub

Related Articles

TypeScript 5 - Smaller, Simpler, Faster

ESP32 In MicroPython: Using Hardware Registers

The Pico/W In C: Direct To Hardware

The Pico In MicroPython: A PIO Driver For The DHT22

To be informed about new articles on I Programmer, sign up for our weekly newsletter, subscribe to the RSS feed and follow us on Twitter, Facebook or Linkedin.

Banner


C23 ISO Standard Is Here But You Probably Won't Read It
06/11/2024

At last ISO C23 has been published, but at $250 you probably aren't going to read it. Can we really tolerate this sort of profiteering on the work of others? This is worse than academic publishing!



OpenAI Library For .NET Exits Beta
19/11/2024

A few months ago the OpenAI .NET library was released as a beta. It has now reached version 2.0.0 and the time has come to leave beta and, with a few amendments enter production readiness.


More News

espbook

 

Comments




or email your comment to: comments@i-programmer.info

<ASIN:187196282X>

<ASIN:1871962811>

<ASIN:1871962684>

<ASIN:1871962692>

Last Updated ( Friday, 23 June 2023 )