Ask anything to Rust Language Team

Rust is a systems programming language that runs blazingly fast, prevents segfaults, and guarantees thread safety.

Featuring

  • zero-cost abstractions

  • move semantics

  • guaranteed memory safety

  • threads without data races

  • trait-based generics

  • pattern matching

  • type inference

  • minimal runtime

  • efficient C bindings

    Ask Rust Language Team about:

  • Getting started with Rust

  • Contributing to Rust

  • Migrating to Rust

  • Performance questions

  • Future plans

  • OSS

  • General Advice

Hosted by:


Hey y'all! A subset of the Rust core team is now here and we'll be answering from our personal perspectives. Keep the questions coming!

EDIT: And we're done! Thanks for the great questions, everyone! This was a lot of fun.

Comments (158)

Sean Griffin's photo

Does pineapple belong in pizza?

Show all replies
Erick Tryzelaar's photo

Why you gotta be like that Aaron? Vim all the way. It's how I got involved in Rust back in 2011.

Alexis's photo

Hi Rust team! Thanks for doing this AMA. One question that beginner developers always ask about Rust is:

With C++17 being such a great and easy-to-use language, why would anyone use Rust?

Would love to hear your thoughts on this.

Mike Kaur's photo

Can I replace my Rails/Django/Flask with Rust? Is it ready for web development already?

Show all replies
Erick Tryzelaar's photo

To add to Steve, there's also a great website, Are We Web Yet, that literally tries to answer this question. The biggest web frameworks that I know of (in alphabetical order):

There are a number of companies using Rust Web Services in production, but offhand I'm not sure which frameworks they are using.

Jeshwanth Kumar N K's photo

I feel learning Rust needs functional programming experience, being coming from C background I am facing difficulty in solving problems rust way.

I would like to learn rust by contributing to the open source code, for now can you please recommend some rust projects where I can contribute as a beginner?

I am also interested in embedded systems, what's the plan to support micro-controllers like ARM cortexM3 and friends? Is anybody is doing work on this?

Show all replies
Steve Klabnik's photo

As for contributing, there's a big drive right now to get people involved with Rust itself and related projects! See https://blog.rust-lang.org/2017/09/18/impl-future-for-rust.html for a big list, or https://www.rustaceans.org/findwork to just dive in.

There's a lot of work on ARM! Check out http://blog.japaric.io/quickstart/; you use the thumbv7m-none-eabi triple for the M3.

https://www.tockos.org/ is also a very interesting project I'm excited about.

U007D's photo

What is your personal vision for Rust in 10 years? I'd love to hear a few random interesting personal highlights from what you hope or envision the Rust language or ecosystem looking like 10 years from now in 2028. Specialty, language feature, adoption pattern, notable success story, however you envision it!

Show all replies
Steve Klabnik's photo

In ten years, I'd like to see Rust become the default systems language of the web. I talked about that in another question though, so you should check that out :)

In ten years, I'd like to see Rust be taught in universities as the go-to low-level language.

In ten years, when someone asks "We need more performance, how do we get it?", "Rust" should be the default answer.

In ten years, I'd like to see crates.io be one of the largest package ecosystems in existence.

In ten years, I'd like to see dozens of books on Rust.

In ten years, I'd like to see Rust have a formal, proven memory model, with fantastic tooling for unsafe code.

Rex Kerr's photo

Complex constraints and code abstractions can be handled in different ways, including with advanced type systems including higher-kinded types (as in Haskell and Scala) or by including advanced code-generation capabilities (as in C++ templates and Scheme macros). Both come with drawbacks, however (large learning curve and difficulty in figuring out where behavior is coming from, respectively).

