Pernah dengar berita "aplikasi crash karena null pointer" atau "memori bocor di server"? Itu bug klasik dari C/C++ yang udah berdekade ada — sampe Microsoft bilang 70% security CVE mereka berasal dari memory bug. **Rust** = solusi: bahasa system-level yang nge-block bug ini di compile time, tanpa garbage collector. Performa setara C++, tapi compiler maksa kamu nulis kode aman. Dropbox, Discord, Cloudflare, Microsoft, Linux kernel sekarang pake Rust untuk komponen kritis.
💡 Stack Overflow Most Loved 9 tahun berturut-turut. Survey developer global, Rust selalu di puncak "bahasa yang paling disukai". Kompiler Rust strict (kamu bakal stress di awal), tapi sekali kompile = jalan. "If it compiles, it works" — vibes yang bikin developer addicted.
Kenapa Belajar Rust?
- Memory safety tanpa GC — Ownership system mencegah null pointer, dangling pointer, dan data race pada saat kompilasi
- Performa setara C/C++ — Zero-cost abstractions, tanpa runtime overhead
- Loved by developers — Bahasa paling disukai di Stack Overflow Survey bertahun-turut
- Ekosistem modern — Cargo (package manager), crates.io, tooling yang excellent
Rust di Web Development
Rust semakin banyak digunakan di ekosistem web:
- Actix Web / Axum — Web framework dengan performa luar biasa
- WebAssembly (Wasm) — Compile Rust ke Wasm untuk menjalankan kode di browser
- Tauri — Alternatif Electron yang ringan untuk desktop apps
- Tooling — SWC (pengganti Babel), Turbopack, rspack ditulis dalam Rust
Hello World
fn main() {
println!("Hello, World!");
}
Setiap program Rust dimulai dari fungsi main(). Macro println! digunakan untuk mencetak teks ke konsol — perhatikan tanda seru ! yang menandakan ini adalah macro, bukan fungsi biasa.
🎭 Analogi sehari-hari
C/C++ = mobil sport tanpa airbag — sangat cepat, tapi salah dikit = crash fatal. Garbage-collected (Java/Go/JS) = mobil keluarga aman tapi punya supir tambahan (GC) yang bikin lambat sesekali. Rust = mobil sport dengan airbag yang gak ngurangi performa. Compiler maksa kamu drive aman, tapi setelah lulus check, full speed tanpa overhead. Best of both worlds.
⚠️ Jebakan yang sering ditemui
- Borrow checker bikin pusing — error compile yang aneh-aneh di awal. Belajar konsep ownership dengan teliti
- "Fighting the compiler" jadi meme — proses normal pemula. Sabar, makin lama makin lancar
- Slow compile time — Rust compile lebih lama dari Go. Trade-off untuk safety
- Async di Rust kompleks — Tokio runtime, lifetime di async function = challenging
- Overkill untuk script sederhana — pakai Python/JS untuk one-off task
TL;DR: Rust = bahasa system-level dengan memory safety tanpa GC. Compiler strict mencegah null pointer / data race / memory leak. Performa setara C++. Stack Overflow Most Loved 9x. Dipake Dropbox/Discord/Cloudflare/Linux kernel untuk komponen kritis. Steep learning curve (borrow checker), tapi reward besar untuk performance + reliability.