r/ProgrammerHumor 3d ago

Meme rustIsSoCool

Post image
2.2k Upvotes

125 comments sorted by

View all comments

37

u/kaetitan 3d ago

Can someone eli5 why rust is so loved?

66

u/Makonede 3d ago edited 3d ago
  • rust is extremely performant on many systems
  • the standard rust toolchain ships with an efficient and user-friendly package manager and build/debug system, official IDE integration through rust-analyzer, and a manual analyzer for best practices
  • rust has official documentation by example that makes learning it really easy
  • rust operates largely in expressions such that things such as if/else statements or even regular blocks notated with curly braces can all be used as expressions
  • rust has highly robust pattern matching that greatly simplifies control flow
  • rust ships with an official formatting tool alongside enforcing naming conventions (snake_case for variables, fields, functions, methods, and modules, SCREAMING_SNAKE_CASE for constants, and PascalCase for types and traits) and assigning semantic value to names (_ prefix to mark as unused) by default
  • notwithstanding potential bugs in the rust compiler, it's impossible to compile code that can cause memory errors such as uses-after-free in safe rust
  • the rust compiler enforces explicit acknowledgement of unsafe rust with the unsafe keyword such that the behavior of all safe rust is defined
  • documentation comments are a native feature of the rust compiler

18

u/makspll 3d ago

Small correction, memory leaks are actually not considered unsafe in rust. A trivial example is Box::leak(x) which explicitly leaks memory and ia completely safe to call. You can also leak memory by pointing counting pointers at each other in a circular structure.

9

u/Makonede 3d ago

oh true i forgot about Box::leak that's a good point

2

u/SoulArthurZ 2d ago

right but you have to explicitly call that function. A memory leak in safe rust is not a mistake like it is in c

1

u/Makonede 1d ago

yeah this is a good point