Популярное

Музыка Кино и Анимация Автомобили Животные Спорт Путешествия Игры Юмор

Интересные видео

2025 Сериалы Трейлеры Новости Как сделать Видеоуроки Diy своими руками

Топ запросов

смотреть а4 schoolboy runaway турецкий сериал смотреть мультфильмы эдисон
dTub
Скачать

LEARN MOJO TUTORIAL - 11 HOW TO COMPILE YOUR FIRST MOJO BINARY FILE IN 5 MINUTES

Автор: Learn Mojo Tutorial - Simple AI Tutorial

Загружено: 2023-09-30

Просмотров: 244

Описание:

In this video we are going to compare two little example programs for Python and for Mojo and we will compile our first Mojo file to a binary. So I think that most people have seen Python code like this one. This is a simple for loop. It says for x in range. X is a whole number, at least that is it to be assumed because in Python we don't need to use data types. And while that is in a range of the number here, we are going to print out x is now and the value of x.

And afterwards we are going to increase x by the current value and add 1. So if we run this code, you can see that it counts below and I think it's pretty fast. Now it's finished. And we all have heard that Mojo is so much faster than Python. So let's see how the same thing looks in Mojo. We start with a function called main and we need to declare a variable by using VAR.

VAR stands for a value that can be changed. There is another one for constants, but for now let's say X is 1 and for X in range we want to count until the value is 100,000 and we will print the same x is now and the value of x before we add 1 to x. Now let's clear this one and run the Count..Ojo file and you see it's also counting at a high speed. I have not really tried to measure it, but I think it's not so fast than the one we have seen before in Python. So one thing that people can do to make code faster is to compile a binary file and that is done by using mojo build as a command followed by the file name which is count.mojo.

And now we should see a compiled version. So let's type in LS to list the files. And this green one here is a binary that has been compiled. We can run it by typing in ./count and sure enough it starts to count. So this still is not looking as if it is much faster and there are reasons for that because Mojo offers some things that Python doesn't have to offer.

So we can specify a type here. And you see when I try to type integer there are several types that I can pick. One is int, one is int8, one is int16 and these are the number of bits that we need to calculate. So let's pick an int8. We need to save the file.

Let's clear the terminal and rebuild the file here. There we are and let's retry and let it count again. And it seems to be a little bit faster than before. This was just a fast way to show you how to compile something to a binary file. And if you optimize the code, you can make it faster.

Obviously this was a very simple example, but I think simple examples are the best way to learn something. And you can do this in five minutes yourself. And in this video, you have learned how to compile a binary file for mojo and you have done it with a few lines of mojo code.

LEARN MOJO TUTORIAL - 11 HOW TO COMPILE YOUR FIRST MOJO BINARY FILE IN 5 MINUTES

Поделиться в:

Доступные форматы для скачивания:

Скачать видео mp4

  • Информация по загрузке:

Скачать аудио mp3

Похожие видео