Other languages (e.g. Go) eschew such features. This makes programming feel simple; simple tasks are simple to understand, and you handle complexity face-to-face (manually--the compiler doesn't help you).

Rust already has a sophisticated type system (especially if lifespans are counted), a robust macro system, and plans are underway to add to both capacities. What is the ideal end-goal? Is there a balance to be had between language simplicity and language expressivity? When should the type system carry the burden of taming complexity and when should metaprogramming (macros)?

Aaron Turon's photo

These questions really strike right at the heart of language design philosophy! Here's my perspective.

In Rust, we try not to be too dogmatic about attributes like "simplicity", "expressivity", and so on. Instead, we're driven as much as possible by use-cases and programmer experience. So, taking higher-kinded types as an example: we've so far avoided adding them, waiting for strong demand and clear use-cases to emerge. While we now have a design that touches on HKT, we're also taking the most simple-minded approach we can that solves real-world use-cases.

This year, we've been really focused on reducing the learning curve, and increasing productivity around Rust. To do that, we've found ways to simplify or clarify existing features that benefit new and existing users alike. In some cases, this means using the information the compiler already has to avoid the need for you to jump through extra hoops. We've done this work with utmost care, ensuring that these improvements don't involve hidden complexities that you have to grapple with eventually. You can read more about the effort here.

The question of expressivity via macros vs the core language is an interesting one. To some degree, we see macros as a way of prototyping things that might become core features eventually; we're developing our async/await story this way.

While Rust libraries definitely do employ macros to do some pretty spectacular things, there are also some particularly common ways to use macros that don't feel so mysterious -- like automatically implementing traits for a particular struct. In my experience, as a client of these macros, I virtually never need to know anything about their implementation.

Sunjay Varma's photo

What RFC or other language feature are you most excited about in Rust?

Show all replies
Steve Klabnik's photo

After custom derive landed in 1.15, I lost my good answer to this question ;)

I'd say the default binding modes in matches, non-lexical lifetimes, and impl trait. The first one is something I run into all the time, the latter are things others run into all the time.

Pearce Keesling's photo

Are there any plans for any sort of official (or at least standard) GUI solution in rust?

Show all replies
Erick Tryzelaar's photo

No plans now. One of our driving philosophies is that we truly want the language and the standard library to be stable in order to make it easy for users to upgrade when we release every 6 weeks (known as the train model). The consequence of this is that we are promising to support that anything added to the standard library. If we followed Python's "batteries included" philosophy, those libraries would be quick to atrophy as we learn better ways to implement things.

So instead we developed Cargo to make it as easy as possible to depend on external resources. There are a few projects trying to make GUIs easy to use with Rust, which you can see on Awesome Rust. I believe the most advanced integration is with GTK, but I don't have much experience in this space, so I could be wrong.

Todd's photo

Explain like I'm 5: Why would I want to use Rust rather than C? Give as many reasons as you can.

Niko Matsakis's photo

Well, not having to start your project by writing a hashtable is certainly a plus. ;)

In general, I'd say that everything we said about C++17 also applies here, but even more so -- e.g., C lacks generics, which means that you either have to write code that uses void* as a stand-in for "some type" (forcing you to use pointers), or else write complex macros or python scripts that generate different copies of your types (been there), or... well, that's kind of it.

Birkenstab's photo

Do you think every security related C code should be rewritten in Rust to prevent vulnerabilities like Heartbleed in the future? And are there already any plans of famous projects to do this?

Show all replies
Erick Tryzelaar's photo

Another great security project that's starting to integrate Rust is Tor. They talk about the branch here.

Sunjay Varma's photo

What do you think the Rust language and ecosystem needs before anyone, even complete beginners to programming, can come in and start writing Rust?

People learn C++ as their first language so Rust is definitely possible too. :)

Show all replies
Niko Matsakis's photo

I find this question very hard to answer. I don't know that there is any one particular thing that we need -- just a steady accrual of resources, as well as the simple matter of gaining more experience in teaching Rust to more diverse groups. It definitely took us some time and iteration to come up with our current methods of teaching Rust, and we are constantly trying to tweak and improve them.

I personally believe that Rust -- or a language much like Rust -- could be a really great first programming language for people. I'd like people to learn the idea of ownership and resource management from day one, before they get used to the idea of omnipresent pointers and aliasing.

(Many people who have not yet tried Rust seem surprised when I say this; I think they imagine that, when you don't have a GC, a great portion of your time is spent worrying about how to manage resources. I at least don't really find that to be the case in Rust: mostly I just write code, and the rules kind of guide me towards what is going to work.)

Anyway, I definitely think that we should be working hard at figuring out the best ways to teach Rust to all audiences. Besides growing Rust, it also has the effect of getting us to think hard about the "essence" of Rust, which can help us to improve the language itself.

