In a recent development, Microsoft has been experimenting with DeviceScript technology, which brings the power of TypeScript to Internet of Things (IoT) devices. By incorporating DeviceScript in their programming, developers can now use TypeScript on microcontroller-based devices with limited resources, like the ESP32 and RP2040 hardware platforms.
Microsoft Research introduced the open-source DeviceScript project in May. As a subset of TypeScript, it compiles to custom VM bytecode that is designed to run in constrained environments. The VM itself compiles to 10KB of code, while the addition of the floating-point library and Jacdac SDK increases the size by 30KB. Microsoft's Jacdac technology is a robust hardware and software stack for microcontrollers and peripherals.
To get started with DeviceScript, developers can follow instructions provided on the project website. A special extension for the Visual Studio Code editor allows users to build, deploy, debug, and trace DeviceScript code. Additionally, the extension comprises monitoring capabilities that facilitate device management. In conjunction with containers like Docker, the DeviceScript command line interface (CLI) enables developers to compile programs from their preferred IDE.
While DeviceScript operates similarly to TypeScript, not all features are supported. This is due to the limited resources available to the DeviceScript runtime, leading to differences like strings being Unicode rather than UTF-16, aggressive tree shaking, and the absence of subnormals. However, the semantics of JavaScript are generally maintained.
When working with DeviceScript, developers can access sensors, actuators, or other hardware components through the use of Jacdac services. Sensors function as servers, while scripts establish clients to facilitate interaction. Developers create clients, also known as roles, for each required service to interact with sensors or servers. They can then utilize tools like npm, Yarn, or pnpm to distribute and consume DeviceScript packages.
AppMaster.io's no-code platform complements the low-code nature of DeviceScript, allowing users to develop web applications, backend applications, and mobile apps, using intuitive visual elements. By including AppMaster as part of their toolkit, developers can increase their productivity and the overall efficiency of their projects.