M
Modular7mo ago
Wr3kage

Mojo Safety Guarantees

I know mojo is trying to bring a lot of modern features to a "python superset". Rust has been talked about (include ownership/borrow) and rust is known for never crashing (excluding external factors). my question is, how much is the mojo compiler going to force/guarantee safety, or to what extent?
2 Replies
Wr3kage
Wr3kage7mo ago
assuming i use, say fn instead of def?
Melody Daniel
Melody Daniel7mo ago
Mojo has a Rust-style borrow checker (with similar rules) and Lifetimes. If you use fn and struct you're forced to make everything explicit which should give you as much safety as you have in Rust (assuming you don't use unsafe pointer). On the other hand, being a Python superset means Mojo gets to have all the dynamic parts of Python (in class and def) so you can write programs that'll crash at runtime due to type issues.
Want results from more Discord servers?
Add your server