Rust Lang in a nutshell
softax.pl
softax.pl
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.
I was much more successful by studying the rust book while trying to solve/implement not completely trivial pet projects.
* ToDo list with UI
* Stock Quote retrieval/analysis
* Toy VM/Interpreter
For those with more experience, Rust By Example walks through the same concepts in a more compact form that also lets you experiment with the code in your browser: https://doc.rust-lang.org/rust-by-example/index.html
Try removing the `return` and the semicolon.
It's much denser than "Learn X in Y minutes" but it covers more.
_An Introduction to Rust featuring Carol Nichols and Jake Goulding_, https://www.heroku.com/podcasts/codeish/34-an-introduction-t...
Webcache version - https://webcache.googleusercontent.com/search?q=cache:SHrbch...
let s1 ="hello world";
let s2 = s1; // copied – x1 is still valid
let x1 = 2;
let x2 = x1; // copied – x1 is still valid
println!("{} for the {}nd time!", s1, x1);
Typo in first comment? s1 vs x1?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++.
It's actually very scientific (testing hypothesis, measuring results, etc) but might not be generalizable.
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++.
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?
Believe but do not know? Shade?
Rust has more potential for better optimisation than C++ because the compiler has full information on pointer aliasing.
One of those C++ comparisons is currently multi-core vs sequential.
Several C++ programs were recently removed, which upends things. You might say — "there were faster than [Rust] versions that were rejected".
(The changes were in the last month or two.)
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.
I wrote an overview of Rust's performance characteristics: https://kornel.ski/rust-c-speed