Published release of the Mojo 24.3 programming language toolkit, which allows you to compile projects on the local system. Includes components needed to develop 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 highlighting syntax, module for integration with Jupyter for building and running Mojo notebook. Mojo Standard Library Sources open under the Apache 2.0 license with exceptions from the LLVM project allowing mixing with code under the GPLv2 license. The source code of the compiler is planned to be open after the design of the internal architecture is completed.
Simultaneously formedvoan engine release MAX Engine 24.3, which offers a platform for development in the field of machine learning. MAX Engine complements the Mojo toolkit 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 changes in Mojo 24.3:
- In modules for working with collections (List, Dict, Set And Tuple) features have been added to make them more familiar to users familiar with the Python programming language. Added methods to the List type that replicate the Python API, such as pop(index), resize(new_size), and insert(index, value).
- An update() method has been added to the Dict type to update a key/value from another Dict.
- The Tuple type supports memory-only types such as String, allowing you to specify “x = tup(1)” instead of “x = tup.get(1, Int)()” and assign values via “tup(1) ) = x”.
- The Set type provides support for named methods that can be used instead of operators: difference() instead of “-“, difference_update() instead of “-=”, intersection_update() instead of “&=”, and update() instead of “|=”.
- Added the reversed() function, which allows you to reverse the order of elements. The reversed() function can be used with List, Dict, and any type that supports ranges.
var numbers = List(1, 2, 3, 4, 5) for number in reversed(numbers): print(number)
- Implemented type Boolablewhich returns True for variables of type Dict, List, and Set if they contain at least one element.
- Improved support for variable arguments. It is possible to define functions that contain both optional and variable arguments.
fn variadic_arg_after_default( a: Int, b: Int = 3, *args: Int, c: Int, d: Int = 1, **kwargs: Int ): ...
- Added __source_location() and __call_location() functions to determine the location (line number in the source code) of function calls and code.
- Similar to the Python language, support for the “whence” argument has been added to the FileHandle.seek() method.
- The AnyPointer type has been renamed to Unsafe Pointer. Added the ability to initialize UnsafePointer directly from a reference with type Reference (“UnsafePointer(someRef)”). To work with UnsafePointer pointers, the functions initialize_pointee_copy, initialize_pointee_move, move_from_pointee() and move_pointee have been added.
The Mojo language 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. Mojo's syntax is based on Python, and its type system is similar to C/C++. 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.
Simplicity is achieved through the use of familiar Python syntax, and the development of final products is facilitated by the ability to compile to 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.
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: