ПІДТРИМАЙ УКРАЇНУ ПІДТРИМАТИ АРМІЮ
Uk Uk

This new tool is changing Python forever...

This new tool is changing Python forever...

Python is one of the world's most popular programming languages, and today is usually the primary...

Python is one of the world's most popular programming languages, and today is usually the primary choice for beginners, except perhaps for JavaScript. It's easy to understand why; Python's syntax is easy to read and lets you focus on the code and logic rather than complex syntax and usability.

Recently, however, a company called Modular released a new programming language called Mojo, which might just be the language to top them all.

In this post, we'll examine what Mojo is, why it's so powerful, and whether it could take over the programming world.

The Mojo Story

Mojo was developed by a company called Modular, and it's part of the company's MAX suite of developer tools, which are used primarily for creating machine learning and generative AI.

Modular itself is dedicated to creating infrastructure and tools focused on powering and improving generative AI and is by the same teams who worked on TensorFlow, PyTorch, XLA, and even tools like Swift, LLVM, & MLIR.

Not Quite a Language

Mojo itself isn't exactly a programming language - rather, it's considered a subset of Python. What does that mean?

Well, Mojo supports and is built on the same syntax as Python, allowing for complete compatibility. It's in the changes that Mojo has made, and how it works, that things get interesting.

The Mojo Compiler

Under the hood, Python is an interpreted language, meaning its runtime goes through line by line and executes the equivalent code. That results in reduced performance compared to compiled languages, where the code is compiled into another, lower-level language.

Mojo, unlike Python, is built on a compiler. The compiler is built with LLVM and MLIR, technologies used to power other languages like C++ and Swift.

As you might imagine, this results in immense performance gains. By benchmarks, Mojo is an almost ridiculous 68000x than Python. In practice, you won't always get that same improvement, but it's still a vast difference.

Extended Syntax

In addition to having an incredible compiler, Mojo provides you with extra syntax for lower-level control and even types. This new syntax is completely optional, so Python code will still work just fine, but allows you to take greater control of the code when needed.

# Progressive Types
def sort(v: ArraySlice[Int]):
 for i in range(len(v)):
 for j in range(len(v) - i - 1):
 if v[j] > v[j + 1]:
 swap(v[j], v[j + 1])

# Portable Parametric Algorithms
def exp[dt: DType, elts: Int]
 (x: SIMD[dt, elts]) -> SIMD[dt, elts]:
 x = clamp(x, -88.3762626647, 88.37626266)
 k = floor(x * INV_LN2 + 0.5)
 r = k * NEG_LN2 + x
 return ldexp(_exp_taylor(r), k)

Best Of All.

Last, and most important of all, Mojo's file extension is clearly on another level from the competition:

// You could do this...
hello.mojo
// or this
hello.????

Conclusion

Overall, Mojo is a great language that will likely be quickly adopted, especially among AI engineers and data scientists. You can use Mojo right now at their website .

Is Python going away? Likely not, as it has a strong community and powerful ecosystem, but Mojo will certainly take up some of its usage by programmers - unless Modular screws things up, anyway.

Ресурс : dev.to


Scroll to Top