“We see this iteration of tools, frameworks [and] patterns, and over time, we in the standards world start to pick out where the convergence has happened and we try to pave that cowpath, which has the effect of decreasing the complexity in the application stack. So the size of your Node modules directory decreases, because more of that functionality is provided by the language itself.”
Taken with major developments like adding native async in 2017, those incremental features add up, Vercel’s TC39 delegate Justin Ridgewell told the New Stack. “Over a span of years, they add up to a lot of new APIs with new functionality that we’re adding very quickly and then while the smaller things are being added, we’re working on massive features.”
“These massive features, they don’t land every year: maybe every two years, maybe every three years. But when they do get added they really advance the language forward.”
“There’s huge value just in having static types that only exist during development and are fully erased during runtime,” he explained. Some of that value is obvious: “The fact that you can provide type checking and can tell you when you’ve made a mistake, and you’ve dereferenced a property that doesn’t exist: that’s great. But above and beyond that, the type information also powers a number of quality of life improvements for the developer, like the ability to refactor things — such as renaming variables and properties, all at once just automatically in the IDE, as well as code navigation.”
Simplifying Localization with Smarter Message Formats
Localizing websites (and web apps) is more complicated than just swapping out the message strings in the user interface, because if you want those messages to make sense and be grammatically correct, you can’t just swap in words without thinking about how numbers, ordinals (like first and second), dates, plurals and other constructions are handled in different languages.
“Plurals are really difficult,” Igalia’s Romulo Cintra tells us. “All the grammatical concepts, inflections and depending on gender number, and then different placeholders can vary in different languages; [handling] this complexity normally relies on those libraries, but also requires tons and tons of data.”
The work to bring internationalization APIs to the web is so comprehensive that it triggered a major update to the 20-year-old ICU message format API. “It only relies on strings, it’s very rigid, not modular — so why not solve the problem from the root and start a new standard on Unicode,” Cintra wondered. That became MessageFormat 2.0 (MF 2.0 for short) which is designed to be a common ground, handling internationalization for software and the web alike, and it underpins Intl MessageFormat, which he views as the most needed international API to help the web reach the next billion users.
“It’s closing the cycle of providing a more accessible web at the level of localization and personalization.”
“To me as a non-native English speaker,” said Cintra, “it’s extremely important as the web grows and everybody has access [to it], having something like this, that puts in our hands the capability of making more accessible all the software we write, is fantastic!”
Currently, a lot of localization relies on mostly proprietary specifications for custom message formats that have to be parsed at runtime. Mozilla uses its Fluent tool to translate all its interfaces: Bloomberg has an internal tool as well, Igalia’s Ujjwal Sharma told us. “Everybody is trying to tackle this problem through custom tooling that does different things.” While Intl MessageFormat will let organizations who are already doing internationalization build on a common standard, with all the usual advantages of open collaboration, Sharma hopes it will also help smaller organizations that don’t yet have a process for translating sites.
Beyond simply translating text strings, MF 2.0 will include metadata and comments that can be used to mark up everything from the tone of the writing — whether it’s formal or informal — to hints for speech synthesis that will be useful for smart speakers like Siri and Alexa as well as screen readers. That could also remove a bottleneck: “A lot of the innovation in speech and interfaces is happening on the client side,” Sharma noted, but the amount of data has made that impractical for localization: “Intl MessageFormat could enable us to do a lot more client-side”.
Localization is a multimillion-dollar industry so balancing compatibility with the necessary improvements is something of a balancing act. “Providing an easy-to-use intuitive API that can still somehow work with all the legacy effort is a challenging task,” Sharma noted. “But I think if we can do it well, then we can really change some things around how people think about websites.”
A Language for Translating Languages
The MF 2.0 spec defines what you can think of as a simple programming language with name binding (“let” declarations) and pattern matching (selectors), explained Igalia’s Tim Chevalier, who is working on the ICU implementation. He suggested thinking of it as “a domain-specific language for writing translatable messages” that can draw on what we know about writing compilers and interpreters.
If you want to try this out, FormatJS has early support for the initial IntlMessageFormat proposal and there’s an experimental polyfill under development. Because the polyfill is based on tools that are already widely used for internationalizing React and other applications, it will give developers experience with the new syntax required.
Milestones, but Still Plenty to Do
Removing something from the web platform, if it turns out to have been designed the wrong way and needs changing — like the first implementation of web components — has an extremely high cost. Polyfills and tool-based implementations of features that are candidates to become part of the standard allow for the faster feedback cycle that helps protect web compatibility, without making developers wait for all the steps of the formal process.
“We have many implementations; we have a lot of usage,” Ehrenberg said. “Other platforms can be these more experimental environments, and we can be the more conservative implementation environment.”
“When you look at class fields, including private fields and decorators, but also small things like hashbang grammar, and then hopefully soon our type annotations proposal and on-going modules work, they kind of complete the pantheon of things people are doing through tools, that we want to bring into the language,” said Ehrenberg. “CSS is at a similar point, where they’re also bringing in many features that were done through tools into the core language, like nesting — the classic example — or scoping, or layers and variables.”
“I think we’re nowhere near yet running out of things to do that are inspired in that direction.”