Pyry Kontio's photo

Do you have any wishes or plans – no need to be concrete ones or anything – to address the "rental" problem? (References to other fields in the same struct?) I feel that that is one of the next big expressivity problems in the borrow system after non-lexical lifetimes.

Show all replies
Aaron Turon's photo

To add a bit to what Niko said: I anticipate this being a pretty major focus next year, as we try to make our async/await story as strong as possible. That said, I think we should approach it incrementally, and get these key use-cases covered ASAP before going fully general.

Lezwon Castellino's photo

I have come across a Blockchain project where in Rust is being used at the core. Can you tell me how does rust compare to Go for network concurrency stuff? or whats the difference between them and where would I use which one?

Show all replies
Steve Klabnik's photo

Oh, I forgot: so these differences in approach correspond to how you make that choice: Go is convenient, but comes with drawbacks, such as a non-zero cost to call into C code. Rust gives you much more flexibility and power, but also, that means less ecosystem uniformity. Which one is best for your situation is a question only you can answer for yourself :)

Hugo Aguirre's photo

Besides "The book", do you guys recommend any other book? I've been struggling for a while in my path of being a Rustacean.

Show all replies
Aaron Turon's photo

Rust by Example is a great resource as well.

Dara Hak's photo

What got you involved with Rust?

What's the plan with RustBridge? It's interesting, but the website doesn't seem very active.

Show all replies
Steve Klabnik's photo

I answered the former elsewhere, so I'll stick to the second: are you sure you're looking at the right site? https://rustbridge.github.io/ is the correct one. We just held a RustBridge a week ago at Rust Belt Rust, and another one at RustFest Zurich at the start of the month!

One upcoming plan is a teacher training, early next year, to help teach people how to run their own Rustbridges.

sreenivas alapati's photo

Hola Rust gang! What advice you have for beginners coming from python and javascript backgrounds with out any low level programming experience. Any resources targeting them ?

Steve Klabnik's photo

The book is written without the need to have low-level experience; many Python and JS people have told me that they learned well from it.

As far as advice, the biggest hurdles you're going to have are: generics, pointers, and thinking about scopes. It's not insurmountable though! I myself primarily did Ruby before Rust, though I did learn C long long ago.

Danny Feliz's photo

In what cases you wouldn't recommend using Rust?

Show all replies
Niko Matsakis's photo

Well, if you've got a taste for bugs, for one thing. ;)

More seriously, it's a hard question to answer. I've found that I enjoy using Rust in a lot of domains where I wouldn't have expected to -- e.g., simple command-line scripts work out really nicely in Rust, and they run fast, too.

But, overall, Rust is definitely focused on producing polished end-products -- if you want to make something temporary that you plan to throw away, Rust is probably not the language for you, at least not right now. (That said, I'd love to see us make more strides towards better support for "rapid prototyping".)

I would also like to turn the question around: if you were trying a project in Rust, and felt that Rust was really not a good fit, I'd like to hear about it, and why. I'm always looking to know what we can improve. =)

Josh Backstein's photo

For someone who wants to start contributing to the Rust community, what libraries seem to be missing that you think would be most beneficial? And anything simple enough that someone without much experience in Rust could start working on?

Erick Tryzelaar's photo

Wonderful question! We have a community effort going on now called the Libz Blitz, which is trying to make it easy for people to start contributing to significant projects and get them to reach a 1.0 stability.

Karan Sharma's photo

How stable is Gotham? Would you recommend using it to build high scale production ready apps?

Show all replies
Erick Tryzelaar's photo

I haven't tried it either, but if you want to compare Gotham with the other web frameworks, check out rust-web-framework-comparison, which re-implements a simple Hello World service in the various frameworks.

George Kiknadze's photo

I wanted to learn Rust for http://exonum.com/ project, but I think the syntax of the language is quite complicated. In what other development environments can I use it and why it is better than Python or for example Java?

Thanks in advance.

P.S Language actually is very interesting, I think that it has a really lot great features built-in.

Go Rust ! ⚙️

Steve Klabnik's photo

In what other development environments can I use it

