Mojo ๐Ÿ”ฅ โ€” a new programming language for AI developers (first look)

Patrick Loeber ยท Intermediate ยท๐Ÿ’ป AI-Assisted Coding ยท3y ago

Key Takeaways

Mojo, a new programming language announced by Chris Lattner, combines the usability of Python with the performance of C/C++ for AI applications, claiming to be up to 35,000 times faster than Python. The language is designed as a superset of Python, with additional features such as progressive types, zero-cost abstractions, and language-integrated auto-tuning.

Full Transcript

hi everyone I'm Patrick and welcome back on my channel so yesterday Chris lattner the co-founder of llvm and the Swift programming language announced a new programming language called mocho which Builds on top of python and is designed specifically for AI applications and in their keynote they claim that it's up to 35 000 times faster than python so let's take a quick first look at it so Mojo combines the usability of python with the performance of C or C plus unlocking unparalleled programmability of AI hardware and extensibility of AI models so this is one of the main motivations we all know one of the main drawbacks of python is its speed and poor low level performance so what ends up happening is often we use python as a glue and have the actual implementations in C plus plus or c for example this is what happens with numpy or tensorflow or pytorch or for AI applications we even go a level deeper and write code in Cuda which is optimized for your tensor operations on this on the GPU so Mojo tries to unify all of this so here it claims write everything in one language no C plus plus or Cuda required and at the same time it should be as simple and familiar as python so let's have a look at some of its features so first of all Mojo is designed as a superset of pythons so you can also write python code and in fact the hello world looks the very same as in Python so a lot of the language features and the functions and the syntax are the same but then it has additional features on top to extend this so I will go over this in a few moments but what I also want to mention is that right now they mentioned this in their docs how compatible is Mojo with python really and at the moment it is still very early and missing many features but they want to work towards a full compatibility in the future so we have to wait how this will go so let's look at some of the features so here we have the softmax function in Python and we can rewrite this in numpy which looks similar for example we also have this Define a function and then we return something but here we have this struct which I will show you in a moment again so let's go over some of the features here first of all they say it has Progressive types so we can leverage types for better performance and error checking then it has zero cost abstractions so we can take control of storage by inline allocating values into structures so this is what I just showed you here we can define a struct which looks similar to a class but it has some differences so first of all for example you can also write your init function but then you might notice these typins here and with this we can take more control of the storage then we can have ownership and borrow Checkers so we can take advantage of memory safety without the rough edges and in fact they claim to be as safe as rust then you can have portable parametric algorithms so you can leverage compile time meta programming to write Hardware agnostic algorithms and reduce boilerplate and then you get language integrated Auto tuning so you can automatically find the best values for for your parameters and take advantage of the target hardware and then some more features they list here and I also want to point out the documentations that you can check out so for example they have the section about basic systems programming extensions so for example one of the extensions are the let and wear declarations that you can use on top of your normal python code of course so here you can use this for immutable and mutable types then you get these struct type that I already showed you which looks similar to a class but has some differences then you get strong type checking then you can overload functions so this is similar to C plus plus or Java in Swift so here you can write a function that has the same syntax as two init functions for example but it has different arguments and then here also you have this function definition so this is similar to a def keyword in Python and you can also write def function but then again here with this you get some more functionality and for this I recommend to check out the documentation then you get a copy in it and a move in its special method and then you also get this section about parameterization and yeah so again if you want to go into more depth then check out the documentation I will put the link in the description so how can you try Mojo and at the moment it is not yet publicly available so you have to sign up here and wait until you get access and once you have access you can try try it out via the so-called Mojo playground which is just a two-parter notebook with also the Mojo compiler in the background so so then here you can write for example also python code and then also cells with Mojo code and then try this out but again it is not yet publicly available so you cannot simply install this on your own machine so you have to use it via their playground and also it is not yet open source so they have a repository and here they write we plan to open source Mojo progressively over time but it's changing very quickly now and we believe that a small tight-knit group of Engineers with a shared Vision can move faster than a community effort so we also have to wait until this will go open source so yeah this is just a very short overview of Mojo at first glance it looks and sounds very exciting but as you can see here it is still very early so we have to wait and see so yeah let me know in the comments what you think about Mojo if you also think it could change the way how we write AI applications in the future and if you want to try it out yourself and also if you want to see more tutorials in the future on my channel let me know and then I hope to see you in the next video bye

Original Description

