Python for Javascript Developers
Alexa Leoto
Posted on July 8, 2024
Why Learn Python in the First Place?
In today's world, we have an abundance of options for languages, and at times it can become overwhelming. So why Python out of all languages? Python is number one on the list of most used programming languages. It is used by companies all around the world.
Python is used by Intel, IBM, NASA, Pixar, Netflix, Facebook, JP Morgan Chase, Spotify, and a number of other massive companies. It's one of the four main languages at Google, while Google's YouTube is largely written in Python. The same goes for Reddit, Pinterest, and Instagram. The original BitTorrent client was also written in Python. It is used as a scripting language to control Maya, the industry standard 3D modeling and animation tool. ~ Brainstation.io
Quick History on Python!
Python, one of the world's most popular programming languages, was conceptualized by Guido van Rossum in the late 1980s as a successor to the ABC programming language. Python was designed to be easy to learn and use, with support for exception handling and initially targeted at the Amoeba operating system. The first version, 0.9.0, was released in 1991, featuring essential elements like classes, functions, and data types such as lists and dictionaries. Python 1.0, released in 1994, introduced functional programming tools like lambda, map, filter, and reduce, contributed by other developers. Van Rossum continued developing Python at the Corporation for National Research Initiatives (CNRI) in Virginia, where he promoted programming accessibility through the initiative "Computer Programming for Everyone."
In 2000, the Python development team moved to BeOpen.com, transforming Python into a more open-source project with the release of Python 2.0, which fostered greater community involvement. This transition marked a significant change in Python's development process. Python 3.0, released in December 2008, was a major revision that was not backward compatible with Python 2.x, focusing on removing redundant constructs and modules to provide a more streamlined language. Despite the challenge of transitioning from Python 2 to Python 3, with support for Python 2.7 ending in 2020, Python continues to evolve and remains a highly popular and accessible programming language for beginners and professionals alike. Okay now that we got that out the way lets talk code!
Essential Context and Syntax
For JavaScript developers, learning Python can be a smooth transition thanks to similarities in syntax and logic. However, there are also notable differences. Let's explore the essential context and syntax to get you started.
One of the first things I noticed about python is the readability. lets take a look at the example below
Javascript Example
Python Example
While both are fairly short pieces of code, the python example is shorter by a considerable amount of characters and python also has the added benefit of being english readable.
Variables and Data Types
Variables in Python do not require a keyword for declaration (like var, let, or const in JavaScript). Plus, Python has dynamic typing, making it flexible and easy to use.
JavaScript Example:
Python Equivalent:
Functions and Loops
Defining functions in Python is straightforward, using the def keyword. Loops in Python are also quite similar but use a different syntax.
JavaScript Example:
Python Equivalent:
Lists and Dictionaries (Arrays and Objects)
Python lists and dictionaries are similar to JavaScript arrays and objects, making data manipulation easy and intuitive.
JavaScript Example:
Python Equivalent:
Conclusion
Learning Python as a JavaScript developer is like adding a new superpower to your coding arsenal. It's simple, readable, and used by companies in every field out there. Python's flexibility, readability, and extensive library support make it an excellent choice for web development, data science, machine learning, automation, and more. Lastly don't forget that python is for the girls :)
Posted on July 8, 2024
Join Our Newsletter. No Spam, Only the good stuff.
Sign up to receive the latest update from our blog.