Rust is a general-purpose language, so, lots! We support Mac/Windows/Linux, as well as a range of embedded devices and other operating systems. You can also write your own OS in Rust too :)

and why it is better than Python or for example Java?

You'd need more context to say why here; for example, Python is probably easier to learn than Rust, so saying Rust is always "better" is a bit of a misnomer.

One big thing that differentiates Rust from these languages is that Rust doesn't have a VM or runtime the way these languages do. This also means no garbage collector. This means that Rust can reach much farther down the stack; operating systems, device drivers, etc. It's not impossible, technically, to use those languages in these environments, but it's a snap with Rust. Rust will also use much less memory, and have more predictable performance.

Hugo Aguirre's photo

Would you recommend Rust as your first programming language?

Steve Klabnik's photo

Sadly, I can't recommend it today. I used to teach programming professionally; beginners need totally different resources than people who have programmed before. We don't have those resources in Rust. Maybe someday!

David Deprost's photo

What is the plan regarding Rust and Gnome? Is there a complete integration of Rust and GTK planned? In a few years, would it be possible to use Rust for high quality GUI's on Linux? Could such GUI's be ported to the web through Webassembly?

I've been longing for a clean, integrated, powerful, native GUI toolkit for a long time, and I was hoping maybe Rust could be just that ...

In other words, do you eventually envision Rust able to write both the application logic as well as sophisticated graphical stuff?

Niko Matsakis's photo

What is the plan regarding Rust and Gnome? Is there a complete integration of Rust and GTK planned?

I don't know that there is an official plan -- and certainly not an official commitment -- but yes there is ongoing work on making it possible to use Rust seamlessly within a GTK-based system: that is, to access objects written in C (or other languages) and to export objects from Rust for use by other languages. Federico Mena Quintero, for example, has been doing great work on extending the gnome-class plugin, which lets you write GObject-style classes on Rust, and on integrating that with the excellent gtk-rs project, which lets you access all the GTK libraries and so forth from within Rust. See for example this recent thread bikeshedding how to integrate signals and other features.

I really enjoyed the GNOME-Rust sprint that we did in Mexico City -- it was a lot of fun to meet the GNOME developers, and I walked away with a real respect for the excellent engineering that has gone into that codebase (I also thought in general that the two projects were a great "cultural fit"). There is also a second sprint in the works -- I'm sad because I won't be able to attend this one in person, but I'm excited to see what comes out of it.

Adam Perry's photo

WebAssembly is on track to receive a number of features to improve targeting it from languages with large runtimes. What wasm features would you like to see to help Rust be a useful choice for libraries and applications on the web? What work might be done on Rust and in the ecosystem to make it more competitive when targeting the web?

Show all replies
Aaron Turon's photo

To add a bit to Steve's answer: on the wasm side, there's work just getting started in exposing the DOM in a way that Rust can easily work with, without requiring full GC integration (which is still years off). That will immediately increase the power of Rust on the web, and we hope to have the Rust side of that story ready in lock-step with it becoming available.

That said, Rust is already usable via wasm for cases that are not DOM-heavy, i.e. if you have pretty compute-heavy components.

Finally, within the Rust ecosystem, I expect we'll have an explosion of libraries for working in wasm (and binding to web platform APIs, as well as ultimately js libs). The cool thing is that this in many ways resembles the no_std/embedded story for Rust, because wasm out of the box doesn't even give you malloc, let alone files etc. Moreover, wasm often has much stronger binary size constraints than even embedded devices. So I think that working on the wasm-centric ecosystem will also help us push Rust for embedded.

Comfy Weirdo's photo

Hai,

Are there any plans for other platforms to use rust as a primary language? E.g. how the Android framework is with Java

Show all replies
Aaron Turon's photo

Google's Fuchsia is at least adopting Rust as a contender for a lot of the layers surrounding the kernel. Whether it becomes the primary language remains to be seen.

Darin Gordon's photo

What are the risks that a programmer ought to be aware of when using features only available from rust nightly?

Show all replies
Aaron Turon's photo

It really depends a lot on the feature. In some cases, features are relatively stable from the day they land in nightly, and you may never have to update your code. Others are known to be more experimental. We've considered having a finer-grained feature opt-in to make this more clear, but you can always ask the Rust devs.

