0Pricing
Mojo Academy · Lesson

Mojo's Safe Default

Why value semantics prevents surprise bugs.

Mojo's Safe Default is a free Mojo Academy lesson on CoddyKit — lesson 3 of 4. You can read the complete lesson below for free — then practise it hands-on in the browser with a built-in code editor and a 24/7 AI tutor. It is part of the Mojo Academy learning path, one of 4 lessons in the course, and your progress syncs across the web and the CoddyKit app.

Safe Unless You Say Otherwise

Mojo's default is to give you independent copies. You opt into sharing only when you truly need it. 🛡️

Why a Safe Default Matters

A safe default means the easy path is also the correct path. You avoid bugs without thinking hard about them.

No Accidental Aliasing

Aliasing is when two names secretly share data. Value semantics blocks accidental aliasing, the root of many tricky bugs.

var cart = 3
var copy = cart
copy = 9

Local Reasoning

Because copies are independent, you can understand a function by reading just that function. Outside code cannot reach in and surprise you.

Passing Values Stays Safe

Hand a value to a function and, by default, it works on a copy. Your original is protected from quiet edits.

fn show(n: Int):
    print(n)

Predictable Beats Clever

Code that behaves the same every time is worth more than clever sharing tricks. The safe default trades a little flexibility for trust.

You Still Get Performance

Mojo is smart about copies and can optimize them away when safe. Safety here does not mean slow.

Sharing Is Explicit

When you do want shared or mutable access, Mojo makes you ask for it explicitly. Intent is visible right in the code.

Fewer Footguns

Many languages let one edit silently corrupt distant data. Mojo's value-first default removes that whole class of mistakes.

Confidence to Refactor

When values are independent, moving code around rarely breaks hidden links. You refactor with real confidence. ✅

The Takeaway Mindset

Assume copies unless told otherwise. That single assumption, backed by Mojo's default, keeps reasoning simple.

Quick Check

Why does Mojo default to value semantics instead of sharing data between variables?

Recap

Mojo copies by default, so the easy path is the safe path. Sharing is explicit, aliasing is rare, and reasoning stays local. 🎯

Frequently asked questions

Is the “Mojo's Safe Default” lesson free?

Yes — the full text of “Mojo's Safe Default” is free to read here on the web, and the Mojo Academy course includes 4 lessons in total. To practise it interactively (a built-in code editor and a 24/7 AI tutor) and unlock the rest of the Mojo Academy course, upgrade to CoddyKit PRO.

What will I learn in “Mojo's Safe Default”?

Why value semantics prevents surprise bugs. You practise Mojo Academy with hands-on code you run directly in the browser, and a 24/7 AI tutor answers your questions as you work through the lesson.

Do I need any experience to start Mojo Academy?

No prior experience is required. Mojo Academy on CoddyKit is structured for beginners through advanced learners; this is — lesson 3 of 4, so you can start here or from the beginning and move at your own pace.

How long does the “Mojo's Safe Default” lesson take?

Most CoddyKit lessons take about 5–10 minutes. Each one is bite-sized and interactive, so you make steady progress and pick up exactly where you left off across the web and the app.

Can I write and run code in this Mojo Academy lesson?

Yes. Every Mojo Academy lesson includes a built-in code editor, so you write and run real code right in your browser and get instant AI feedback — no local setup required.

All lessons in this course

  1. What Value Semantics Means
  2. Copies vs Shared State
  3. Mojo's Safe Default
  4. A First Look at Mutation
← Back to Mojo Academy