748 points · by dwaxe · 10y ago · 189 comments
Overall the experience of using Rust for that project has been pretty great; the original requirements for a language were "able to produce static executables with no external runtime requirement, not prone to C-style memory safety issues, and accessible to a team with mostly Python backgrounds". That leaves quite a few options — Go for example — but being a Mozilla project taking the opportunity to use Rust seemed like it would align better with initiatives like those discussed in the article.
Apart from the general niceness of Rust-the-langauge, the experience of the Rust ecosystem has been really nice. Not only were there easy-to-install, well documented, packages to do much of the heavy lifting (http server, command line argument handling, etc.), it was also quite straightforward to set up travis builds using cargo to compile releases for linux64+musl osx and cross-compile releases for linux-arm7hf (added because someone asked about running on raspberry pi and it turned out to be trivial) and win64. The only wrinkle so far has been the difficulty of cross compiling to win32, meaning we might actually need to set up Appveyor or similar.
Obviously this is a much smaller project than the original post in terms of the number of users, and rather different as it is much higher level and could comfortably be written in Python or similar, except for the distribution requirements. However I think the use of Rust has been an unmitigated success, and I would be tempted to use it for a lot more projects that I would never consider writing in C/C++.
I wrote most of the initial implementation of geckodriver and mostly learnt Rust from reading the official book, writing some small patches for Servo, and working on this project (of course); pretty much the same advice you would get coming from any other language.
I just chatted with one of the other major contributors to the project who said that he was able to learn on the job by reading the existing code, looking up concepts in the book or via web searches, and asking questions when necessary; although some parts of Rust undoubtedly have a significant learning curve it is empirically possible to contribute to an existing project without a significant amount of upfront study. This arguably isn't too different from learning most languages, although you are going to need to read up on the rules around e.g. references and borrowing sooner than you would need to look something up if you took the same approach to writing your first Python.
The type system and borrow checker mean that the compiler will tell you if you're doing something wrong which is both a blessing and a curse; it can be dispiriting to get dozens of compile errors when you are getting started, but once you have satisfied the compiler it's possible to be more confident that your code won't break in ways that are relatively common in Python (e.g. missing or broken code for error handling).
So I'm not sure that I answered your question, but in practice it didn't seem to be a major problem. Of course in a different environment — one where people were less enthusiastic about learning a technology their colleagues were raving about, for example — you might have a different experience.
But at the end of the day the borrow checker is enforcing a relatively simple set of rules that you can learn and, with experience, intuit. So after a while the number of mistakes you make goes down, along with their severity. And there is payoff too in the ability to do things that would be impossible in Python and challenging in C e.g. write a copy-avoiding parser in performance critical code (not something too relevant to geckodriver, but useful for a so-far-prototype project to replace the log parsing on Mozilla's CI system — used to extract the reasons a job failed, and responsible for about 80% of the CPU time on that server — with a Rust alternative).
Edit: "Coming from" in the sense of bootstrapping great independent communities around these.
For example Gecko is gaining support for Servo's style engine so maybe CSS will be the first large component merged.
I wonder if Firefox will slowly become written in mostly Rust.
I doubt that will ever happen. Small parts of Firefox, yes, but the browser is enormous. I think I once read that even Servo, which is a showcase for Rust, has more C/C++ code in it than Rust code, largely because it uses Firefox's JS engine.
Not in the core project: https://github.com/servo/servo
Now if only there was a way to isolate stuff at runtime (i.e. a sandbox) to better take advantage of operating system mitigations. I hope that with e10s now (almost) shipping we will start to see some progress towards this. IIRC Mozilla has said they would start to roll out security features (related to e10s) in stages. I'll believe it when I see it but it's nice to finally see this from Firefox since it's been far too long without a defense in depth approach to security from them.
Still wishes a safe parallel renderer to emerge so good luck to the team.
That someone is worried about these issues does not imply that they don't understand the value of telemetry data for developers. It's just a question of tradeoffs, and it's a decision the user should make.
I don't dislike error reporting in programs. I dislike it when programs call home without asking permission.
The restrictions on telemetry on release versions are pretty stringent. It's possible this was measured on release, I'm not aware of the details, but I suspect it wasn't.
(My understanding is based upon whenever I install Firefox it promts me to enable telemetry, which is disabled by default)
Firefox telemetry is opt-out on the Nightly, DevEdition, and Beta channels, but (mostly) opt-in on the Release channel. The opt-in telemetry from the Release channel has limited use because it is not representative of all users.
Here is a list of Firefox's telemetry measurements. Those that are opt-out on the Release channel are tagged "releaseChannelCollection": "opt-out". Adding a new opt-out measurement requires an additional privacy review.
https://hg.mozilla.org/mozilla-central/file/tip/toolkit/comp...
Again, ICBW here.
If it becomes something dependable, infrastructure-wise, like Java, this might mark the beginning of a more serious uptake.
Currently, I believe that this functionality is optional, so distros aren't required to actually ship it just yet.
For the produced binary packages (rpms, debs) it won't matter that much; although it will reduce build dependencies for source packages and give more consistent builds, even if your distribution comes with an _ancient_ version.
In the past, we've explicitly added platform support for this reason, Windows XP comes to mind.
1) Making the "cargo vendor" story work better. rust-url has a bunch of dependencies, and you have to get them all in-tree.
2) More security review & planning. URL parsing is scary! And we'd want to ship & run it alongside the C++ one to check for places where rust-url is not fully web compatible, but there are major privacy issues in reporting back anything more than "1 failure," even for users who have explicitly opt'd in to reporting back data.
But the team is definitely working on both of these pieces and I'd hope to see it in the near future. No timeline / release number promises, though, right now :-)
I followed Rust at the beginning and I was pleased with the design goals of the language. However, I wasn't thrilled with the pre-1.0 documentation, and even after 1.0 there were breaking changes to the language.
Hopefully this is a sign of Rust's maturity. I'll have to look at it again:>)
EDIT: s/from/at/
So I haven't worried about anything per se, but breaking changes are mildly irritating to me. Without a doubt the utility value of some of these changes has been worth it (specifically RFC 1214, which was ironically one of the most major and definitely necessary). I'm not involved enough to be able to speak about other changes.
EDIT: I should also add that the software I work on professionally doesn't use any language that Rust competes with directly. Rust doesn't offer me professional utility so it's easy for me to complain about one thing and ignore all the benefits of Rust. If I were in a situation where I was contemplating using C++, Rust, or maybe Go, I think I would still choose Rust. It's far ahead of its competitors and gets a lot of things right.
> However, implementation of some Java SE 8 features required changes that could
> cause code that compiled with Java SE 7 to fail to compile with Java SE 8.
http://www.oracle.com/technetwork/java/javase/8-compatibilit...Especially in a statically-typed language, technically breaking changes are a fact of life. The key is to make them as minimal as possible, so that you don't struggle to update.
(Oh, and glad to hear you like the errors: we're actually working on making them even better. Elm is really leading the way here...)
So does that mean despite a billion samples between those dates, all samples fell on just three dates?
* Firefox 45: https://telemetry.mozilla.org/new-pipeline/dist.html#!measur...
* Firefox 46: https://telemetry.mozilla.org/new-pipeline/dist.html#!measur...
* Firefox 47: https://telemetry.mozilla.org/new-pipeline/dist.html#!measur...
Also, 45 ESR doesn't include the Rust code on Windows (I heard that's landing in 48, if a Mozillian could please confirm that), so that's a large userbase to not have included in testing.
I think that would be an excellent project for someone, if you should both show all of Flash's capabilities implemented in Rust and that the result was safer it would be an excellent endorsement of Rust. It could also illuminate end user features which can never be made safe. Also good for the overall body of web knowledge.
Emphasis on "met". I've yet to come across a function that can be built in Flash, but not in HTML 5. In fact, I'm not using flashplayer at all anymore and I don't suffer. (There are a few video sites that are still Flash-only, but `mpv --ytdl` works around that very nicely.)
Come to think of it, this is actually not true. At work, I have to use Flash Player for exactly one thing: Adobe Connect. I wonder why they didn't move to Flash yet. ;)
This is great news for the language as it's going to help make sure a wider array of architectures are supported.
Awesome work!
As I read it, they are not shipping Rust but a component written in Rust.
> For this reason, Ralph Giles and Matthew Gregan built Mozilla’s first Rust
> media parser. And I’m happy to report that their code will be the first
> Rust component shipping in Firefox.It's just shocking to me this type of meta-discussion about the phrasing of an announcement headline is the bulk of top comments.
It took me, literally, years before I figured out 'check your brain at the door'.
"Shipping Rust code in Firefox" is what it's about. Though really "Shipping Rust in Firefox" means that too, it's just a bit ambiguous.
Assuming that they ship another language in addition to Javascript would not be completely out of the question. While it seems that with WebAssembly that is no longer necessary, who knows what Mozilla, in search of future funding, may come up with to open new markets. They also tried creating their own OS for mobile - shipping Rust to further its adoption for whatever to me at the moment inconceivable reason is no less improbable.
So yes, I wasn't sure what to expect from the headline - it said they are "shipping Rust" after all, so something crazy was certainly within realm of possibility.
I believe they have mentioned that a WebAssembly target for Rust compilation is something they are working towards, and IMO that would be the ideal way to deploy Rust for a website (if it's a compiled language, there's no need to deliver it uncompiled).
When WebAssembly is finished, stable, and widespread, I guarantee people will be using end-to-end Rust (among other languages).
Small nitpick, I know :)
We need that new moderator quickly! :)