Delma's photo

Pi or Tau for the ultimate circle constant?

Show all replies
Aaron Turon's photo

I know Tau is "more right" but... Pi.

Delma's photo

What you think about Linear Haskells idea of using linear functions instead of types? Would that have been good enough for Rust? https://arxiv.org/abs/1710.09756

Steve Klabnik's photo

(Submitted on 26 Oct 2017)

I haven't read it yet, so I can't say.

Robert Balicki's photo

Hey! I'm one of the organizers of the Rust NYC meetup. If any of y'all (whether you're part of the Rust team or not!) are interested in presenting, we are always looking for speakers. Message me through meetup :)

Show all replies
Erick Tryzelaar's photo

I'm sadly not in NYC, but I do run the San Francisco meetup (where we are hosting a meetup tonight with a live stream if you are not local).

If anyone is interested in attending (or speaking) at a meetup and you're not in NYC of San Francisco, we have 89 known meetups around the world. Feel free to contact them, or or open a ticket on our community talks repository and we'll help connect you with the local groups.

kev's photo

I'm currently working on code involving cryptocurrencies like blockchain explorers and market aggregators. I know many languages but I mainly use Go and Rust for most things. Unfortunately, this project is going to be very large and I was not comfortable with the delays Rust imposes on the code-build-run cycle, so I went with Go for the core of this project (though I use Rust for other smaller services).

I know incremental compilation has landed and helped a ton, but it's still magnitudes slower than Go compilation. Is there any plans to improve this and is there a timeline (like alternative compiler backends)?

Show all replies
Niko Matsakis's photo

I wrote about compilation times here; short answer: I see lots of reasons to be optimistic!

Ryan Token's photo

I've seen a lot of comparisons recently between Rust and Swift. How do the two compare, and do you view Swift more as competition or as a complement?

Show all replies
Aaron Turon's photo

I see them as pretty complementary, at least right now.

Swift and Rust definitely have a lot of ideas in common, and Swift is even exploring some of the ownership tech from Rust. Where they most diverge, though, is their goals.

Swift's aim, as I understand it, is to be an awesome application-development language, first and foremost. Rust is more aimed as systems development, first and foremost. Each one wants to branch into the other space, but the deep difference in starting points already makes them quite different beasts.

In particular, there are some core aspects of Rust that I can't see us ever changing, nor can I see Swift ever adopting:

  • Rust intends to be usable in as many environments as possible. Thus, it has no runtime, no GC, speaks C natively, and generally speaking can be "just tossed in" as a lightweight component.

  • Similarly, Rust is unwilling to forcibly impose costs or abstractions on top of the underlying system. If you want to work at a higher level, you can do so, and we give you lots of great tools to do so. But we take as a constraint that it's always possible to drop down to "bare metal".

  • Put differently, Rust intends to be appropriate for writing an OS or database in.

  • Rust as much as possible avoids "legacy commitments"; at the libcore level, there are no assumptions about even the surrounding operating system.

That said, we often talk about Rust having three core goals which I think Swift shares: it should be fast, reliable, and productive. I think a lot of the differences between the two come down to a different choice of how to balance between those three goals.

Gregory Panos's photo

What do you think about Rust applicability in the field of cryptography? Not only in technical terms, but also regarding how to attract professional cryptographers to write in Rust. Can we in 5-10 years get a pure Rust OpenSSL replacement which hopefully will be free of all those horrible memory bugs or there is some obstacles which will be hard to overcome?

Steve Klabnik's photo

There's lots of great working going on here!

Specifically with regards to "pure Rust OpenSSL", https://crates.io/crates/ring is an in-progress, bit-by-bit port of BoringSSL to pure Rust + asm.

Alexei's photo

Why does not pass variables by reading by default? Rust is plagued of '&'.

Niko Matsakis's photo

We experimented a lot in this regard, and I think we will likely continue doing so. One thing that we found along the way is that it is very valuable to be able to look at the syntax and have a general idea of when a value is going to be borrowed or moved -- this makes a great deal of different with respect to what you can do with it! We also wanted to avoid the "implicit by-ref" that some other languages offer, where writing foo(x) can wind up mutating x, which can be quite surprising.

That said, I think we've been evolving this story this year. For example, the default binding modes RFC allows one to drop a whole bunch of *, &, and ref when working with matches. I also experiment that some of the ongoing experiments around Copy type coercions will lead to similar improvements, specifically around types like &i32, where the fact that a value is borrowed or not is not typically especially interesting.

(As an aside, one pattern that I personally find nice is to move the & or &mut to the point where a variable is initialized. In other words, instead of doing this:

let x = Foo::new();
use(&x);

You can do this:

let x = &Foo::new();
use(x);

This also serves as a way to signal to your reader that x will not be moved later on.)

Mohammad AlSaleh's photo

Does the fields in traits RFC stand a chance at getting merged in Q1 2018?

Aaron Turon's photo

Definitely! There aren't any serious blockers, it's just been on the back burner. If an enterprising community member wanted to help push it along...

A Dinesh's photo

Any plotting library for scientific community?

Erick Tryzelaar's photo

There's RustGnuplot, but I've never tried using it. I know the scientific community is really into Python these days, so another option to use pyo3, rust-cpython, or rust-numpy to use Python tools to explore Rust objects.

Delma's photo

Would you choose to live forever (assuming you are invulnerable and keep your current health)? Even if that means that you exist at and beyond the heat death of the universe?

Delma's photo

If you could create a new English word, what would it be and what would it mean? Your favourite word (Not necessary English one)?

Delma's photo

What would be the hardest question you could be asked? :P

Delma's photo

Is science invented or discovered?

Aaron Turon's photo

Yes.

As someone who previously had a research career, I think both views are critical. Discovery requires creativity. Inventions require contact with the real world.

In the programming languages realm, you might imagine it's all invention, but that's faaaaar from the case. For example, some of the core ideas in Rust about ownership descend fairly directly from a highly useful connection between mathematical logic and programming languages.

Delma's photo

Zermelo–Fraenkel set theory or homotopy type theory? Or should we accept pluralistic view for foundation of mathematics instead?

Aaron Turon's photo

ZF for me, thanks.

Kashish Grover's photo

Hello and thanks for the AMA! :)

