Live data from Hacker News

Welcome to Comprehensive Rust

google.github.io

41–50 of 204 posts

Re: Welcome to Comprehensive Rust

#41
post #36
post #23

Earlier quoted context omitted.

Rust is most comparable to C++ with heavy TMP, as it itself also makes use of templates.

To be precise, Rust generics perform monomorphization, which C++ templates also perform. But I wouldn't go so far as to compare the language to "C++ with heavy TMP", as that's far too broad of a characterization; TMP implies a lot of things, e.g. poor error messages, that Rust doesn't necessarily exhibit.

> TMP implies a lot of things, e.g. poor error messages, that Rust doesn't necessarily exhibit.

That's fair. My comment was mostly about performance.

Re: Welcome to Comprehensive Rust

#42

The first thing I implore everyone to do when evaluating Rust is to check out a non trivial project and start hacking on it. I have always found the compiler to be unacceptably slow in these cases, especially if you come from C rather than C++. If you work your way up from Hello World you may not ever notice this until you already invested a substantial amount of effort.

I class Bevy as a “non trivial” project. It's also an example of how to immediately set new Rust devs up with better system performance to reduce the problem you mention where compilation becomes a bottleneck as a project grows.

https://bevyengine.org/learn/book/getting-started/setup/

The early setup docs offer ways to improve compile speeds. Some help all Rust projects (change your linker) and others are specific to Bevy (enable dynamic linking if you're not on Windows).

Yes, it's a little jarring for an intro to game development with Rust to start with, “first, change a bunch of things so your compile speeds don't suck by default”. But I appreciated it because it helps you evaluate Bevy properly (it's as fast as it'll get from that point) and it also made my non-game Rust project workflows faster.

Bevy also sets expectations well about the initial slow-ish build (“This will take some time as you are essentially building an engine from scratch. You will only need to do a full rebuild once. Every build after this one will be fast!”).

Re: Welcome to Comprehensive Rust

#44

The first thing I implore everyone to do when evaluating Rust is to check out a non trivial project and start hacking on it. I have always found the compiler to be unacceptably slow in these cases, especially if you come from C rather than C++. If you work your way up from Hello World you may not ever notice this until you already invested a substantial amount of effort.

> have always found the compiler to be unacceptably slow in these cases

How slow is "unacceptably" slow?

Personally I do not find this to be an issue the vast majority of the time. Especially in combination with cargo watch which can automatically run a check/build/tests/... whenever a change is made.

Re: Welcome to Comprehensive Rust

#45

Can Rust make Android apps faster ? It feels logical because Rust is close to the metal, but I don't know enough Android or Rust to be sure.

Hi, I wrote the new course. We have been enabling the use of Rust in the Android Platform.

Roughly speaking, the Android Platform is the Linux distribution running below the Android apps we all know. There are a number of daemons running on the system and these are often written in C++. We've now made it possible for Android engineers to write them in Rust instead (or to link in Rust libraries if they want). To do this, the Android build system had to be extended with new rules, see https://source.android.com/docs/setup/build/rust/building-ru....

The overall goal is to have more secure software. Rust removes a whole class of possible security vulnerabilities and we deploy it to make phones more secure. See https://security.googleblog.com/2022/12/memory-safe-language... for details on that.

Re: Welcome to Comprehensive Rust

#46
post #40

Earlier quoted context omitted.

…perhaps you lack experience of a time where fixing bugs that cannot be effectively discovered using tools available in other languages took less time than the equivalent code in Rust would take to compile?

Yet all the tools that exist still don't prevent memory safety bugs found regularly in pretty much any C codebase. Using safe rust will be a productivity boon because of its type system, crate ecosystem and memory safety.

> Yet all the tools that exist still don't prevent memory safety bugs found regularly in pretty much any C codebase.

They can help, but I am well aware of which kinds of bugs existing C tooling cannot catch. I still take issue with your opinion, which hold through this thread, that claims that productivity gains from not having to track these down necessarily outweighs Rust's compile times.

Re: Welcome to Comprehensive Rust

#47
post #30

Earlier quoted context omitted.

Slow compile times can reduce productivity.

Most of the errors can already be caught by running `cargo check` which is substantially faster than rust. Coming from C++ rust's compile times don't feel extraordinarily long.

When I write Rust code most of my errors typically get caught by my language server. Unfortunately, this doesn't help much with making builds faster, though it may reduce the number I may have to do.

Re: Welcome to Comprehensive Rust

#48
post #31
post #22

Earlier quoted context omitted.

I'm tired of installation instructions that consist of "curl | sh". Especially since this one just tries to detect the platform and downloads the correct installer for me. I know what platform I'm running, and I don't want to pipe the internet to my shell. In the end this is unpacking a tarball in ~/.rustup, I don't need the risk of running some bespoke script for that.

Since the ultimate objective is to run a binary blob that you just downloaded off of the internet, piping a script to your shell over HTTPS adds no additional attack surface.

I get what you are trying to say here but I could also make the argument that you actually doubled it because now you have to trust two things rather than one.

Depending on how you want to consider trust in a wider sense too it may even be worse than “double” because I do not have the same amount of trust for the package I am ultimately installing and the script I am using to install it.

Edit: it’s actually 3 things you need to trust I didn’t include curl itself which just released a security audit that found a number of vulnerabilities here https://daniel.haxx.se/blog/2022/12/21/the-2022-curl-securit...

…security is often harder than it looks.

Re: Welcome to Comprehensive Rust

#50

Why would one use this tutorial over the main https://doc.rust-lang.org/book/ ? Apart from the Android specific additions I mean.

From another comment: https://old.reddit.com/r/rust/comments/zrs1of/new_rust_cours...

Thanks for reposting :-)

In general, I feel that the new course will be useful for people who want to teach Rust. If you have a group of engineers and you want to teach them Rust, then this is a ready-to-go solution. You only need to spend some time getting familiar with the material and then you can start teaching it. I don't think there was such a resource before.

For self-study, I really like the Rust book and also Rust by Example. I've listed a bunch of good resources here: https://google.github.io/comprehensive-rust/other-resources.....

Post reply on HN