Hi Magicians,
I have been drafting an online book on Mojo programming language since last summer. With Mojo’s syntax being stabler and stabler, I finally finished most chapters that reflect the features of the latest Mojo version (25.3). It is called “Mojo Miji - A Guide to Mojo Programming Language from A Pythonista’s Perspective”.
The Miji is designed to help Python users quickly adapt to Mojo, highlighting the similarities and differences between the two languages. It tries to provide additional insights, tips, conceptual models that do not present in the official documentation but would be helpful for understanding Mojo from a Pythonista’s perspective, e.g., quaternary system of variable, four statuses of ownership, diagrams of memory layouts for some data structures and operations, etc. Readers can use this Miji as a complementary resource to the official Mojo manual.
The term “Miji” is derived from the Chinese word “秘籍”, which means “secret book” or “manual”. It is often used to refer to a guide or handbook that provides valuable insights, tips, and shortcuts for mastering a particular subject.
The first four parts of the Miji are summarized as follows.
-
START: The first part introduces how to set up the Mojo environment on your computer so that you can write your first Mojo program.
-
MOVE: The second part first shows you how to convert Python code into Mojo code with three examples. Then it highlights the similarities and differences between the two languages. If you are familiar with Python, after reading this part, you will be able to write Mojo code with a certain level of confidence.
-
BASIC: The third part covers the basic features of Mojo, starting with a conceptual model of variables, and then introducing functions, data types, operators, structs, etc. These features are also present in Python, but Mojo has some differences that you should be aware of. This part will help you to understand the basic syntax and semantics of Mojo.
-
ADVANCED: The fourth part introduces some more advanced features of Mojo, such as SIMD, parameterization, generic, ownership, etc. These features are not present in Python, but they are essential for writing efficient and safe Mojo code.
-
MISCELLANEOUS: The final part covers miscellaneous topics, which may be further integrated into the previous parts in the future. This part also includes a glossary of key terms and concepts related to Mojo, as well as a list of information, tips, and warnings that are scattered throughout the Miji. It is particularly helpful if you are already a Magician but want to avoid common pitfalls and mistakes that I encountered while using Mojo.
Although I am continuing working Part V, a case study that implements a matrix struct with Mojo, I still think that it might be a suitable time now to share this Miji in the community, so that more people, particularly Pythonistas, can join in the Mojo world and make Mojo better and popular.
Since Mojo is still evolving, a lot of things in the Miji will be outdated soon. But I will keep it up to date with the latest Mojo version. I will also add more chapters when more functionalities become stable.
Special thanks to you in advance for your feedback!