We see it all the time. Check job listings for programmers and very soon, you'll see the word: Python. If you, like me, started your digital journey in the wilds of javascript, and you'd really like to know what this new language has to offer, then you're in luck. I'll try to explain it as javascriptually as I can. Let's begin!
Why Python at all
The first question on this javascripters mind is: Why python? Why not just stick with javascript? Well, the thing is, Python is a general-purpose programming language that can accommodate a variety of programming paradigms. Data science, artificial intelligence, machine learning, computer science education, computer vision, image processing, medicine, biology, and even astronomy all use it.1
In addition to being widely used, it's mentally ergonomic. Python is a simple to use interpreter-based high-level programming language. It's also very simple to understand a Python program.1
It's also heavily utilized in back-end programming, and more and more often heavily utilized in general. A poll by StackOverflow points out that the popularity of Python as it goes with programming language is extremely high! Second only to HTML and, of course, good ol' javascript.
As you can see, Python is certainly here to stay, being utilized by tech giants like Instagram, Spotify, Reddit, and YouTube, this snake will come to bite you at many different angles. Now, before we really jump in, lets see
which benefits each language provides
Python pros/cons
*Python is a widely used general-purpose, high-level programming language. It was initially designed by Guido van Rossum in 1991 and developed by Python Software Foundation *6 *(he got the name from *Monty).
Python has been an inspiration for many other coding languages such as Ruby , Cobra, Boo, CoffeeScript ECMAScript, Groovy, Swift, Go, OCaml, Julia , etc.6
Here are some pros to Python:
- Easy to learn and read: Python's code looks a bit like English, which makes it easier to get what it's doing. This helps a lot when you're trying to find and fix mistakes.
- Interpreted execution: Unlike some languages that need to be fully built before you can see if they work, Python lets you try things out one step at a time. This is great for making changes and seeing results quickly.
- Dynamic typing: You don't have to tell Python what type of data (like numbers or text) you're using upfront. It figures it out as you go, making things more flexible.
- Vast libraries and frameworks: Python has a big collection of extra tools for different jobs - from making websites with Django or Flask to handling data with NumPy and Pandas, or even doing machine learning with TensorFlow.
- Cross-platform portability: Python works on different computers like Windows, Linux, and macOS without needing changes. This makes sharing your work easier.
- Supports multiple programming paradigms: Python lets you write code in different styles, whether it's focusing on actions, objects, or rules. This means you can pick the best way to solve a problem.
And some Cons:
- Python can be slower than languages that are built all at once before running. This might matter for tasks that need lots of computing power.
- If you're into making websites, knowing JavaScript is key because it's the main language for creating interactive web pages. Python is more for the behind-the-scenes stuff.
- Python isn't the go-to for making apps on phones compared to other languages specifically for Android or iOS.
Javascript pros/cons:
- Everywhere in web dev: JavaScript is a must-know for anyone making websites.
- See results fast: When you change something, you can see the effect right away, which is great for learning.
- Do more than just websites: With Node.js, you can work on servers and more, not just web pages.
- Lots of help available: Being so popular, there's a ton of guides and communities to help you out.
- Skills that transfer: What you learn in JavaScript, like how to use functions and store data, helps with other languages too.
But also:
- Handling many things at once: The way JavaScript does multiple tasks at the same time can be confusing.
- Old habits die hard: Some outdated JavaScript ways are still around and can be puzzling.
- Too many choices: With so many tools and frameworks, it's hard to know where to start.
- Not great for math stuff: JavaScript doesn't have as many built-in tools for math or data science as Python.
Variables
Case-sensitive
python underscore practices
Datatypes
"strings" or text
numbers or integers
Boolean True, False
in operator(.includes, .contains, .hasOwnProperty)
and = &&
or = ||
not (kinda like) !
Functions
indentation
len()
input() always returns a string
if/elif/else
print()
int()/str()
upper()/lower()
find()
.replace()
float()
loops
for item in numbers:
print(item)
i = 0
while i < len(numbers):
print(numbers[i])
Conclusion
We've looked at some facets of Python and Javascript and how they compare to each other, but the real judge is you at the end of the day.
Code on, and prosper!!
References:
2.https://blog.finxter.com/python-cheat-sheet/
3.https://daily.dev/blog/python-and-javascript-choosing-your-first-language
4.https://radixweb.com/blog/python-vs-javascript
5.https://inveritasoft.com/article-python-vs-javascript:-what-to-choose-in-2021
Test and test can be two different variables
booleans are written as True and False
typescript-ish, as you can add type annotations optionally
these do not change the code, but they help to remember if you only want a certain type for a variable...
e.g. name: str = "Roy"sg
Top comments (0)