Hacker News new | ask | show | jobs
by swordbeta 2170 days ago
The playground is rather slow, is it possible to run this locally much like how go's tour can?
3 comments

1. Install rustup

2. create a new project with "cargo new foo"

3. add the code to the SRC/too.rs file

4. run with "cargo run"

Yeah. I've been getting quite a few timeouts with compilation. I'd recommend they could just check to see if the code has been modified in the examples, and if it hasn't then just pipe the results out using JavaScript/cached results. There are a few things I'm interested in (such as seeing what printing a void function comes out as) which I can't currently run, and which don't really need anything to do with the server
From what I've heared, Go compiles much faster than Rust. But I'm only experienced in Go...

[Edit] I mean you could just install Rust, copy the samples and run them locally?

Yes, I've noticed the Rust compiler does fancy stuff like check for similarly named constants, check constants have uppercase names, do static analysis to check that I've kept my immutable variables immutable, check that a semicolon is always at the end, and so on. I've never found those necessary in Go...
Most of these are written in such a way that they don't affect the happy path and if they do their pact is negligible. Are you saying that these checks are completely unnecessary, or are you saying that you'd prefer a faster compiler over one with more checks?

Also, we perform many, many more checks beyond the ones you've mentioned, for example https://play.rust-lang.org/?version=nightly&mode=debug&editi... :)

Edit: To expand on "don't affect the happy path": most of those extra lints, checks and suggestions will be performed only if the error condition has been met. If your code doesn't trigger a mutability error, or a missing identifier error (to take from the parent's examples) the searches for suggestions are never executed. For others like style lints, those add some time to processing, but they are linear in time, we tag things that miss a lint during parsing or other passes and then emit them later.

The bigger costs as I understand them, are that everything needs to get passed through LLVM, and that the widespread use of generics increases the amount of generated code that passes through LLVM.
Last I heard, the biggest source of compile time in rustc is emitting absolutely enormous amounts of LLVM IR and leaning on aggressive low-level LLVM optimisation passes to clean things up. There are efforts to make most of these optimisations earlier that have been landing in recent releases, but I'm not sure what the overall state of it is.
I they have started doing work on that? I can't recall what it was exactly, but there was one constant or number (I'm so good at being specific) related one that did the optimization on the rust side instead of on LLVM's side.
Those are negligible in terms of compile time.
Indeed. I suspect this is just the tip of the iceberg?