Yesterday Chris Lattner announced a new programming language called Mojo, which builds on top of Python and is designed specifically for AI applications. They claim itโ€™s up to 35000 times faster than Python. So letโ€™s take a quick first look at it. Website: https://www.modular.com/mojo Docs: https://docs.modular.com/mojo/ Keynote: https://youtu.be/-3Kf2ZZU-dg Get my Free NumPy Handbook: https://www.python-engineer.com/numpybook โœ… Write cleaner code with Sourcery, instant refactoring suggestions in VS Code & PyCharm: https://sourcery.ai/?utm_source=youtube&utm_campaign=pythonengineer * โญ Join Our Discord : https://discord.gg/FHMg9tKFSN ๐Ÿ““ ML Notebooks available on Patreon: https://www.patreon.com/patrickloeber If you enjoyed this video, please subscribe to the channel: โ–ถ๏ธ : https://www.youtube.com/channel/UCbXgNpp0jedKWcQiULLbDTA?sub_confirmation=1 ~~~~~~~~~~~~~~~ CONNECT ~~~~~~~~~~~~~~~ ๐Ÿ–ฅ๏ธ Website: https://www.python-engineer.com ๐Ÿฆ Twitter - https://twitter.com/patloeber โœ‰๏ธ Newsletter - https://www.python-engineer.com/newsletter ๐Ÿ“ธ Instagram - https://www.instagram.com/patloeber ๐Ÿฆพ Discord: https://discord.gg/FHMg9tKFSN โ–ถ๏ธ Subscribe: https://www.youtube.com/channel/UCbXgNpp0jedKWcQiULLbDTA?sub_confirmation=1 ~~~~~~~~~~~~~~ SUPPORT ME ~~~~~~~~~~~~~~ ๐Ÿ…ฟ Patreon - https://www.patreon.com/patrickloeber #Python Timeline: 00:00 - Intro & motivation 01:23 - Features 04:48 - How to try Mojo ---------------------------------------------------------------------------------------------------------- * This is an affiliate link. By clicking on it you will not have any additional costs, instead you will support me and my project. Thank you so much for the support! ๐Ÿ™
Watch on YouTube โ†— (saves to browser)
Sign in to unlock AI tutor explanation ยท โšก30

Playlist

Uploads from Patrick Loeber ยท Patrick Loeber ยท 0 of 60

