Week in Review: What’s Next for JavaScript?
Programming languages are the bread and butter of what The New Stack and its readers do, and our readers flocked last week to what’s become something of an annual tradition at TNS: Mary Branscombe’s roundup of what’s new in ECMAScript, a standard for scripting languages including JavaScript.
Another annual tradition, Stack Overflow’s Developer Survey, was also released last week; Javascript ranked as the most popular language overall (used by 62% of participants) and among professional developers (used by nearly 65%).
Devs like using JavaScript (58% in the Stack Overflow survey said they admire the language, though Rust was most admired, at 82%). But at nearly 30 years old, it remains a work in progress. Mary’s post illuminated a handful of upcoming changes in ECMAScript that aim to make Javascript easier for developers to use. The changes are largely small improvements, but improvements just the same.
“This year there’s a mix of APIs that standardize common patterns that developers have been writing by hand or importing from third-party libraries — including some aimed specifically at library authors — plus improvements in string handling, regular expressions, multithreading and WebAssembly interoperability,” Mary wrote.
One of the approved changes involves the promises feature. First introduced in 2015, “the pattern the promise constructor uses isn’t common elsewhere in JavaScript,” Mary wrote
As a result, the workarounds are cumbersome. “People have this boilerplate pattern that they have to write over and over again, where they call the promise constructor, they get the resolve and reject callbacks, they write those to a variable, and then they inevitably do something else [with them]. It’s just an annoying piece of code to write,” Ecma vice president Daniel Ehrenberg told The New Stack.
In 2024, ECMAScript has accepted the Promise.withResolvers proposal to add a static method to ease this pain point for developers.
“Previously, when you created a promise, the ways that you resolve it and you give it its final state were APIs only accessible inside the function that you built the promise with,” Ehrenberg told TNS. “Promise.withResolvers gives you a way to create a promise and it gives you direct access to those resolution functions.”
We love to dig down into the details of the languages you use every day, to help you use them efficiently and keep tabs on what’s new. Keep watching this space.
— Heather Joslyn, editor-in-chief, TNS
|