Live data from Hacker News

Welcome to Comprehensive Rust

google.github.io

51–60 of 204 posts

Re: Welcome to Comprehensive Rust

#51
post #20

Earlier quoted context omitted.

Rust is most definitely slow to compile compared to GCC or LLVM for C/C++. This is a known situation and has been since the pre-1.0 days because of the heavily front-loaded macro and borrow systems. It's the tradeoff you have for having a "safe" language vs a "trusting" one. I would argue that it's not as bad as it's made out to be, especially if you're not doing full recompiles and using it on modern (2019+) hardwar…

Rust macros are not the fault for its slowness. expansion is one of the fastest compilation phases. Time is rather spent in other steps like type checking, llvm optimizations and such. The issue is more Rust's generics as they cause a lot of code to be passed to llvm (among other issues for Rust's slowness).

Macro expansion is slow, but only noticeably in the specific situation of a) third-party proc macros, b) a debug build, and c) a few thousand invocations of said proc macros. This is because building in debug mode also compiles proc macros in debug mode, so while the macro itself compiles quickly (because it's an unoptimized build), it ends up running slowly (because it's an unoptimized build).

I know this from observing a ~90s difference between debug and release builds, of a large (mostly auto-generated) crate that had a couple of thousand `#[derive(serde::*)]`s. [1]

This doesn't affect most users, because first-party macros like `#[derive(Debug)]` etc are not slow because they're part of rustc and are thus optimized regardless of the profile, and even with third-party macros it is unlikely that they have thousands of invocations. Even if it is a problem, users can opt in to compiling just the proc macros in release mode. [2]

[1]: https://github.com/Arnavion/k8s-openapi/issues/4

[2]: https://github.com/rust-lang/cargo/issues/5622*

Re: Welcome to Comprehensive Rust

#52
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.

Actually no, one can detect curl-piping server-side and serve hostile blobs only to those foolish enough to do so: https://www.idontplaydarts.com/2016/04/detecting-curl-pipe-b...

Re: Welcome to Comprehensive Rust

#53

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.

Android apps are already compiled to native code, being faster or slower is a matter of developer skills, and how much they paid attention to algorithms and data structures lectures.

Re: Welcome to Comprehensive Rust

#54
post #8

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.

Slower compile times are a small price to pay for memory safety and much higher productivity.

Not an issue on other safer languages, currently on Rust it is mostly having the focus elsewhere.

Re: Welcome to Comprehensive Rust

#55
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.

Useless for graphics and GUI programming.

Re: Welcome to Comprehensive Rust

#56
post #39

It's kind of surprising to see that Rust is so rapidly accepted by wide range of developers. Unfortunately I'm from DataScience field, so I cannot see much motivation to learn Rust, but I am considering learning it, because language itself seems exciting! Is there anyone on HN who is from DataScience field like me and has learned Rust? It would be much appreciated if you could share the experience.

Rust is a safer C/C++. If you'd never consider writing anything in C/C++ (i.e. low-level code where performance is essential), you'll never use Rust.

Re: Welcome to Comprehensive Rust

#57

Earlier quoted context omitted.

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 als…

Based on my personal experience, I think it might also be helpful to have an even shorter version tailored to "Rust for C++ programmers", which I find to be useful because you can mostly just go "ok here's the syntax for basic things, here is how lifetimes work and what problems they solve, here are the replacements for things you are familiar with and why some operations are not available for them". In particular, this lets you skim over "What is the stack? What is the heap?" that many introductions will spend time on.

Re: Welcome to Comprehensive Rust

#58
post #52
post #31

Earlier quoted context omitted.

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.

Actually no, one can detect curl-piping server-side and serve hostile blobs only to those foolish enough to do so: https://www.idontplaydarts.com/2016/04/detecting-curl-pipe-b...

And kibwen's point is that if you're in a situation where you're running potentially hostile binaries from a remote host, the fact that you used `curl | sh` to obtain said binary is not the pressing problem.

Re: Welcome to Comprehensive Rust

#59

Earlier quoted context omitted.

Rust is most definitely slow to compile compared to GCC or LLVM for C/C++. This is a known situation and has been since the pre-1.0 days because of the heavily front-loaded macro and borrow systems. It's the tradeoff you have for having a "safe" language vs a "trusting" one. I would argue that it's not as bad as it's made out to be, especially if you're not doing full recompiles and using it on modern (2019+) hardwar…

It's slower then C for sure. But slower then C++? I doubt it.

C++ is only slower in heavy template metaprogramming.

Additionally thanks to heavy reliance on binary libraries, when starting a new project, we only need to compile our own code.

Re: Welcome to Comprehensive Rust

#60
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.

To be honest, the course suggests using apt since that's an easy security-approved way to install things on our computers (see https://en.wikipedia.org/wiki/GLinux ). I'll be happy to update it to suggest using rustup like "normal". Could you make a PR for that?

Are you sure you're replying to the correct comment?
Post reply on HN