29 ms·
Shipping Rust code in Firefox
- Noseshine 10y agoAm I'm reading either the headline or the announcement wrong? 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.
- Manishearth 10y agoThat is correct. "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.
- Noseshine 10y agoI would expect the phrase "shipping Rust" to mean that they include the language environment, so that I can write code in Rust with Mozilla.
- deleted 10y ago[deleted]
- wyager 10y agoThat doesn't make sense. It is a statically compiled systems-oriented language, not a web-oriented language.
- deleted 10y ago[deleted]
- maxerickson 10y agoThe headline is nerdview. http://languagelog.ldc.upenn.edu/nll/?p=26094 http://languagelog.ldc.upenn.edu/nll/?p=26094
- smt88 10y agoThere is a whole article that explains the headline. The headline can't include 100% of background.
- Noseshine 10y agoBut a headline can be correct or incorrect. That they changed the headline shows a lot of users thought it was incorrect.
- hyperpape 10y agoI'd say it's nerdview that's going to be read by nerds, and that unlike the examples in that lovely post, it will be understood by the majority of people who read it.
- maxerickson 10y agoSure, it wasn't egregious, but I think the insider perspective idea has lots of explanatory power when it comes to the confusion Noseshine expressed and the surprise wyager responded to the confusion with.
- hyperpape 10y agoWell, obviously we can disagree and I could be wrong, but I think Noseshine's response was a "man bites dog" situation. After thinking about it, I'd still expect the intended audience to see it.
- Noseshine 10y agoWhat does "man bites dog situation" mean? Looking at the Wikipedia explanation for the phrase in the context of journalism it supports my question about the title: Extreme and rare events are more likely to be reported. Obviously shipping "Rust code" is much less noteworthy than "shipping Rust" would be.
- Noseshine 10y agoOf course it doesn't make sense. I'm talking about what the the headline says.
- Sanddancer 10y agoOther browsers have support for statically compiled, safe, systems-oriented languages built in. https://developer.chrome.com/native-client https://developer.chrome.com/native-client
- sctb 10y agoThanks, we updated the HN title to the much more unambiguous form.
- awalGarg 10y agoSort of offtopic, but.. since Manish has already clarified the intent below... I am just curious - would you have drawn a similar conclusion from the headline if the language in question was not Rust, but a more popular/stable one, like say JavaScript/C? "Shipping C in Firefox"? (asking purely from a linguistic point of view)
- akerro 10y agoYou did not think, they would replace VanillaJS with Rust, did you? ;)
- smt88 10y agoThis will happen. Rust can already be compiled to JS, although that's not very practical for client-side work right now. When WebAssembly is finished, stable, and widespread, I guarantee people will be using end-to-end Rust (among other languages).
- Noseshine 10y agoWhat does "replace" have to do with it? Why do you invent the most illogical option possible - that I never uttered - to find a counter argument? 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.
- kbenson 10y ago> While it seems that with WebAssembly that is no longer necessary 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).
- coltonv 10y agoWow you took that joke way too seriously my friend.
- gkya 10y agoMy first thought was that they'd include the compiler in Firefox, when I read the title.
- unethical_ban 10y agoWas it inconceivable for you, after reading the article, to understand what they meant? Is it so shocking a headline that multiple people have commented that "well REALLY it's just compiled code from Rust, not the runtime/source code/etc.". Which one of those possible interpretations makes the most sense? It's just shocking to me this type of meta-discussion about the phrasing of an announcement headline is the bulk of top comments.
- david-given 10y agoDon't underestimate just how easy it is to misunderstand phrases across cultures and languages. It took me, literally, years before I figured out 'check your brain at the door'.
- mkroman 10y agoI'm curious why rust-url still hasn't been shipped with firefox yet. https://bugzilla.mozilla.org/show_bug.cgi?id=1151899 https://bugzilla.mozilla.org/show_bug.cgi?id=1151899
- joelthelion 10y agoI'm guessing because it's an absolutely crucial piece of the browser?
- larsberg 10y agoThere are a couple of big pieces of work here: 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 :-)
- steveklabnik 10y agoFor some context on point 1, https://github.com/rust-lang/cargo/pull/2857 https://github.com/rust-lang/cargo/pull/2857
- swsieber 10y agoIt would be cool for #2 that if a difference was detected, firefox would try to test and generate a general case (or a minimal case) - substituting out sensitive information. I guess sort of like fuzzy testing...
- nickpsecurity 10y agoThat's a great idea. They should consider doing that even if the initial code mighg be convoluted a bit.
- penagwin 10y agoAHHH Telemetry! I feel like there is a group of people who freak out to any form of telemetry, I just wanted to highlight them using it to track bugs. It's super beneficial to any form of changes, especially something like switching an entire language for a component.
- Manishearth 10y agoIIRC the telemetry involved here was only run on the nightly/developer edition versions. Or something like that. 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.
- kevincox 10y agoFrom my understanding release is opt-in only. (My understanding is based upon whenever I install Firefox it promts me to enable telemetry, which is disabled by default)
- Manishearth 10y agoRight, but I think even then you opt in to a very restricted subset. Again, ICBW here.
- cpeterso 10y agoYou are both correct. :) 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/components/telemetry/Histograms.json https://hg.mozilla.org/mozilla-central/file/tip/toolkit/comp...
- nathancahill 10y agoI make a point of enabling Telemetry for Mozilla products. It's probably the easiest way to support the work they are doing.
- empath75 10y agoI'm sort of surprised that this is the first time they've used rust for anything in the browser. I thought they developed Rust for this exact purpose?
- pfraze 10y agoSo far it's only been used in Servo, their next-gen browser project.
- bjz_ 10y agoRust was supported from the start by Mozilla in order to enable the construction of an experimental browser engine (ie. Servo) that was completely separate from Gecko and Firefox. Afaik, there was never any explicit goal at the beginning to rebuild things in Firefox - this is just the result of how successful the language project has been.
- coldpie 10y agoYep, and it's now ready to be deployed. Takes a while to build a language and its environment from scratch...
- bluejekyll 10y agoWill this include iOS devices too? This is great news for the language as it's going to help make sure a wider array of architectures are supported. Awesome work!
- kevincox 10y agoI presume not because IIUC the actual video decoding would be handled by iOS's built in webkit. However I would expect that some rust components would make it to the iOS Firefox in the future.
- TazeTSchnitzel 10y agoFirefox for iOS itself is written in Swift.
- guelo 10y agoFirefox for iOS is just a wrapper around webkit since Apple refuses to allow any alternate engines.
- masklinn 10y agoIIRC, technically alternate (rendering) engines are allowed but you can only execute downloaded code using the system's webkit/JSC (and if you didn't you'd be restricted to a straight interpreter).
- cpeterso 10y agoNo, but Rust code in Gecko will eventually run on Firefox for Android.
- madmax96 10y agoSuper exciting! 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/
- steveklabnik 10y agoWhich post-1.0 breaking changes were you worried about? This is technically correct, but we've managed it in a way that's been hopefully painless to deal with, and the community survey seemed to agree.
- madmax96 10y agoThe compiler has been fantastic emitting warnings about future language changes and I have appreciated it. The Rust compiler's messages (in general) are some of the highest quality I've seen, actually. The Rust Devs have done a superb job at documenting the changes. I'm more complaining that breaking changes to a non-beta language leave a bad taste in my mouth. Sure, they do have to happen sometimes, but it seems that this should be rarer than it has been so far with Rust. 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.
- steveklabnik 10y agoCool, thanks. I mostly want to make sure we don't have any blind spots here; this is an issue we care about deeply. I think it's also important to remember that even languages which are known for "no breaking changes" do introduce breaking changes. Take Java for example, known for being an exemplar in this space. > 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-compatibility-guide-2156366.html 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...)
- gregwtmtno 10y agoEven if Servo doesn't pan out as anything more than an experiment (though I'm optimistic that it will), I think Rust will bring real benefits to Firefox by enhancing security of isolated components like this mp4 parser.
- kevincox 10y agoIf you look on the Mozilla bug tracker you can look at a number of tickets open for integrating servo components into Firefox. 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.
- gregwtmtno 10y ago> 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.
- snuxoll 10y agoSpiderMonkey is probably a long-term target for a Rust replacement or oxidization over time, but considering it is a JIT there's certain classes of issues Rust couldn't help with since native code generation is inherently unsafe.
- Dylan16807 10y agoA JIT doesn't have to be any less safe than compiling Rust code.
- haberman 10y agoIt seems safe to say that a JIT-trace -> Rust -> machine code compilation pipeline will probably never be fast enough to satisfy the requirements of a high-performance JIT compiler.
- radarsat1 10y agoDoes this imply anything regarding rust compiler package for distros? To support the Firefox build, all distros will have to have good rust compiler packages now, right? (I'm sure the status is already not bad, I haven't checked recently..) If it becomes something dependable, infrastructure-wise, like Java, this might mark the beginning of a more serious uptake.
- steveklabnik 10y agoWe've been doing a lot of work in this area, and some distros already have packages. Debian testing, for example. Currently, I believe that this functionality is optional, so distros aren't required to actually ship it just yet.
- snuxoll 10y agoNow that Rust can properly bootstrap from previous versions I can see most distros getting it packaged soon(TM), unfortunately the Fedora 25 change window ends today and since rust/cargo will require new packaging guidelines unless someone really steps up to the plate (I don't have time today) it won't make it in until F26.
- steveklabnik 10y agoAh, bummer. How long between Fedora releases?
- snuxoll 10y ago6 months, all that needs to get in is a proposal (first alpha is a month away so there's plenty of time to flesh it out). We can still package rustc without needing a change, but cargo would be delayed if there isn't a proposal on the wiki before the end of day.
- comzeradd 10y agoThere is already a bug tracking this effort for Fedora https://bugzilla.redhat.com/show_bug.cgi?id=915043 https://bugzilla.redhat.com/show_bug.cgi?id=915043 Also a few unofficial repos for rust/cargo on Copr https://copr.fedorainfracloud.org/coprs/fulltext/?fulltext=rust https://copr.fedorainfracloud.org/coprs/fulltext/?fulltext=r...
- throwawayReply 10y agoThat telemetry graph looks odd, dates filtered from 2016/03/03 to 2016/04/07 but "Number of dates" is "3". So does that mean despite a billion samples between those dates, all samples fell on just three dates?
- DCoder 10y agoIf you click on the image to see the interactive graph, under "Advanced settings" there's a switch "Date range variable: filter submissions by build date range or submission date range", which is set to "build date range". So those "3 dates" correspond to three different build dates.
- cpeterso 10y agoThe telemetry link in the article points to Firefox 45 data. Curiously, the error rates appear to be going up: Firefox 46's error rate is 0.10% and Firefox 47's error rate is 4.35%. * Firefox 45: https://telemetry.mozilla.org/new-pipeline/dist.html#!measure=MEDIA_RUST_MP4PARSE_SUCCESS&max_channel_version=release%252F45 https://telemetry.mozilla.org/new-pipeline/dist.html#!measur... * Firefox 46: https://telemetry.mozilla.org/new-pipeline/dist.html#!measure=MEDIA_RUST_MP4PARSE_SUCCESS&max_channel_version=release%252F46 https://telemetry.mozilla.org/new-pipeline/dist.html#!measur... * Firefox 47: https://telemetry.mozilla.org/new-pipeline/dist.html#!measure=MEDIA_RUST_MP4PARSE_SUCCESS&max_channel_version=release%252F457 https://telemetry.mozilla.org/new-pipeline/dist.html#!measur...
- moosingin3space 10y agoWouldn't that make sense because FF 46 was not an ESR, 47 is the latest, and most users have been pushed to 47? More users are triggering more bugs in the parser. 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.
- arc_of_descent 10y agoThe headline is really wrong. Mozilla is shipping compiled and executable code to us. Now, if its Perl, I can confidently say I'm shipping Perl code to you. Small nitpick, I know :)
- wtetzner 10y agoWell, "shipping" could mean shipping the source too.
- arc_of_descent 10y agoWhy am I being down voted? Is my comment not relevant at all to the topic? Why not just ignore my comment or reply with the advice? We need that new moderator quickly! :)
- djsumdog 10y agoTheir source contains the actual Rust code and it's part of the build process. Distribution build maintainers will compile that rust code when making their packages. I run Gentoo, so that process happens when I upgrade Firefox.
- barackobama123 10y agoMozilla Firefox is very good browser. if anyone have problem visit here http://quickbookssupporthelp.com/mozilla-firefox-technical-support/ http://quickbookssupporthelp.com/mozilla-firefox-technical-s... for solve our problems and issues
- nachtigall 10y agoRust (like Let's Encrypt) is a great thing coming from Mozilla and I'd like to thank them. Edit: "Coming from" in the sense of bootstrapping great independent communities around these.
- alimbada 10y agoAre there other improvements besides the security advantages from this? E.g. performance or memory usage?
- nbaksalyar 10y agoPerformance can be considered a consequence of security/language safety. Rust code is free from data races and developers can utilize concurrency and all available CPU cores without fear.
- moosingin3space 10y agoAs evidenced by Servo.
- topspin 10y agoInteresting question. One assumes they've achieved at least parity with the legacy code, so comparing these in detail would yield some useful insights.
- ChuckMcM 10y agoThis is awesome. Now we just need a rust based flash player :-)
- ffggvv 10y agoOr we should get rid of flash already.
- ChuckMcM 10y agoI see it more like the Chesterson's Fence argument. Flash exists, and continues to plague us, because it met a need for developers that wasn't met in other ways. If that need still exists, rather than remove Flash (can the capability with it) and replace it with the same capability but with a much reduced attack surface. 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.
- majewsky 10y ago> Flash exists, and continues to plague us, because it met a need for developers that wasn't met in other ways. 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. ;)
- llamadrama 10y agoNot sure if this is the case for adobe connect, but other, similar products (such as blackboard's collaborate) are trying to move across to webRTC. This is complicated because Apple doesn't support webRTC yet, which I'd imagine is why Adobe hasn't moved across just yet.
- jgraham 10y agoNot in the same league as the mp4 parser shipping to all Firefox users, but GeckoDriver [1], a Mozilla-authored standalone binary for interacting with Firefox via the WebDriver protocol (e.g. using Selenium) is also written in Rust and shipping, possibly to as many as hundreds of users ;) 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++. [1] https://github.com/mozilla/geckodriver https://github.com/mozilla/geckodriver
- mkesper 10y agoHow did you handle the Python to rust knowledge transition? Do you know any helpful guides?
- amenod 10y agoNot OP, but first few chapters of http://rustbyexample.com/ http://rustbyexample.com/ seem much less steep than The Book (to me). Would also appreciate other guides... (coming from C / Java / PHP / Python myself)
- SShrike 10y agoSeems Rust is moving up in the world!
- OneNoteIsFree 10y agoHow does one donate to Mozilla? Rust and lets encrypt are great community driven stuff for the community
- darkboltyoutube 10y agohttps://www.youtube.com/watch?v=B2KXVfnw4rg https://www.youtube.com/watch?v=B2KXVfnw4rg pokemon go death???