The developers of the Mojo programming language have begun to transition their project materials to open-source. The code for the standard library has been opened first, now available under the Apache 2.0 license with exceptions from the LLVM project that allow mixing with GPLv2 licensed code. In addition to publishing the code, the development process has shifted towards openness and the possibility of incorporating third-party changes through pull requests on GitHub. The source code for the compiler is planned to be opened after the internal architecture design is completed.
Two branches have been created in the repository for the 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 recommended for participants who wish to join the development and share their changes. However, some modules of the library are still closed, but the remaining closed code is also planned to be moved to the open repository over time. The code related to rapidly evolving modules that require additional stabilization, modules scheduled for refactoring, and modules needing further review and rework due to ties with proprietary projects remain primarily closed.
Simultaneously, the release of the Mojo SDK 24.2 toolkit has been published, allowing for project compilation on local systems, along with the release of the MAX Engine 24.2, providing a platform for developments in the field of machine learning. The Mojo SDK includes components necessary for developing applications in the Mojo language, including the compiler, runtime, an interactive REPL shell for building and running programs, a debugger, an extension for Visual Studio Code (VS Code) supporting input autocomplete, code formatting, and syntax highlighting, as well as a module for integration with Jupyter for building and running Mojo notebooks. The MAX Engine complements the SDK with tools for developing and debugging applications using machine learning models in various formats (TensorFlow, PyTorch, ONNX, etc.). Mojo SDK and MAX Engine builds are prepared for the Linux and macOS platforms.
Among the most notable changes in Mojo 24.2:
- Structures and other nominal types can now implicitly conform to traits. For example, any structure that implements the __str__() method implicitly conforms to the Stringable trait and can be used with the str() function.
- The compatibility tools for Python code have been updated to support passing keyword arguments to Python functions. For example, 'plt.plot((5, 10), (10, 15), color="red")'
- Support has been added for passing a variable number of arguments specified via keyword assignment to a function. For example, 'print_nicely(a=7, y=8)'.
- The DynamicVector type has been renamed to List and moved to the collections.list module. The ability to create a list from an arbitrary number of values has been added, for example, 'var numbers = List[Int](1, 2, 3)'.
- Named parameters sep and end have been added to the print() function, allowing you to specify the separator and final output values. For example, executing print("Hello", "Mojo", sep=", ", end="!!!\n") will output "prints Hello, Mojo!!!".
The Mojo project is being developed under the leadership of Chris Lattner, the founder and chief architect of the LLVM project and the creator of the Swift programming language. The syntax of Mojo is based on Python, and its type system is similar to C/C++. The project is presented as a general-purpose language that extends the capabilities of Python with systems programming tools, suitable for a wide range of tasks and combining ease of use for research development and rapid prototyping with suitability for producing high-performance end products.
Simplicity is achieved through the use of the familiar syntax of the Python language, while the development of final products is aided by the ability to compile to machine code, mechanisms for safe memory operations, and the involvement of hardware acceleration resources for computations. To achieve high performance, parallel computing is supported, utilizing all available hardware resources in heterogeneous systems such as GPUs, specialized accelerators for machine learning, and vector processor instructions (SIMD). In intense computing situations, parallelization and the use of all computational resources enable performance that surpasses applications written in C/C++.
The language supports static typing and features for safe low-level memory operations reminiscent of the capabilities of Rust, such as tracking the lifetimes of references and variable borrowing checks (borrow checker). At the same time, it also provides low-level capabilities, such as direct memory access in unsafe mode using the Pointer type, calling individual SIMD instructions, or accessing hardware extensions like TensorCores and AMX.
Mojo can be used both in interpreted mode with JIT and for compilation into executable files (AOT, ahead-of-time). The compiler incorporates modern technologies for automatic optimization, caching, and distributed compilation. Source code written in Mojo is transformed into low-level intermediate code MLIR (Multi-Level Intermediate Representation), developed by the LLVM project. The compiler allows for various backends that support MLIR to be used for machine code generation.
Source: opennet.ru
