GithubHelp home page GithubHelp logo

uberkael / mojo-vs-python-benchmarks Goto Github PK

View Code? Open in Web Editor NEW

This project forked from grayhatdevelopers/mojo-vs-python-benchmarks

0.0 0.0 0.0 1.89 MB

Comparing Mojo and Python for some newbie work

Home Page: https://www.linkedin.com/pulse/python-vs-mojo-we-yet-grayhatpk-jdszf/

Python 47.67% Shell 5.99% Mojo 46.34%

mojo-vs-python-benchmarks's Introduction

Language Comparison: Python vs Mojo

Hey there! I am new to both Python and Mojo languages. In this repository, I went on a mission to explore and compare these two languages from scratch, knowing only the basics of programming (started with C++). It contains a comparison of both the languages, from the perspective of a newbie.

I would love if people can verify whether or not my benchmarking is correct. If you can, please send an Issue or Pull Request with any changes and I'd be glad to re-run your request.

Programs

  1. Length of last word : returning the length of the last word in the string.
  2. Student attendance record : Whether or not the student is eligible for an attendance award
  3. Remove repeating letters : Removing the adjacent letters (one being capital) in a string.
  4. Detect Capital letter usage : Returning true if the usage of capitals in it is right.
  5. Find the difference: : Returning the extra letter among 2 strings

Benchmarking and Testing

The performance of both languages was benchmarked using Hyperfine. Programs were tested and outputs were compared to see which one of them was faster.

Results

For all the codes, Python ran significantly faster than Mojo and beat Mojo, in speed, by a huge margin

Comparing the advantages of both

1: Python installation was much simpler compared to Mojo. Installing Mojo was not user-friendly; it would have been better if there was a one-click installation option for Mojo on Windows, similar to Python.

2: The syntax of Mojo and Python was quite similar, with the main difference being that in Mojo, you need to use Python functions by importing them. For example, to take user input, you have to import the "input" function from Python. This made Python easier to learn

3: Mojo provided helpful explanations with each error, making it easier for me to understand and identify my mistakes. Python, on the other hand, lacked this feature, which is an advantage of Mojo.

4: The code itself requires a main() function to be called in Mojo for it to run while Python runs as is.

5: The Discord community of Mojo is very active and helpful. Their Discord has a chatbot which guides through every inconvenience with ease and is up to date with all the errors that I encountered while coding in Mojo; the bot is equipped with the latest info regarding Mojo, so was a very helpful feature

6: Python proved to be more user-friendly for me, mainly due to its proper documentation (because of it being older than Mojo). Moreover, the commands in Python were straightforward and simple to use, unlike Mojo, where there were some instances like for example me clearly stating the variable type (requiring explicit variable declarations), a step which I didnt have to do in Python

mojo-vs-python-benchmarks's People

Contributors

sohaibbazaz avatar uberkael avatar saadbazaz avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.