โ† Previous Next โ†’
1 Lists in Python - Advanced Python 01 - Programming Tutorial
Lists in Python - Advanced Python 01 - Programming Tutorial
Patrick Loeber
2 Tuples in Python - Advanced Python 02 - Programming Tutorial
Tuples in Python - Advanced Python 02 - Programming Tutorial
Patrick Loeber
3 Dictionaries in Python - Advanced Python 03 - Programming Tutorial
Dictionaries in Python - Advanced Python 03 - Programming Tutorial
Patrick Loeber
4 Sets in Python - Advanced Python 04 - Programming Tutorial
Sets in Python - Advanced Python 04 - Programming Tutorial
Patrick Loeber
5 Strings in Python - Advanced Python 05 - Programming Tutorial
Strings in Python - Advanced Python 05 - Programming Tutorial
Patrick Loeber
6 Collections in Python - Advanced Python 06 - Programming Tutorial
Collections in Python - Advanced Python 06 - Programming Tutorial
Patrick Loeber
7 Itertools in Python - Advanced Python 07 - Programming Tutorial
Itertools in Python - Advanced Python 07 - Programming Tutorial
Patrick Loeber
8 Lambda in Python - Advanced Python 08 - Programming Tutorial - Map Filter Reduce
Lambda in Python - Advanced Python 08 - Programming Tutorial - Map Filter Reduce
Patrick Loeber
9 Exceptions in Python - Advanced Python 09 - Programming Tutorial
Exceptions in Python - Advanced Python 09 - Programming Tutorial
Patrick Loeber
10 Logging in Python - Advanced Python 10 - Programming Tutorial
Logging in Python - Advanced Python 10 - Programming Tutorial
Patrick Loeber
11 JSON in Python - Advanced Python 11 - Programming Tutorial
JSON in Python - Advanced Python 11 - Programming Tutorial
Patrick Loeber
12 Random Numbers in Python - Advanced Python 12 - Programming Tutorial
Random Numbers in Python - Advanced Python 12 - Programming Tutorial
Patrick Loeber
13 Decorators in Python - Advanced Python 13 - Programming Tutorial
Decorators in Python - Advanced Python 13 - Programming Tutorial
Patrick Loeber
14 Generators in Python - Advanced Python 14 - Programming Tutorial
Generators in Python - Advanced Python 14 - Programming Tutorial
Patrick Loeber
15 Threading vs Multiprocessing in Python - Advanced Python 15 - Programming Tutorial
Threading vs Multiprocessing in Python - Advanced Python 15 - Programming Tutorial
Patrick Loeber
16 Threading in Python - Advanced Python 16 - Programming Tutorial
Threading in Python - Advanced Python 16 - Programming Tutorial
Patrick Loeber
17 Multiprocessing in Python - Advanced Python 17 - Programming Tutorial
Multiprocessing in Python - Advanced Python 17 - Programming Tutorial
Patrick Loeber
18 Function arguments in detail - Advanced Python 18 - Programming Tutorial
Function arguments in detail - Advanced Python 18 - Programming Tutorial
Patrick Loeber
19 The asterisk (*) operator in Python - Advanced Python 19 - Programming Tutorial
The asterisk (*) operator in Python - Advanced Python 19 - Programming Tutorial
Patrick Loeber
20 Shallow vs Deep Copying in Python - Advanced Python 20 - Programming Tutorial
Shallow vs Deep Copying in Python - Advanced Python 20 - Programming Tutorial
Patrick Loeber
21 Context Managers in Python - Advanced Python 21 - Programming Tutorial
Context Managers in Python - Advanced Python 21 - Programming Tutorial
Patrick Loeber
22 KNN (K Nearest Neighbors) in Python - Machine Learning From Scratch 01 - Python Tutorial
KNN (K Nearest Neighbors) in Python - Machine Learning From Scratch 01 - Python Tutorial
Patrick Loeber
23 Linear Regression in Python - Machine Learning From Scratch 02 - Python Tutorial
Linear Regression in Python - Machine Learning From Scratch 02 - Python Tutorial
Patrick Loeber
24 Logistic Regression in Python - Machine Learning From Scratch 03 - Python Tutorial
Logistic Regression in Python - Machine Learning From Scratch 03 - Python Tutorial
Patrick Loeber
25 Linear and Logistic Regression in 60 lines of Python - Machine Learning From Scratch 04
Linear and Logistic Regression in 60 lines of Python - Machine Learning From Scratch 04
Patrick Loeber
26 Naive Bayes in Python - Machine Learning From Scratch 05 - Python Tutorial
Naive Bayes in Python - Machine Learning From Scratch 05 - Python Tutorial
Patrick Loeber
27 Perceptron in Python - Machine Learning From Scratch 06 - Python Tutorial
Perceptron in Python - Machine Learning From Scratch 06 - Python Tutorial
Patrick Loeber
28 SVM (Support Vector Machine) in Python - Machine Learning From Scratch 07 - Python Tutorial
SVM (Support Vector Machine) in Python - Machine Learning From Scratch 07 - Python Tutorial
Patrick Loeber
29 Decision Tree in Python Part 1/2 - Machine Learning From Scratch 08 - Python Tutorial
Decision Tree in Python Part 1/2 - Machine Learning From Scratch 08 - Python Tutorial
Patrick Loeber
30 Decision Tree in Python Part 2/2 - Machine Learning From Scratch 09 - Python Tutorial
Decision Tree in Python Part 2/2 - Machine Learning From Scratch 09 - Python Tutorial
Patrick Loeber
31 Random Forest in Python - Machine Learning From Scratch 10 - Python Tutorial
Random Forest in Python - Machine Learning From Scratch 10 - Python Tutorial
Patrick Loeber
32 PCA (Principal Component Analysis) in Python - Machine Learning From Scratch 11 - Python Tutorial
PCA (Principal Component Analysis) in Python - Machine Learning From Scratch 11 - Python Tutorial
Patrick Loeber
33 K-Means Clustering in Python - Machine Learning From Scratch 12 - Python Tutorial
K-Means Clustering in Python - Machine Learning From Scratch 12 - Python Tutorial
Patrick Loeber
34 Anaconda Tutorial - Installation and Basic Commands
Anaconda Tutorial - Installation and Basic Commands
Patrick Loeber
35 PyTorch Tutorial 01 - Installation
PyTorch Tutorial 01 - Installation
Patrick Loeber
36 PyTorch Tutorial 02 - Tensor Basics
PyTorch Tutorial 02 - Tensor Basics
Patrick Loeber
37 PyTorch Tutorial 03 - Gradient Calculation With Autograd
PyTorch Tutorial 03 - Gradient Calculation With Autograd
Patrick Loeber
38 PyTorch Tutorial 04 - Backpropagation - Theory With Example
PyTorch Tutorial 04 - Backpropagation - Theory With Example
Patrick Loeber
39 PyTorch Tutorial 05 - Gradient Descent with Autograd and Backpropagation
PyTorch Tutorial 05 - Gradient Descent with Autograd and Backpropagation
Patrick Loeber
40 PyTorch Tutorial 06 - Training Pipeline: Model, Loss, and Optimizer
PyTorch Tutorial 06 - Training Pipeline: Model, Loss, and Optimizer
Patrick Loeber
41 PyTorch Tutorial 07 - Linear Regression
PyTorch Tutorial 07 - Linear Regression
Patrick Loeber
42 PyTorch Tutorial 08 - Logistic Regression
PyTorch Tutorial 08 - Logistic Regression
Patrick Loeber
43 PyTorch Tutorial 09 - Dataset and DataLoader - Batch Training
PyTorch Tutorial 09 - Dataset and DataLoader - Batch Training
Patrick Loeber
44 PyTorch Tutorial 10 - Dataset Transforms
PyTorch Tutorial 10 - Dataset Transforms
Patrick Loeber
45 Download Images With Python Automatically - Python Web Scraping Tutorial
Download Images With Python Automatically - Python Web Scraping Tutorial
Patrick Loeber
46 PyTorch Tutorial 11 - Softmax and Cross Entropy
PyTorch Tutorial 11 - Softmax and Cross Entropy
Patrick Loeber
47 Select Movies with Python - Web Scraping Tutorial
Select Movies with Python - Web Scraping Tutorial
Patrick Loeber
48 PyTorch Tutorial 12 - Activation Functions
PyTorch Tutorial 12 - Activation Functions
Patrick Loeber
49 List Comprehension in Python - A Python Feature You MUST KNOW - Python Tutorial
List Comprehension in Python - A Python Feature You MUST KNOW - Python Tutorial
Patrick Loeber
50 PyTorch Tutorial 13 - Feed-Forward Neural Network
PyTorch Tutorial 13 - Feed-Forward Neural Network
Patrick Loeber
51 How To Add A Progress Bar In Python With Just One Line - Python Tutorial
How To Add A Progress Bar In Python With Just One Line - Python Tutorial
Patrick Loeber
52 PyTorch Tutorial 14 - Convolutional Neural Network (CNN)
PyTorch Tutorial 14 - Convolutional Neural Network (CNN)
Patrick Loeber
53 The Walrus Operator - New in Python 3.8 - Python Tutorial
The Walrus Operator - New in Python 3.8 - Python Tutorial
Patrick Loeber
54 PyTorch Tutorial 15 - Transfer Learning
PyTorch Tutorial 15 - Transfer Learning
Patrick Loeber
55 YouTube Data API Tutorial with Python - Analyze Channel Statistics - Part 1
YouTube Data API Tutorial with Python - Analyze Channel Statistics - Part 1
Patrick Loeber
56 YouTube Data API Tutorial with Python - Find Channel Videos - Part 2
YouTube Data API Tutorial with Python - Find Channel Videos - Part 2
Patrick Loeber
57 YouTube Data API Tutorial with Python - Get Video Statistics - Part 3
YouTube Data API Tutorial with Python - Get Video Statistics - Part 3
Patrick Loeber
58 YouTube Data API Tutorial with Python - Analyze the Data - Part 4
YouTube Data API Tutorial with Python - Analyze the Data - Part 4
Patrick Loeber
59 AdaBoost in Python - Machine Learning From Scratch 13 - Python Tutorial
AdaBoost in Python - Machine Learning From Scratch 13 - Python Tutorial
Patrick Loeber
60 Ultimate FREE Study Guide for Machine Learning and Deep Learning
Ultimate FREE Study Guide for Machine Learning and Deep Learning
Patrick Loeber

