Mojo Toolkit 24.2 Update: A Guide to the Standard Library Opening in Mojo Language

Programming language developers Mojo started translation developments of the project into the category of open source software. The first to open the code librarieswho is now available under license Apache 2.0 with exceptions from the LLVM project allowing mixing with GPLv2 licensed code. In addition to publishing code, the development process has shifted towards openness and the ability to communicate third-party changes through submitting pull requests to GitHub. The source code of the compiler is planned to be opened after the design of the internal architecture is completed.

The repository has two branches with Mojo standard library code: the main branch, synchronized with the latest stable release of Mojo, and the nightly branch, reflecting the current development process and synchronized with the nightly builds of Mojo. The nightly branch is encouraged to be used by participants who wish to join the development and share their changes. At the same time, some of the library modules are not yet open, but after some time the remaining closed code is also planned to be moved to an open repository. The code of rapidly developing modules that require additional stabilization, modules for which refactoring is planned, and modules that require additional review and rework due to connections with proprietary projects remains closed.

Advertisement

Simultaneously published release of the Mojo SDK 24.2 toolkit, which allows you to compile projects on the local system, and release engine MAX Engine 24.2, which offers a platform for development in the field of machine learning. The Mojo SDK includes the components necessary for developing applications in the Mojo language, including a compiler, runtime, an interactive REPL shell for building and running programs, a debugger, an add-on for the Visual Studio Code (VS Code) code editor with support for input completion, code formatting and syntax highlighting, a module for integration with Jupyter for building and running Mojo notebook. MAX Engine complements the SDK with tools for developing and debugging applications that use machine learning models in various formats (TensorFlow, PyTorch, ONNX, etc.). Mojo SDK and MAX Engine builds prepared for Linux and macOS platforms.

Among most notable changes in Mojo 24.2:

  • Structs and other nominal types can now implicitly map to traits. For example, any structure for which the __str__() method is implemented implicitly corresponds to the Stringable trait and can be used with the str() function.
  • Python Compatibility Tools have added support for passing keyword-based arguments to Python functions. For example, “plt.plot((5, 10), (10, 15), color=”red”)”
  • Added support for passing a variable number of arguments to a function, specified through keyword assignment. For example, “print_nicely(a=7, y=8)”.
  • The DynamicVector type has been renamed to List and moved to the collections.list module. Added the ability to generate a list based on an arbitrary number of values, for example, “var numbers = List(Int)(1, 2, 3)”.
  • Named parameters sep and end have been added to the print() function, through which you can set the separator and final output values. For example, executing print(“Hello”, “Mojo”, sep=”, “, end=”!!!n”) will result in the output “prints Hello, Mojo!!!”.

The Mojo project is being developed under the leadership of Chris Latner (Chris Lattner), founder and chief architect of the LLVM project and creator of the Swift programming language. The project is presented as a general purpose language, expanding The capabilities of Python as a systems programming language that is suitable for a wide range of tasks and combines ease of use for research development and rapid prototyping with suitability for the formation of high-performance end products.

Mojo's syntax is based on the Python language, and the type system is close to C/C++. The first is achieved through the use of the familiar syntax of the Python language, and the second through the ability to compile into machine code, memory-safe mechanisms, and the use of hardware acceleration tools. To achieve high performance supported parallelization of calculations using all available hardware resources of heterogeneous systems, such as GPUs, specialized accelerators for machine learning and vector processor instructions (SIMD). For intensive calculations, parallelization and utilization of all computing resources makes it possible to achieve performance superior to C/C++ applications.

Advertisement

The language supports static typing and low-level memory-safe features reminiscent of Rust, such as reference lifetime tracking and borrow checker. At the same time, the language also provides opportunities for low-level work, for example, it is possible to directly access memory in unsafe mode using the Pointer type, call individual SIMD instructions, or access to hardware extensions such as TensorCores and AMX.

Mojo can be used both in interpretation mode using JIT, and for compilation into executable files (AOT, ahead-of-time). The compiler has modern technologies built into it automatic optimization, caching and distributed compilation. Mojo source code is converted into low-level intermediate code MLIR (Multi-Level Intermediate Representation), developed by the LLVM project. The compiler allows you to use various backends that support MLIR to generate machine code.

Thanks for reading:

Advertisement