Back to Home
Software

Microsoft lays out a buffet of Windows goodies for JavaScript Developers

Just don’t call the WinRT projection for Node.js a lock-in

t
tech4you AI
July 27, 20263 min read
Share

DEVOPS

Microsoft lays out a buffet of Windows goodies for JavaScript Developers

Just don’t call the WinRT projection for Node.js a lock-in

If you want your JavaScript app to have access to Microsoft's OS features, it's now easier than ever.  Redmond is giving JavaScript and TypeScript devs first-class access to some Windows internals to make their lives easier, via new “dynamic projections,” as Microsoft calls these new language bindings.

JavaScript applications have been seeping onto the Windows desktop for years. Originally designed for the Web, JavaScript — and its more formal TypeScript superset — have been used to build desktop apps as well. 

The Windows Runtime API (WinRT) projection for Node.js, now available in public preview, isn't giving developers access to heretofore-forbidden Windows powers; it just makes it much easier for them to connect to these capabilities. 



Through a Node.js or Electron developer environment, JavaScript developers can write hooks to data-oriented Windows Runtime APIs such as on-device AI, storage, notifications, networking, and other system capabilities.

Bindings at build time

Previously, adding Windows features to JavaScript/TypeScript apps would require writing native add-ons, requiring a C++ or C# bridge, manual translations, and wrapper code for every API, according to Microsoft. Those who do not already know C++, or have a toolchain in place, were obviously left at a disadvantage.

Now, a single Node runtime package, dynwinrt, can generate the needed JavaScript wrappers and TypeScript declarations for the Windows features an app desires. You’ll also need a separate package (winappCli) containing a command-line interface (CLI) setup, configuration, and samples.

The Windows Runtime (WinRT) already has similar accommodations for other languages to call its APIs — including C++, C#, Rust, and Python — using native language projections (generated at compile time for C++ and Rust). In this case, the winappCli code generation feature creates JavaScript wrappers and TypeScript declarations for each API call at build time.

Metadata for the win

The setup relies on Windows Metadata (winmd), introduced in Windows 8, to provide a dynamic list of Windows APIs and their capabilities.  If the API metadata changes, the codegen updates the wrapper or declaration – no manual rewrites required. 

What capabilities can JS/TS developers tap into? Pretty much all of Windows, minus the UI stuff, will be at their command. An app can send notifications that pop up on the user’s screen. Or, it can provide a way for the user to pick files or folders from the hard drive.  Anything captured in winmd is fair game, including APIs for system and device calls covering networking, sensors, globalization, and security. 

Only the UI capabilities have been withheld from the buffet of capabilities laid out before the JavaScript coders (probably because Electron already handles UI on its own). 

All aboard for AI

Of particular interest to the Microsoft top brass, no doubt, are the API calls that JavaScript/TypeScript developers can now make to onboard AI. 

Executives, from CEO Satya Nadella on down, have been stressing the importance of local AI, or AI that doesn’t need to call into one of the increasingly expensive frontier AI Labs

Developers can tap into all sorts of AI capabilities in Windows. Their apps can generate, summarize, and rewrite text. They can convert text to tables. They can scale images, provide descriptions, recognize objects within images and remove them, if requested. The company provided an entire gallery of examples of how to do these tasks within Electron. 

Of course, there is the question of vendor lock-in to consider. Is this another case of Microsoft’s ancient embrace, extend, and extinguish strategy to lure developers onto the proprietary Windows platform with the siren calls of a large user base? 

Doubtful. It’s worth noting that many of the JavaScript developers building desktop apps are building them as cross-platform apps. If they were building Windows-only apps, they’d probably just use C# instead. Both Linux and Apple offer their own OS bindings for various languages as well. So here it’s more a case of Microsoft playing catch-up. Times have changed. ®


Originally published on The Register

Related Articles

Microsoft lays out a buffet of Windows goodies for JavaScript Developers | tech4you