Mojo is a new programming language that combines the usability of Python with the performance of C/C++ for AI applications. It is designed as a superset of Python, with additional features such as progressive types and zero-cost abstractions. Mojo claims to be up to 35,000 times faster than Python and has the potential to change the way we write AI applications.

Key Takeaways
  1. Sign up for access to the Mojo playground
  2. Try out Mojo via the playground
  3. Learn about Mojo's features, such as progressive types and zero-cost abstractions
  4. Experiment with writing Mojo code
  5. Compare Mojo's performance to Python
๐Ÿ’ก Mojo has the potential to significantly improve the performance of AI applications, making it an exciting development in the field of AI.
๐Ÿ”’ Pro feature: Ask AI to explain this lesson โ†’

Related Reads

๐Ÿ“ฐ
Building a Vibe-Based Music Recommender with MongoDB and Voyage AI
Learn to build a music recommender system using MongoDB and Voyage AI that suggests songs based on vibe, not just artist or genre
Dev.to ยท Jordan Smith
๐Ÿ“ฐ
AI Wrote Your Code. Did It Ship a Vulnerability Too?
AI-generated code often fails basic security tests, highlighting the need for careful review and testing
Dev.to ยท Stanley A.
๐Ÿ“ฐ
Beyond Vibe Coding: Embracing Agentic Engineering for Sustainable AI Development
Learn to move beyond vibe coding and adopt agentic engineering for sustainable AI development
Medium ยท AI
๐Ÿ“ฐ
I Had 16 AI Reviewers Guarding My Code. Not One of Them Existed.
Learn how to effectively use AI-powered code reviewers to improve code quality and catch errors, and understand the limitations of relying solely on AI tools
Dev.to ยท Akash Khanna

Chapters (3)

Intro & motivation
1:23 Features
4:48 How to try Mojo
Up next
We Studied 10,000 Devs Using AI. This Is Where They Fail.
SCALER
Watch โ†’