This article's tone or style may not reflect the
encyclopedic tone used on Wikipedia. (October 2023) |
Paradigm |
|
---|---|
Family | Python |
Designed by | Chris Lattner |
Developer | Modular Inc. |
First appeared | 2023 |
Preview release | 24.2.1
[1]
/ April 12, 2024 |
Typing discipline | |
OS | Cross-platform |
License | Proprietary |
Filename extensions | .🔥 (the fire emoji/U+1F525 Unicode character), alternatively .mojo |
Website |
www |
Influenced by | |
Python, Cython[ citation needed], C, C++, Rust, Swift, Zig |
Mojo is a programming language in the Python family that is currently under development. [2] [3] [4] It is available both in browsers via Jupyter notebooks, [4] [5] and locally on Linux and macOS. [6] [7] Mojo aims to combine the usability of higher level languages, specifically Python, with the performance of lower level ones. [8]
The Mojo programming language was created by Modular Inc, which was founded by Chris Lattner, the original architect of the Swift programming language and LLVM, and Tim Davis, a former Google employee. [9]
According to public change logs, Mojo development goes back to 2022. [10] In May of 2023, the first publicly testable version was made available online via a hosted playground. [11] By September 2023 Mojo was available for local download for Linux [12] and by October 2023 it was also made available for download on Apple's macOS. [13]
In Mojo, functions can be declared using both fn (for performant functions) or def (for Python compatibility). [17]
Basic arithmetic operations in Mojo with a def function:
def sub(x, y):
"""A pythonic subtraction."""
res = x - y
return res
and with an fn function:
fn add(x: Int, y: Int) -> Int:
"""A rustacean addition."""
let res: Int = x + y
return res
The manner in which Mojo employs var and let for mutable and immutable variable declarations respectively mirrors the syntax found in Swift. In Swift, var is used for mutable variables, while let is designated for constants or immutable variables. [17]
Variable declaration and usage in Mojo:
fn main():
let x = 1
let y: Int
y = 1
var z = 0
z += 1
The Mojo SDK allows Mojo programmers to compile and execute Mojo source files locally from the command line and currently supports Ubuntu and macOS. [21] Additionally, there is a Mojo extension for Visual Studio Code which provides code completion and tooltips.
In January 2024, an inference model of LLaMA2 written in Mojo was released to the public. [22]
Mojo is a programming language that is as easy to use as Python but with the performance of C++ and Rust. Furthermore, Mojo provides the ability to leverage the entire Python library ecosystem.
While many other projects now use MLIR, Mojo is the first major language designed expressly for MLIR, which makes Mojo uniquely powerful when writing systems-level code for AI workloads.
All values passed into a Python def function use reference semantics. This means the function can modify mutable objects passed into it and those changes are visible outside the function. However, the behavior is sometimes surprising for the uninitiated, because you can change the object that an argument points to and that change is not visible outside the function. All values passed into a Mojo def function use value semantics by default. Compared to Python, this is an important difference: A Mojo def function receives a copy of all arguments—it can modify arguments inside the function, but the changes are not visible outside the function.
This article's tone or style may not reflect the
encyclopedic tone used on Wikipedia. (October 2023) |
Paradigm |
|
---|---|
Family | Python |
Designed by | Chris Lattner |
Developer | Modular Inc. |
First appeared | 2023 |
Preview release | 24.2.1
[1]
/ April 12, 2024 |
Typing discipline | |
OS | Cross-platform |
License | Proprietary |
Filename extensions | .🔥 (the fire emoji/U+1F525 Unicode character), alternatively .mojo |
Website |
www |
Influenced by | |
Python, Cython[ citation needed], C, C++, Rust, Swift, Zig |
Mojo is a programming language in the Python family that is currently under development. [2] [3] [4] It is available both in browsers via Jupyter notebooks, [4] [5] and locally on Linux and macOS. [6] [7] Mojo aims to combine the usability of higher level languages, specifically Python, with the performance of lower level ones. [8]
The Mojo programming language was created by Modular Inc, which was founded by Chris Lattner, the original architect of the Swift programming language and LLVM, and Tim Davis, a former Google employee. [9]
According to public change logs, Mojo development goes back to 2022. [10] In May of 2023, the first publicly testable version was made available online via a hosted playground. [11] By September 2023 Mojo was available for local download for Linux [12] and by October 2023 it was also made available for download on Apple's macOS. [13]
In Mojo, functions can be declared using both fn (for performant functions) or def (for Python compatibility). [17]
Basic arithmetic operations in Mojo with a def function:
def sub(x, y):
"""A pythonic subtraction."""
res = x - y
return res
and with an fn function:
fn add(x: Int, y: Int) -> Int:
"""A rustacean addition."""
let res: Int = x + y
return res
The manner in which Mojo employs var and let for mutable and immutable variable declarations respectively mirrors the syntax found in Swift. In Swift, var is used for mutable variables, while let is designated for constants or immutable variables. [17]
Variable declaration and usage in Mojo:
fn main():
let x = 1
let y: Int
y = 1
var z = 0
z += 1
The Mojo SDK allows Mojo programmers to compile and execute Mojo source files locally from the command line and currently supports Ubuntu and macOS. [21] Additionally, there is a Mojo extension for Visual Studio Code which provides code completion and tooltips.
In January 2024, an inference model of LLaMA2 written in Mojo was released to the public. [22]
Mojo is a programming language that is as easy to use as Python but with the performance of C++ and Rust. Furthermore, Mojo provides the ability to leverage the entire Python library ecosystem.
While many other projects now use MLIR, Mojo is the first major language designed expressly for MLIR, which makes Mojo uniquely powerful when writing systems-level code for AI workloads.
All values passed into a Python def function use reference semantics. This means the function can modify mutable objects passed into it and those changes are visible outside the function. However, the behavior is sometimes surprising for the uninitiated, because you can change the object that an argument points to and that change is not visible outside the function. All values passed into a Mojo def function use value semantics by default. Compared to Python, this is an important difference: A Mojo def function receives a copy of all arguments—it can modify arguments inside the function, but the changes are not visible outside the function.