<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://johnwick.cc/index.php?action=history&amp;feed=atom&amp;title=Rust_Explained_for_JavaScript_Developers</id>
	<title>Rust Explained for JavaScript Developers - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://johnwick.cc/index.php?action=history&amp;feed=atom&amp;title=Rust_Explained_for_JavaScript_Developers"/>
	<link rel="alternate" type="text/html" href="https://johnwick.cc/index.php?title=Rust_Explained_for_JavaScript_Developers&amp;action=history"/>
	<updated>2026-05-07T07:24:35Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.44.1</generator>
	<entry>
		<id>https://johnwick.cc/index.php?title=Rust_Explained_for_JavaScript_Developers&amp;diff=770&amp;oldid=prev</id>
		<title>PC at 08:48, 21 November 2025</title>
		<link rel="alternate" type="text/html" href="https://johnwick.cc/index.php?title=Rust_Explained_for_JavaScript_Developers&amp;diff=770&amp;oldid=prev"/>
		<updated>2025-11-21T08:48:14Z</updated>

		<summary type="html">&lt;p&gt;&lt;/p&gt;
&lt;a href=&quot;https://johnwick.cc/index.php?title=Rust_Explained_for_JavaScript_Developers&amp;amp;diff=770&amp;amp;oldid=769&quot;&gt;Show changes&lt;/a&gt;</summary>
		<author><name>PC</name></author>
	</entry>
	<entry>
		<id>https://johnwick.cc/index.php?title=Rust_Explained_for_JavaScript_Developers&amp;diff=769&amp;oldid=prev</id>
		<title>PC: Created page with &quot;If you already know JavaScript and want to learn Rust fast, this is the perfect beginner’s guide for learning Rust  500px  ⚡ Introduction: Why Are So Many JavaScript Developers Talking About Rust? Rust is having its moment. In just a few years, it’s gone from a language only hardcore systems programmers cared about, to one that’s being used by Google, Microsoft, AWS, and even JavaScript developers. But why is everyone...&quot;</title>
		<link rel="alternate" type="text/html" href="https://johnwick.cc/index.php?title=Rust_Explained_for_JavaScript_Developers&amp;diff=769&amp;oldid=prev"/>
		<updated>2025-11-21T08:45:24Z</updated>

		<summary type="html">&lt;p&gt;Created page with &amp;quot;If you already know JavaScript and want to learn Rust fast, this is the perfect beginner’s guide for learning Rust  &lt;a href=&quot;/index.php?title=File:Rust_Explained_for_JavaScript.jpg&quot; title=&quot;File:Rust Explained for JavaScript.jpg&quot;&gt;500px&lt;/a&gt;  ⚡ Introduction: Why Are So Many JavaScript Developers Talking About Rust? Rust is having its moment. In just a few years, it’s gone from a language only hardcore systems programmers cared about, to one that’s being used by Google, Microsoft, AWS, and even JavaScript developers. But why is everyone...&amp;quot;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;If you already know JavaScript and want to learn Rust fast, this is the perfect beginner’s guide for learning Rust&lt;br /&gt;
&lt;br /&gt;
[[file:Rust_Explained_for_JavaScript.jpg|500px]]&lt;br /&gt;
&lt;br /&gt;
⚡ Introduction: Why Are So Many JavaScript Developers Talking About Rust?&lt;br /&gt;
Rust is having its moment.&lt;br /&gt;
In just a few years, it’s gone from a language only hardcore systems programmers cared about, to one that’s being used by Google, Microsoft, AWS, and even JavaScript developers.&lt;br /&gt;
But why is everyone suddenly obsessed with a language that looks a little… complicated?&lt;br /&gt;
Let’s go back to where it all began.&lt;br /&gt;
Non-Members: Can read for FREE here&lt;br /&gt;
🏗️ How Rust Came Into Existence&lt;br /&gt;
Back in 2006, a Mozilla engineer named Graydon Hoare was frustrated. He was dealing with bugs that could crash systems, security vulnerabilities due to unsafe memory, and the painful debugging process that languages like C and C++ demanded.&lt;br /&gt;
So, he started working on a new programming language that would give:&lt;br /&gt;
* 		The speed of C++,&lt;br /&gt;
* 		The safety of a high-level language, and&lt;br /&gt;
* 		The convenience of modern tools.&lt;br /&gt;
Mozilla later picked up the project, and by 2015, Rust officially launched its first stable release.&lt;br /&gt;
The mission? To build a programming language that prevents entire classes of memory bugs — without sacrificing performance.&lt;br /&gt;
Fast-forward to today: Rust powers everything from browser engines (like Firefox’s Servo) to blockchain nodes, game engines, and even parts of Linux.&lt;br /&gt;
And let me tell you the best part- It’s now easier than ever for web developers — especially JavaScript devs — to learn and use Rust.&lt;br /&gt;
💡 Why This Blog Is Perfect for You&lt;br /&gt;
You already understand programming logic — functions, variables, loops, and data types. That’s 80% of what you need.&lt;br /&gt;
This blog is about the remaining 20% — how Rust does things differently, and why it’s worth learning.&lt;br /&gt;
This blog will provide learning experience with analogies over javascript!&lt;br /&gt;
Let’s start by answering the “why.”&lt;br /&gt;
🚀 Why Rust Exists (and Why It’s Used So Much)&lt;br /&gt;
Rust exists because speed and safety rarely coexist in programming languages.&lt;br /&gt;
* 		JavaScript is safe but not built for performance-heavy tasks.&lt;br /&gt;
* 		C/C++ is fast, but it can easily crash your system if you mishandle memory.&lt;br /&gt;
Rust gives you the best of both worlds: ✅ Performance like C ✅ Memory safety like JavaScript ✅ Zero-cost abstractions (no garbage collector slowing you down like javascript)&lt;br /&gt;
That’s why big companies love Rust. It’s perfect for:&lt;br /&gt;
In short: Rust is what you’d use when JavaScript is too slow, but C++ is too scary.&lt;br /&gt;
⚙️ JavaScript vs Rust — The Mindset Shift&lt;br /&gt;
Before diving into Rust syntax, let’s see how the two differ conceptually.&lt;br /&gt;
Press enter or click to view image in full size&lt;br /&gt;
￼&lt;br /&gt;
You can consider this as analogy to understand that:&lt;br /&gt;
* 		JavaScript is like automatic mode in a car — you focus on driving, and the engine handles everything.&lt;br /&gt;
* 		Rust is manual mode — you get more control, more power, but you must be mindful.&lt;br /&gt;
That’s why learning Rust makes you a better programmer — it teaches you how things really work under the hood.&lt;br /&gt;
🧩 Setting Up Rust&lt;br /&gt;
Before we start coding, you install Rust just once:&lt;br /&gt;
curl --proto &amp;#039;=https&amp;#039; --tlsv1.2 -sSf https://sh.rustup.rs | sh&lt;br /&gt;
Once installed, you’ll use the cargo tool — Rust’s version of npm.&lt;br /&gt;
cargo new hello_rust&lt;br /&gt;
cd hello_rust&lt;br /&gt;
cargo run&lt;br /&gt;
That’s it! You’ve created and run your first Rust app.&lt;br /&gt;
🖋️ Rust Syntax: Side-by-Side with JavaScript&lt;br /&gt;
Let’s explore the basics by comparing Rust with familiar JavaScript concepts.&lt;br /&gt;
🧠 Variables&lt;br /&gt;
// JavaScript&lt;br /&gt;
let name = &amp;quot;Atul&amp;quot;;&lt;br /&gt;
const age = 18;&lt;br /&gt;
// Rust&lt;br /&gt;
let name = &amp;quot;Atul&amp;quot;;&lt;br /&gt;
let age: i32 = 18;&lt;br /&gt;
By default, Rust variables are immutable (like const in JS). To make them mutable:&lt;br /&gt;
let mut count = 0;&lt;br /&gt;
count += 1;&lt;br /&gt;
Themut is like you say yourself:&lt;br /&gt;
“Okay Rust, I promise I’ll change this value responsibly.”&lt;br /&gt;
🔄 Functions&lt;br /&gt;
//Javascript&lt;br /&gt;
function add(a, b) {&lt;br /&gt;
  return a + b;&lt;br /&gt;
}&lt;br /&gt;
//rust&lt;br /&gt;
fn add(a: i32, b: i32) -&amp;gt; i32 {&lt;br /&gt;
    a + b&lt;br /&gt;
}&lt;br /&gt;
Differences:&lt;br /&gt;
* 		You must define parameter and return types (i32 = 32-bit integer).&lt;br /&gt;
* 		No return keyword if the last line is the return value (a Rust thing).&lt;br /&gt;
🔢 Data Types&lt;br /&gt;
JavaScript has loose typing — Rust is strict:&lt;br /&gt;
let age: u32 = 25;  // unsigned integer&lt;br /&gt;
let price: f64 = 99.9;  // floating-point&lt;br /&gt;
let is_active: bool = true;&lt;br /&gt;
let name: &amp;amp;str = &amp;quot;Rusty&amp;quot;;&lt;br /&gt;
Rust catches type errors before running the code&lt;br /&gt;
📦 Arrays and Vectors&lt;br /&gt;
In JavaScript:&lt;br /&gt;
let nums = [1, 2, 3];&lt;br /&gt;
nums.push(4);&lt;br /&gt;
In Rust:&lt;br /&gt;
let mut nums = vec![1, 2, 3];&lt;br /&gt;
nums.push(4);&lt;br /&gt;
The vec![] macro creates a vector, Rust’s dynamic array. You must mark it mut to change it — safe by default, flexible when you allow it.&lt;br /&gt;
🔁 Loops&lt;br /&gt;
for (let i = 0; i &amp;lt; 5; i++) {&lt;br /&gt;
  console.log(i);&lt;br /&gt;
}&lt;br /&gt;
for i in 0..5 {&lt;br /&gt;
    println!(&amp;quot;{}&amp;quot;, i);&lt;br /&gt;
}&lt;br /&gt;
Notice:&lt;br /&gt;
* 		0..5 means from 0 to 4.&lt;br /&gt;
* 		println! is like console.log, but it’s a macro (hence the !).&lt;br /&gt;
⚠️ Error Handling&lt;br /&gt;
In JavaScript:&lt;br /&gt;
try {&lt;br /&gt;
  riskyFunction();&lt;br /&gt;
} catch (e) {&lt;br /&gt;
  console.log(&amp;quot;Error:&amp;quot;, e);&lt;br /&gt;
}&lt;br /&gt;
In Rust:&lt;br /&gt;
fn risky_function() -&amp;gt; Result&amp;lt;(), String&amp;gt; {&lt;br /&gt;
    Err(&amp;quot;Something went wrong&amp;quot;.to_string())&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
fn main() {&lt;br /&gt;
    match risky_function() {&lt;br /&gt;
        Ok(_) =&amp;gt; println!(&amp;quot;Success&amp;quot;),&lt;br /&gt;
        Err(e) =&amp;gt; println!(&amp;quot;Error: {}&amp;quot;, e),&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
Rust doesn’t throw exceptions — it uses Result and Option enums to handle errors safely and predictably.&lt;br /&gt;
Think of it as try/catch, but checked before the program even runs.&lt;br /&gt;
🧱 Ownership — The Big Rust Idea&lt;br /&gt;
This is the part that makes Rust special (and a bit hard at first).&lt;br /&gt;
In JavaScript, memory management is automatic. The garbage collector cleans up unused variables.&lt;br /&gt;
In Rust, you are the garbage collector. But don’t worry — it’s not manual; it’s rule-based.&lt;br /&gt;
Ownership Rules:&lt;br /&gt;
* 		Every value has one owner.&lt;br /&gt;
* 		When the owner goes out of scope, the value is dropped (freed).&lt;br /&gt;
* 		You can borrow references without taking ownership.&lt;br /&gt;
Example:&lt;br /&gt;
fn main() {&lt;br /&gt;
    let s1 = String::from(&amp;quot;Hello&amp;quot;);&lt;br /&gt;
    let s2 = s1; // ownership moved&lt;br /&gt;
    // println!(&amp;quot;{}&amp;quot;, s1); // ❌ error: value moved&lt;br /&gt;
    println!(&amp;quot;{}&amp;quot;, s2);&lt;br /&gt;
}&lt;br /&gt;
In JavaScript terms:&lt;br /&gt;
let s1 = &amp;quot;Hello&amp;quot;;&lt;br /&gt;
let s2 = s1;&lt;br /&gt;
console.log(s1); // works fine&lt;br /&gt;
Rust prevents bugs like double free, dangling pointers, and race conditions by making ownership rules part of the language.&lt;br /&gt;
It feels strict at first, but it makes your programs rock-solid.&lt;br /&gt;
🧩 Borrowing and References&lt;br /&gt;
If you want to “use” a value without taking ownership, you borrow it:&lt;br /&gt;
fn print_name(name: &amp;amp;String) {&lt;br /&gt;
    println!(&amp;quot;{}&amp;quot;, name);&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
fn main() {&lt;br /&gt;
    let name = String::from(&amp;quot;Atul&amp;quot;);&lt;br /&gt;
    print_name(&amp;amp;name);&lt;br /&gt;
    println!(&amp;quot;{}&amp;quot;, name); // still valid!&lt;br /&gt;
}&lt;br /&gt;
Here, &amp;amp; means “borrow,” just like passing by reference.&lt;br /&gt;
In short:&lt;br /&gt;
* 		&amp;amp;T = borrow (read-only)&lt;br /&gt;
* 		&amp;amp;mut T = borrow mutably (editable)&lt;br /&gt;
🧮 Structs (Like Objects in JS)&lt;br /&gt;
JavaScript:&lt;br /&gt;
const user = { name: &amp;quot;Atul&amp;quot;, age: 18 };&lt;br /&gt;
console.log(user.name);&lt;br /&gt;
In Rust:&lt;br /&gt;
struct User {&lt;br /&gt;
    name: String,&lt;br /&gt;
    age: u8,&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
fn main() {&lt;br /&gt;
    let user = User {&lt;br /&gt;
        name: String::from(&amp;quot;Atul&amp;quot;),&lt;br /&gt;
        age: 18,&lt;br /&gt;
    };&lt;br /&gt;
    println!(&amp;quot;{}&amp;quot;, user.name);&lt;br /&gt;
}&lt;br /&gt;
Structs in Rust are the backbone of data modeling — similar to JS objects but with strict typing and compile-time checks.&lt;br /&gt;
⚙️ Enums (Like Tagged Unions or Type Variants)&lt;br /&gt;
In JS, you might use strings or objects to represent states:&lt;br /&gt;
let status = &amp;quot;Success&amp;quot;;&lt;br /&gt;
In Rust:&lt;br /&gt;
enum Status {&lt;br /&gt;
    Success,&lt;br /&gt;
    Error(String),&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
fn main() {&lt;br /&gt;
    let s = Status::Error(String::from(&amp;quot;Oops&amp;quot;));&lt;br /&gt;
}&lt;br /&gt;
Enums in Rust are much more powerful — they let you model complex logic cleanly and safely.&lt;br /&gt;
🧠 Pattern Matching&lt;br /&gt;
One of Rust’s most elegant features — match.&lt;br /&gt;
let number = 2;&lt;br /&gt;
&lt;br /&gt;
match number {&lt;br /&gt;
    1 =&amp;gt; println!(&amp;quot;One&amp;quot;),&lt;br /&gt;
    2 =&amp;gt; println!(&amp;quot;Two&amp;quot;),&lt;br /&gt;
    _ =&amp;gt; println!(&amp;quot;Something else&amp;quot;),&lt;br /&gt;
}&lt;br /&gt;
It’s like a switch statement in JS but smarter and exhaustive — Rust ensures you handle all possible cases.&lt;br /&gt;
🔄 Asynchronous Programming&lt;br /&gt;
JavaScript has async/await, and so does Rust — but with a twist.&lt;br /&gt;
In JS:&lt;br /&gt;
async function fetchData() {&lt;br /&gt;
  const res = await fetch(&amp;quot;https://api.com/data&amp;quot;);&lt;br /&gt;
  return await res.json();&lt;br /&gt;
}&lt;br /&gt;
In Rust:&lt;br /&gt;
async fn fetch_data() -&amp;gt; Result&amp;lt;(), reqwest::Error&amp;gt; {&lt;br /&gt;
    let res = reqwest::get(&amp;quot;https://api.com/data&amp;quot;).await?;&lt;br /&gt;
    println!(&amp;quot;{:?}&amp;quot;, res.text().await?);&lt;br /&gt;
    Ok(())&lt;br /&gt;
}&lt;br /&gt;
Both feel similar, but Rust’s async is compile-time checked, meaning fewer runtime surprises.&lt;br /&gt;
🧰 Tooling: Cargo Is Your npm on Steroids&lt;br /&gt;
Rust’s ecosystem is clean and unified.&lt;br /&gt;
* 		cargo new project_name → create a project&lt;br /&gt;
* 		cargo run → run your project&lt;br /&gt;
* 		cargo build --release → optimized build&lt;br /&gt;
* 		cargo test → run tests&lt;br /&gt;
* 		cargo fmt → format your code&lt;br /&gt;
All built-in. No need for third-party CLIs.&lt;br /&gt;
💪 Why JavaScript Developers Should Learn Rust&lt;br /&gt;
If you’re used to JS frameworks and quick iteration, Rust might feel rigid at first. But once you adapt, it changes how you think about code.&lt;br /&gt;
You’ll:&lt;br /&gt;
* 		Write fewer bugs&lt;br /&gt;
* 		Understand memory and performance&lt;br /&gt;
* 		Gain access to WASM, embedded, and system-level programming&lt;br /&gt;
* 		Make your web apps blazingly fast&lt;br /&gt;
In fact, tools like Next.js, Parcel, and Deno already use Rust under the hood for performance.&lt;br /&gt;
So even if you never write a full Rust app, learning it helps you understand what’s powering the ecosystem you already use.&lt;br /&gt;
🌐 Rust + WebAssembly: The Perfect Bridge&lt;br /&gt;
Again, The best part? You can compile Rust to WebAssembly (WASM) and use it inside your JavaScript app.&lt;br /&gt;
For example:&lt;br /&gt;
* 		JS handles the UI and DOM&lt;br /&gt;
* 		Rust handles complex logic (math, crypto, physics, etc.)&lt;br /&gt;
That’s how frameworks are building the next generation of high-performance web apps.&lt;br /&gt;
🔚 Conclusion: You’ve Got This&lt;br /&gt;
Learning Rust as a JavaScript developer is like going from a comfy sedan to a high-performance race car. It demands more attention, but the control and speed are worth it.&lt;br /&gt;
You already understand the logic — Rust just adds discipline, safety, and performance to the mix.&lt;br /&gt;
If you’re ready to move beyond the browser and into the world of system-level performance, Rust is the next logical step.&lt;br /&gt;
And remember:&lt;br /&gt;
The compiler is not your enemy — it’s your mentor.&lt;br /&gt;
Happy coding, or as Rustaceans say, 🦀 “Fearless concurrency starts here.”&lt;br /&gt;
&lt;br /&gt;
Read the full article here: https://javascript.plainenglish.io/rust-explained-for-javascript-developers-c7b0df4b4674&lt;/div&gt;</summary>
		<author><name>PC</name></author>
	</entry>
</feed>