Microsoft is making significant strides in bridging the gap between JavaScript applications and the Windows operating system. With the introduction of “dynamic projections,” developers using JavaScript and TypeScript can now seamlessly access various Windows internals, enhancing their application capabilities without the complexities that previously hindered integration.
The Windows Runtime API (WinRT) projection for Node.js, currently in public preview, simplifies the process of tapping into Windows features. This development does not introduce new powers but rather streamlines the connection to existing capabilities, allowing developers to leverage on-device AI, storage, notifications, networking, and more through a Node.js or Electron environment.
Bindings at build time
Historically, integrating Windows features into JavaScript or TypeScript applications required the cumbersome task of writing native add-ons, which involved creating a bridge using C++ or C#. This process often left developers without C++ expertise at a disadvantage. However, with the new single Node runtime package, dynwinrt, developers can now generate the necessary JavaScript wrappers and TypeScript declarations for their desired Windows features with ease. Additionally, a separate package, winappCli, provides a command-line interface for setup, configuration, and sample code.
MORE CONTEXT
The WinRT has long offered similar functionalities for other programming languages, including C++, C#, Rust, and Python, through native language projections. The winappCli code generation feature now extends this capability to JavaScript and TypeScript, creating wrappers and declarations for each API call at build time.
Metadata for the win
This innovative setup relies on Windows Metadata (winmd), introduced in Windows 8, to dynamically list available Windows APIs and their functionalities. Should any API metadata change, the code generation process automatically updates the corresponding wrapper or declaration, eliminating the need for manual rewrites. JavaScript and TypeScript developers can access a wide array of Windows capabilities, excluding UI elements, which are managed by Electron. This includes functionalities such as sending notifications, file selection from the hard drive, and various system and device calls encompassing networking, sensors, globalization, and security.
All aboard for AI
Of particular interest to Microsoft executives is the newfound ability for JavaScript and TypeScript developers to utilize AI capabilities within their applications. With a focus on local AI solutions that do not rely on external, costly AI services, developers can now create applications that generate, summarize, and rewrite text, convert text into tables, scale images, and even recognize and manipulate objects within images. Microsoft has provided a comprehensive gallery of examples showcasing these capabilities within the Electron framework.
While concerns about vendor lock-in may arise, it is essential to recognize that many JavaScript developers are focused on building cross-platform applications. Those targeting Windows specifically would likely opt for C#. Moreover, both Linux and Apple offer their own OS bindings for various programming languages, indicating that Microsoft’s recent developments are more about catching up with industry trends than enforcing a proprietary ecosystem. The landscape of software development continues to evolve, and Microsoft is adapting accordingly.