Today we'll be talking about what's new and what's next with JavaScript in GNOME.
This slide deck is also meant to be a resource that you can consult later. The slides are already available on my web space so if you want to click on the links NOW, you can already go there and follow along with the presentation.
My development experience was pretty good. TypeScript is a good fit for development with the GNOME platform.
Use the typescript template and most of it "just works".
I'll highlight a few things that were confusing.
TypeScript's downleveled code sets the class fields BEFORE the constructor, real JS code sets them AFTER
What's new for GNOME 48 and the upcoming GNOME 49?
This part of the talk is primarily aimed at people who write code for the GNOME platform in the JavaScript programming language, whether that is GNOME Shell, apps, shell extensions, or even command line scripts. GNOME has its own JavaScript engine for all these purposes, GJS, which is an extended version of the JavaScript engine from the Firefox browser.
In past years I talked a lot in the "what's new and what's next" sections about the various ways to modernize your code, but nowadays we are running a pretty modern JavaScript in GNOME already, with no modernization "backlog". The new language features are still pretty exciting, but there's nothing earthshaking like ES6 classes. Additionally, we have a lot more visibility of these improvements these days, with better documentation, a more active community of GJS developers, and initiatives like This Week in GNOME, so a yearly GUADEC talk is no longer the only channel where people find out about these things. Nonetheless, I've gotten feedback that people still find these talks useful, so that's a good reason to keep doing them in addition to all those other things I mentioned.
I almost always have a section on what JavaScript language features are new, when we upgrade the version of the underlying JavaScript engine to one from a newer Firefox. This year we're planning to upgrade to Firefox 140 in GNOME 49.
Excited to see Temporal finally coming to SpiderMonkey as I've been personally working to bring this proposal to JavaScript for the past couple of years! I'm excited to use it in GNOME Shell's JS code at some point.
(screenshot "This is embarrassing, our dates are currently off by a whopping 1900 years")
stream is closed, even if MyFoobar throws!
without waiting for stream to be garbage collected - it's closed when the variable goes out of scope, just like in C++
Using statements are kind of like context managers and with-blocks in Python. They'll be quite useful for explicitly disposing resources, like disconnecting signals and such, which is currently a bit of a hassle in GJS. Relying on it implicitly often runs into problems with callbacks being run during garbage collection. "Using" should help
I never used iterators for years despite them being RIGHT THERE in Python
then I did Advent of Code in Rust and was forced to use them, and now I understand why they're great!
We do already have base64 in GLib
This part overlaps with what I do in my day job at Igalia, as a member of the TC39 committee that standardizes the JavaScript language. I'm excited to present some of these!
There are many more proposals in the pipeline, but these are the ones I'm particularly looking forward to or that I think are relevant to GNOME.
Decorators we've been eagerly awaiting for the better part of a decade! - I first wrote a blog post on designing a decorator API for GObject classes in July 2017.
The proposal later changed to a form that wouldn't work for us, then it changed back to a form that will work for us! So it looks like finally next year or the year after, we might get to use GObject decorators to define classes and properties, the way we already can in Python.
MessageFormat could really revolutionize the way we translate our apps. It's a replacement for the POT file format, with an expressive file format that I hope is easier for translators to deal with than C format strings. The API is being built into JS, but it's not limited to JS. And because the JS-side API is eventually going to be available in web browsers, it's likely there will be very interesting tooling appearing as people adopt the format. But right now it's early to tell.
A big thank you as well to everyone who helped in any way with GJS in GNOME 48 and 49!
Here's the license for this slide deck; you may reuse bits as-is, with attribution, and not for commercial use.
Now it's time for...