array(10) { [0]=> object(stdClass)#4147 (5) { ["video_id"]=> int(9999999) ["related_video_id"]=> string(11) "t2xvSAPRfiI" ["related_video_title"]=> string(79) "LEARN MOJO TUTORIAL - 12 HOW TO CREATE YOUR FIRST FUNCTION IN MOJO IN 5 MINUTES" ["posted_time"]=> string(19) "1 год назад" ["channelName"]=> string(40) "Learn Mojo Tutorial - Simple AI Tutorial" } [1]=> object(stdClass)#4120 (5) { ["video_id"]=> int(9999999) ["related_video_id"]=> string(11) "maPRR_jjyOE" ["related_video_title"]=> string(129) "JavaScript для начинающих 2024. Полный курс за 6 часов. Уроки. Теория + практика" ["posted_time"]=> string(21) "3 года назад" ["channelName"]=> string(50) "ВебКадеми | Юрий Ключевский" } [2]=> object(stdClass)#4145 (5) { ["video_id"]=> int(9999999) ["related_video_id"]=> string(11) "HSeoJ5ayG7Q" ["related_video_title"]=> string(77) "Минимальный уровень python для первой работы" ["posted_time"]=> string(19) "1 год назад" ["channelName"]=> string(14) "Backend artist" } [3]=> object(stdClass)#4152 (5) { ["video_id"]=> int(9999999) ["related_video_id"]=> string(11) "wDmPgXhlDIg" ["related_video_title"]=> string(121) "Python — полный курс для начинающих. Этот навык изменит твою жизнь." ["posted_time"]=> string(19) "1 год назад" ["channelName"]=> string(39) "Александр Ильин про IT" } [4]=> object(stdClass)#4131 (5) { ["video_id"]=> int(9999999) ["related_video_id"]=> string(11) "5g-MHZ0MzZY" ["related_video_title"]=> string(164) "Экспресс! Учим python за 7 часов! Уроки Python Полный курс обучения программированию с python с нуля" ["posted_time"]=> string(21) "3 года назад" ["channelName"]=> string(17) "Python Hub Studio" } [5]=> object(stdClass)#4149 (5) { ["video_id"]=> int(9999999) ["related_video_id"]=> string(11) "LCkfBhasscA" ["related_video_title"]=> string(41) "Урок 5 Цикл while в питоне" ["posted_time"]=> string(25) "2 недели назад" ["channelName"]=> string(9) "Pythonlib" } [6]=> object(stdClass)#4144 (5) { ["video_id"]=> int(9999999) ["related_video_id"]=> string(11) "BSGJ7XqY7sg" ["related_video_title"]=> string(56) "How to protect your Application from DDoS attacks on AWS" ["posted_time"]=> string(21) "1 день назад" ["channelName"]=> string(30) "Poznaj AWS | Living in a Cloud" } [7]=> object(stdClass)#4154 (5) { ["video_id"]=> int(9999999) ["related_video_id"]=> string(11) "mThiyFYEQhY" ["related_video_title"]=> string(163) "«Будем жить!» | Хитрая передача на Первом канале о вернувшихся с СВО (English subtitles) @Max_Katz" ["posted_time"]=> string(21) "3 часа назад" ["channelName"]=> string(19) "Максим Кац" } [8]=> object(stdClass)#4130 (5) { ["video_id"]=> int(9999999) ["related_video_id"]=> string(11) "pe_ejTiIcSs" ["related_video_title"]=> string(53) "Похудей на 45 КГ, Выиграй $250,000!" ["posted_time"]=> string(21) "5 дней назад" ["channelName"]=> string(7) "MrBeast" } [9]=> object(stdClass)#4148 (5) { ["video_id"]=> int(9999999) ["related_video_id"]=> string(11) "53wphlw-DYE" ["related_video_title"]=> string(125) "Выравнивание — БАЗА быстрого кода! Почему это важно знать | CPU Memory 2" ["posted_time"]=> string(25) "2 недели назад" ["channelName"]=> string(10) "MrTeamlead" } }
LEARN MOJO TUTORIAL - 12 HOW TO CREATE YOUR FIRST FUNCTION IN MOJO IN 5 MINUTES

LEARN MOJO TUTORIAL - 12 HOW TO CREATE YOUR FIRST FUNCTION IN MOJO IN 5 MINUTES

JavaScript для начинающих 2024. Полный курс за 6 часов. Уроки. Теория + практика

JavaScript для начинающих 2024. Полный курс за 6 часов. Уроки. Теория + практика

Минимальный уровень python для первой работы

Минимальный уровень python для первой работы

Python — полный курс для начинающих. Этот навык изменит твою жизнь.

Python — полный курс для начинающих. Этот навык изменит твою жизнь.

Экспресс! Учим python за 7 часов! Уроки Python Полный курс обучения программированию с python с нуля

Экспресс! Учим python за 7 часов! Уроки Python Полный курс обучения программированию с python с нуля

Урок 5 Цикл while в питоне

Урок 5 Цикл while в питоне

How to protect your Application from DDoS attacks on AWS

How to protect your Application from DDoS attacks on AWS

«Будем жить!» | Хитрая передача на Первом канале о вернувшихся с СВО (English subtitles) @Max_Katz

«Будем жить!» | Хитрая передача на Первом канале о вернувшихся с СВО (English subtitles) @Max_Katz

Похудей на 45 КГ, Выиграй $250,000!

Похудей на 45 КГ, Выиграй $250,000!

Выравнивание — БАЗА быстрого кода! Почему это важно знать | CPU Memory 2

Выравнивание — БАЗА быстрого кода! Почему это важно знать | CPU Memory 2

© 2025 dtub. Все права защищены.



  • Контакты
  • О нас
  • Политика конфиденциальности



Контакты для правообладателей: [email protected]