Live data from Hacker News

Rust Lang in a nutshell

softax.pl

11–20 of 36 posts

Re: Rust Lang in a nutshell

#13
post #5

Example for skipping return keyword in case of early return is just wrong. It can be made to work if you have if x > 0 { x } else { x + 1 } but then it isn't early return anymore.

Yeah the early return example is wrong. Demonstration code: https://play.rust-lang.org/?version=stable&mode=debug&editio...

Try removing the `return` and the semicolon.

Re: Rust Lang in a nutshell

#14
post #5

Example for skipping return keyword in case of early return is just wrong. It can be made to work if you have if x > 0 { x } else { x + 1 } but then it isn't early return anymore.

Thank you. We fixed this unfortunate example, and added some more explanation.

Re: Rust Lang in a nutshell

#15
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 simplified beyond what I would consider truth). Overall it’s a decent summary and most of the content seems correct, but be careful.

Re: Rust Lang in a nutshell

#18

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/benchmarksgame/...

Rust is pretty much on par with both C and C++.

Re: Rust Lang in a nutshell

#19

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…

> This is by no means scientific,

It's actually very scientific (testing hypothesis, measuring results, etc) but might not be generalizable.

Post reply on HN