Live data from Hacker News

Announcing Rust 1.35.0

blog.rust-lang.org

91–100 of 111 posts

Re: Announcing Rust 1.35.0

#91

Coming from C++, this always throws me a bit: if (0..=10).contains(&5) { I assume we are taking a ref to "5" (and not passing by value) because "Range" is a generic type that might be too big to want to copy (or it may not be copyable at all). But taking a reference to a number for a simple operation like this feels... weird. It makes me worry that Rust is going to be passing around pointers to some stack-allocated "…

Wouldn't it be possible to allow passing by value (i.e. moving) if a reference is expected? If I don't need my value afterwards or the type is `Copy`, it shouldn't be a problem, right? Of course, the function would still receive a reference, only at the call site or wouldn't be visible. A clear gain for ergonomy.

Re: Announcing Rust 1.35.0

#92

Coming from C/C++. Is working with the online package manager (Cargo?) mandatory? Or is there a sustainable way of working/developing with Rust while completely offline? I'd like to start a project, manually import libraries (downloaded manually, no dependency hell), read documentation, etc. Is it possible?

I generally prefer to use Make as my build system everywhere, so that I only have to learn the quirks of one system, and it’s easier to handle mixed-language projects.

The documentation for using rustc directly is hard to find, but it’s quite possible to skip Cargo entirely. I’ve had no trouble using it mostly like a C compiler, but I have run into a couple of quirks I needed to work around:

* I haven’t figured out how to get dependency information out of the compiler, so I had to write a likely-fragile script to grep the rust sources.

* In any project, crates have a single, flat namespace. If you want to treat them like you would object files in a C project you’ll need some scheme to prevent name conflicts between subdirectories. The more rust-y thing is to use the module system to include anything that shouldn’t be visible at the top level of your hierarchy.

Otherwise, it’s fairly similar to a traditional compiler:

  rustc main.rs -o my-program # compile an executable
  rustc main.rs --test -o ... # compile the test framework
  rustc --crate-type=rlib ... # make an rlib (roughly equivalent to .o)
  rustc --extern name=path/to/rlib ... # reference another crate (required during compilation)

Re: Announcing Rust 1.35.0

#93
post #83

Earlier quoted context omitted.

I found a comment on /r/rust that details the setup that one guy is using for doing Rust development in an air gapped environment. https://www.reddit.com/r/rust/comments/793evq/using_cargo_on... I do think though, that going down that route might be challenging if you try to do it the first time you are trying to develop in Rust. Furthermore, even then you are starting out with a pre-compiled toolchain and trusting q…

Don't forget, Rust is written in Rust, so if you want to compile Rust from source because you don't trust the precompiled toolchain, you're in for a very long and arduous journey all the way back to the last version of the compiler written in OCaml, and then compiling a bunch of intermediate compiler versions using the previously-compiled version to inch your way towards the current version. I'm not even sure how man…

And if you are really paranoid you would need to audit the code of the compiler in every intermediate step.

Re: Announcing Rust 1.35.0

#94
post #47

Earlier quoted context omitted.

Part of the problem is conceptualizing this as a reference (which, admittedly, it is without optimization). Instead, this is a borrow which indicates that the callee will not mutate the argument. It makes more sense in this context.

> Part of the problem is conceptualizing this as a reference (which, admittedly, it is without optimization). Isn't that also the official name of the feature in Rust? Isn't &T in Rust pronounced "reference to T" and "&mut T" pronounced "mutable reference to T"? That is the impression I get from: https://doc.rust-lang.org/book/ch04-02-references-and-borrow...

Rust doesn't have a syntax distinction for passing by reference vs passing by value (which may sound terrible to a C++ programmer, but Rust has no copy constructors, and types are non-copyable by default, so nothing expensive gets copied by surprise). For example, in the C sense, `Box` is a pointer, and `&str` is a struct passed by value.

Rust is all about ownership, and `&` means "don't free() this".

Re: Announcing Rust 1.35.0

#95

Earlier quoted context omitted.

They exposed all the options. That’s very useful. They made their case. That’s very useful. This is the most discussed feature of Rust ever. The team spent a lot of time and energy on it, way way way more than any other feature. Several team members flip flopped positions several times.

And the team seemed to ignore the users. The two polls I saw, both had the method syntax below 50% approval and below the other front runners. It seemed to me they basically said, "Sure, tell us want you want so we can note it and ignore it." Kind of a real dick move. Why bother even asking for input? (For disclosure, I preferred postfix punctuation similar to `?` that most people hated - so I'm not gettng my way eit…

I'm in favor of the chosen syntax, but I was unaware of the poll, so I'm not sure that's a good representation of Rust users.

Re: Announcing Rust 1.35.0

#96
post #51

Earlier quoted context omitted.

Auditing rust and cargo sounds like easily 1000x more work than copying some source files.

Really? How did you get the source code for those dependencies in the first place? Whatever you used likely has just as much power as Cargo does. (And is perhaps similarly hard to audit.)

A well-tested, regularly audited web browser that is subjected to hacking competitions with monetarily significant rewards.

However, at this point I think we are WAY off the original topic. :-)

Re: Announcing Rust 1.35.0

#97
post #58
post #51

Earlier quoted context omitted.

Auditing rust and cargo sounds like easily 1000x more work than copying some source files.

Why is it more important to audit cargo than it is to audit your dependencies?

I have zero interest in auditing cargo.

Re: Announcing Rust 1.35.0

#98

Earlier quoted context omitted.

It is a reference, yes, and without optimization, is a pointer to a value. Your parent is suggesting to not think of it in such a low-level way, and instead think of it as a permission. In this case, the pointer being optimized away makes more sense, as it’s not really about it being a pointer. I’m of two minds about it, to be honest.

Thanks for the book! A++ would read again. https://www.amazon.com/Rust-Programming-Language-Steve-Klabn...

You're welcome!

Re: Announcing Rust 1.35.0

#99
post #89

Earlier quoted context omitted.

It’s around a thousand builds.

I'm honestly kind of surprised someone's actually gone through the effort of figuring that out, and I'm afraid to ask how long it takes to build the whole chain.

There used to be a file that contained the SHA-1 hashes of the entire bootstrap chain; this is before we went with "rust 1.x builds with rust 1.(x - 1)". so i just counted. About 300 of them, three builds per bootstrap chain, plus some extra for all of the versions since we switched over.

I don't think anyone has actually done so, so I'm not sure how long, but probably a very, very long time. And you can't parallel it.

Re: Announcing Rust 1.35.0

#100
post #92

Coming from C/C++. Is working with the online package manager (Cargo?) mandatory? Or is there a sustainable way of working/developing with Rust while completely offline? I'd like to start a project, manually import libraries (downloaded manually, no dependency hell), read documentation, etc. Is it possible?

I generally prefer to use Make as my build system everywhere, so that I only have to learn the quirks of one system, and it’s easier to handle mixed-language projects. The documentation for using rustc directly is hard to find, but it’s quite possible to skip Cargo entirely. I’ve had no trouble using it mostly like a C compiler, but I have run into a couple of quirks I needed to work around: * I haven’t figured out h…

rustc's docs are here: https://doc.rust-lang.org/stable/rustc/
Post reply on HN