Version: 1.1.0
Mojo tips for Python devs
Mojo looks like Python on purpose. The differences are where performance and safety come from.
You will write types
Python discovers types at runtime. Mojo fixes them when it compiles. Add a type when inference is not the type you wanted.
var is required
A new name uses var. Later assignments update that name. They do not create a new one.
Indentation still matters
Blocks end when the indent ends. There are no braces.
Classes are structs
There is no subclassing. Share behavior with a trait. Fields exist only if you declared them.
Arguments are not all mutable
A function borrows its arguments. If you need to change the caller's value, say mut. If you need to consume it, say owned and pass it with ^.
Errors are marked
A function that can fail says raises. Callers handle it. There is no invisible exception.
Python is still there
Import a module when you want one. Keep the inner loop in Mojo. See Python interoperability.