--j id: KrmgjrqydqC65v4Za1t6c title: Rust desc: "" updated: 1659872186436 created: 1622307866939
The main thing why i and other people want rust ... is that it does not have programming.undefined-behavior in the safe subset.
Features
- Shared & exclusive references
- MOdules & visibliity
- Generics
- Lifetimes
- Stricter type systems
- Pattern matching
- Safe/unsafe split
- RAII
- Sum typesPowerful hygienic and procedural macros
- standalone standard library
- Vocabulary types like
Result
andOptions
- Pinning
- Formating
- Checked, saturating & wrapping integer arithmetic primitives
- Iterators
- Vocabulary types like
- tool
- documentation generator
- unit & integration tests
- static analyzer
- c<->rust bindings generators
- linter
- formatter
- IDE tooling
- macro debugging
- UBSAN-like interpreter
- plust the usual friends: gdb, 11db, perf, valgrind
Nuggets
- functions use the
fn
keyword. This is just likefunction
in javascript. - Macros are called just like functions but with the additional
!
before the parenthesis. - Strings in rust use double quotes
"
. You cannot use'
or ```. - Unlike JavaScript, semicolons in Rust are not optional. Every statement in Rust must end with a semicolon.
- Every Rust program needs to have a
main
function. - all variables created using
let
are immutable by default. (You just can't assign them more than once.) - The
mut
keyword allows the variable to be mutable. const
are compile time known constants, Rust will not infer their type for you and you will need to provide a type- Since most of us are using 64-bit machines these days, stick to
u64
,i64
andf64
unless you have a good reason. - The
::
in Rust is much like the dot operator in JavaScript when it comes to types and namespaces. - all elements in an Array must be of the same type.
cargo
will by default look forsrc/main.rs
and use thepackage.name
field as the binary name- Packages can have lang.rust.t.target, lang.rust.t.target, lang.rust.t.target, lang.rust.t.target, and lang.rust.t.target targets.
What can I do with Rust?. A small, incomplete list.
- Serverless functions
- Serverful services
- Embedded programming for microcontrollers, Arduinos, or Raspberry Pis
- CLI tools
- Enhance the performance of JS/Ruby/Elixir/etc by calling out to Rust
- Compile to Wasm and deploy to the edge, browser, and more
- Game development
- Operating systems and shells
bundler
ui
- https://github.com/linebender/druid
- https://github.com/iced-rs/iced
- https://github.com/antoyo/relm
- https://github.com/anp/moxie
- https://github.com/PistonDevelopers/conrod
- https://github.com/sixtyfpsui/sixtyfps
- https://dioxuslabs.com/blog/introducing-dioxus/
Links
- Small exercises to get you used to reading and writing Rust code!
- Rust from a JavaScript perspective
- Rust Is The Future of JavaScript Infrastructure
- https://docs.rs/
- Good intro into rust
- https://product.letsgetrusty.com/
- rust cheat sheet
- Should you, a JavaScript developer, learn Rust in 2022?
- GitHub - uutils/coreutils: Cross-platform Rust rewrite of the GNU coreutils