How did you guys end up being part of something as cool as Rust, and what advise would you give to a dev at the beginning of his or her career in tech?

Steve Klabnik's photo

Hi! :D

I was visiting my family for Christmas back in 2012, and saw this on Hacker News: https://mail.mozilla.org/pipermail/rust-dev/2012-December/002787.html

I decided to check it out, really liked it, and went on to write up my experiences as "Rust for Rubyists", which lead to me contributing to Rust's official docs, and now here I am today :)

Delma's photo

Which game is better: Rust or Go?

Steve Klabnik's photo

Super Mario Odyssey.

(I kid, but there's also a deeper truth here; Rust loves to say "X vs Y? We don't choose, the real answer is Z." This is true with things like "Safety vs performance" or "Systems vs usability")

Hadrien G.'s photo

There are lots of great language improvement ideas flying around in the RFC repo. Non-lexical lifetimes, module system revamp, const fns, variadic generics, extensions to the trait system, and so many others... I assume there are a lot more people proposing ideas than people working on the language, so how do you manage to cope with the flux, examine all of the proposals, and prioritize those that get accepted for implementation?

Show all replies
Hadrien G.'s photo

Thanks again! The way you phrase it, managing a large-scale public open source project sure sounds like a good balance of challenging and exciting!

Wesley Norris's photo

Is there anything that was removed from the language that you'd like to bring back in some way (another form, different syntax, etc)?

Show all replies
Erick Tryzelaar's photo

I miss two things from the old days. First, we used to have an anonymous record syntax, where you could just write let point = {x: 1, y: 2}; (I think that was the to define a point without having to declare the type. We then could write json serializers that would transparently render that record out into a json object. Second, sometimes I miss our old closure syntax, which we stole from Ruby. We could write let x = array.map |item| { item + 1 }. It would have made it easier to have pseudo-control flow methods.

Marko Trebižan's photo

Currently Rust is very slow to create some prototypes. Are there some IDEs with better support for creating Rust projects? Also some better intellisense would come handy.

Steve Klabnik's photo

Currently, VS: Code with the Rust plugin and IntelliJ have the best support. They're both under heavy development and improve rapidly!

Dario Cangialosi (deceiving and decaying world)'s photo

what about rust-lang learning resources? "Ask about Getting started with Rust"

Hadrien G.'s photo

A large fraction of the Rust team works at Mozilla, and I've always been a bit curious about how that came to be. I mean, I work with some MLOCs of hairy legacy C++ code at work, so I can understand the desire to have a better systems programming language, but there is a difference between dreaming that and hiring quite a large team to actually make it happen! Could you give me a bit of perspective on this?

Show all replies
Hadrien G.'s photo

Hah, clicking on the link led me to the realization that I had already seen that talk before! But I keep getting amazed at how much Mozilla has invested into this project :)

octoploid's photo

Compile times

What is being done to bring compile time down?

How much slowdown do you see in Firefox build times, now that parts of the browser are written in Rust?

Show all replies
Niko Matsakis's photo

We're doing a number of things to bring down compile times. Obviously the biggest effort is the development of incremental compilation: it's been a long road, but we're really starting to see results, and I expect those to just keep getting better.

See for example this thread on helping us to benchmark incremental compilation -- you can see that for a number of folks, the current system is already starting to work quite well, and there is still lots of room for improvement (for example, we never skip type-checking now).

Besides incremental, I see a number of other promising things going on:

  • The development of ThinLTO allows us to use a lot more parallelization without hurting the performance of the generated code.
  • We've been moving towards a lazy compilation model, which should allow us to more quickly iterate and get to the stage of showing you compilation errors.
  • That same move should eventually enable us to parallelize the compiler's internal workings (right now it is mostly single threaded).
  • Our performance monitoring infrastructure has been completely reworked and is still being improved further. This enables us to see and catch performance regressions much faster.
  • We've still not begun to optimize at the MIR level, but even doing some simple things such as inlining of smaller functions should allow us to reduce the amount of code we supply to LLVM. Better yet, those optimizations occur before monomorphization, so they pay off many times, since a single MIR function may wind up being generated more than once in the LLVM IR.
  • Going forward, I'd like to see a stronger focus on "small bore" performance gains as well. Currently, from time to time, somebody finds an opportunity for gains -- but nobody is actively seeking them out on a longer term basis. I think it'd be great if we had a few people looking at profiles and trying to find those opportunities.
  • Finally, as a kind of side note, we've been doing a lot of fundamental work on the workings of the trait system, which I expect to allow us to improve our trait resolution performance greatly. Since trait resolution currently accounts for a non-trivial fraction of our compilation times, this could be very nice.
Shubham Kumar's photo

Will there be a gitbook on how to approach hacking the rust compiler

Show all replies
Steve Klabnik's photo

Not literally a gitbook, but we are trying to improve documentation on working on the compiler.

Alexandro Perez's photo

I'm a beginner learning about server deployment. I started like most newbies learning JavaScript, and now I'm moving to Node.js but wish to learn a compiled language like Go or Rust.

Are there any advantages of using Rust over Go?

Show all replies
Niko Matsakis's photo

One thing I would emphasize is that Rust's approach to memory management (that is, avoiding a GC) can really dramatically effect the overall memory requirements of your application as compared with a garbage-collected environment. This is true of Go but also other garbage-collected languages. Reducing your memory footprint can in turn enable greater scaling and more even latency (no GC pauses).

This isn't to cast aspersions on Go itself: their runtime is an excellent piece of engineering, and I know they've put a lot of work into minimizing pauses and so forth. But there are definitely benefits to Rust's ownership approach that show up in practice.

Tymoteusz Jankowski's photo

About error handling.. Let's say i'm a crate creator. For now recommended strategy for error handling is to make own error type:

MyLibError

and wrap all possible error with it.

Let's say someones uses my crate and he/she also need to wrap around my error with its own error type. Now when error occurs in 'ending' crate then there is a chain of converting errors, like:

std::io::Error > some-lib1 > some-lib2 > ..

which a lot of conversion is made + a lot of wrapper code is needed

Is there a way of doing it better?