Live data from Hacker News

Rust Lang in a nutshell

softax.pl

21–30 of 36 posts

Re: Rust Lang in a nutshell

#21

I'm increasingly intrigued by Rust. Can anyone recommend a good analysis / benchmarking of Rust compared to C/C++ code? Curious how it fares on a performance basis.

You can expect it to be in the same ballpark as C or C++ for single-threaded code, especially if you use idiomatic Rust (combinators instead of manual iteration).

Where Rust shines is that it often takes jaut a few minutes to turn a single-threaded program into a multithreaded program — and the type system guarantees that the program won't have data races.

Re: Rust Lang in a nutshell

#22

Skimming through this, there are syntax errors (e.g. → instead of -> and ’ instead of ' in some function signatures), inconsistencies in code style, and a number of content errors (e.g. the content surrounding early return is still quite wrong and suggests a lack of understanding of the actual feature, expression-orientation; and the description of what &str is; and the description of Copy and copy semantics being si…

The arrow thing is probably just editor font ligatures.

Re: Rust Lang in a nutshell

#23
If you are more of an interactive learner I would recommend installing rust on your machine and then cloning the rustlings repo https://github.com/rust-lang/rustlings.

Rustlings is an interactive collection of rust exercises that are either incorrect or incomplete. The exercises are grouped into key concepts of rust and cross referenced with relevant chapters in the rust book https://doc.rust-lang.org/book/

The general flow is to open up the given chapter of the rust book for a set of exercises and hack away at them until they compile. It's a good way to quickly get an introduction to rust and its core features.

Re: Rust Lang in a nutshell

#24
post #23

If you are more of an interactive learner I would recommend installing rust on your machine and then cloning the rustlings repo https://github.com/rust-lang/rustlings . Rustlings is an interactive collection of rust exercises that are either incorrect or incomplete. The exercises are grouped into key concepts of rust and cross referenced with relevant chapters in the rust book https://doc.rust-lang.org/book/ The gene…

Having gone through rustlings while learning rust, I can say that apart syntax overview, they are almost useless.

I was much more successful by studying the rust book while trying to solve/implement not completely trivial pet projects.

Re: Rust Lang in a nutshell

#25

I'm increasingly intrigued by Rust. Can anyone recommend a good analysis / benchmarking of Rust compared to C/C++ code? Curious how it fares on a performance basis.

Technically it's about the same speed, but idiomatic Rust programs are structured differently, which has its ups and downs.

I wrote an overview of Rust's performance characteristics: https://kornel.ski/rust-c-speed

Re: Rust Lang in a nutshell

#26

Earlier quoted context omitted.

This is by no means scientific, but it’s a fun benchmark, there’s some debate about the fastest Rust options submitted (ie I believe there were faster than C versions that were rejected). C: https://benchmarksgame-team.pages.debian.net/benchmarksgame/... Clang (for common llvm backend between rust and c): https://benchmarksgame-team.pages.debian.net/benchmarksgame/... C++: https://benchmarksgame-team.pages.debian.net…

> This is by no means scientific, It's actually very scientific (testing hypothesis, measuring results, etc) but might not be generalizable.

What's missing in these tests is that they do not capture the required knowledge by the developer to achieve those results.

If anybody has actually checked C/C++ examples, one could see that they use non-trivial techniques/libraries to achieve superior performance.

What would be REALLY interesting to see is breakdown of the performance by the years of experience of people that submitted working code examples.

I have a feeling that a developer with one year of experience in Java, will probably beat developers with two years of experience in C/C++.

Re: Rust Lang in a nutshell

#27

Earlier quoted context omitted.

> This is by no means scientific, It's actually very scientific (testing hypothesis, measuring results, etc) but might not be generalizable.

What's missing in these tests is that they do not capture the required knowledge by the developer to achieve those results. If anybody has actually checked C/C++ examples, one could see that they use non-trivial techniques/libraries to achieve superior performance. What would be REALLY interesting to see is breakdown of the performance by the years of experience of people that submitted working code examples. I have…

Do you have an example of program performance measurements that do "capture the required knowledge by the developer" ?

How can you tell that the knowledge was actually "required" rather than incidental ?

Wouldn't it depend exactly what experience they gained in that one year and how relevant it was to the task at hand?

Re: Rust Lang in a nutshell

#28

Skimming through this, there are syntax errors (e.g. → instead of -> and ’ instead of ' in some function signatures), inconsistencies in code style, and a number of content errors (e.g. the content surrounding early return is still quite wrong and suggests a lack of understanding of the actual feature, expression-orientation; and the description of what &str is; and the description of Copy and copy semantics being si…

The arrow thing is probably just editor font ligatures.

[deleted]

Re: Rust Lang in a nutshell

#29

I'm increasingly intrigued by Rust. Can anyone recommend a good analysis / benchmarking of Rust compared to C/C++ code? Curious how it fares on a performance basis.

This is by no means scientific, but it’s a fun benchmark, there’s some debate about the fastest Rust options submitted (ie I believe there were faster than C versions that were rejected). C: https://benchmarksgame-team.pages.debian.net/benchmarksgame/... Clang (for common llvm backend between rust and c): https://benchmarksgame-team.pages.debian.net/benchmarksgame/... C++: https://benchmarksgame-team.pages.debian.net…

> I believe there were faster than C versions that were rejected

Believe but do not know? Shade?

Re: Rust Lang in a nutshell

#30

I'm increasingly intrigued by Rust. Can anyone recommend a good analysis / benchmarking of Rust compared to C/C++ code? Curious how it fares on a performance basis.

This is by no means scientific, but it’s a fun benchmark, there’s some debate about the fastest Rust options submitted (ie I believe there were faster than C versions that were rejected). C: https://benchmarksgame-team.pages.debian.net/benchmarksgame/... Clang (for common llvm backend between rust and c): https://benchmarksgame-team.pages.debian.net/benchmarksgame/... C++: https://benchmarksgame-team.pages.debian.net…

On par is an understatement. It beats C++ in 8 benchmarks and loses in 2. Quite impressive.

Rust has more potential for better optimisation than C++ because the compiler has full information on pointer aliasing.

Post reply on HN