Python gets talked about over and over again across the internet, and we're no exception here at Red Shark Digital. Though WordPress, which is written in PHP, is far and away our bread-and-butter for the development team, we've had a few situations where Python was the perfect tool to reach for. It's a general-purpose language, which means it was written to be used for really whatever is needed. PHP, my first true love as a developer, was written to do one specific thing, and do it very well. But languages like Python were written to be a jack of all trades, master of none. Still, it's extremely popular. Let's take a look at why that is.
Most programming languages you see today are heavily influenced by "C", the grandfather of nearly all modern programming languages. For the most part, this means similar syntax from one language to another. If statements, while loops, it'll all look fairly similar from one language to another. Let's look at a couple of examples so you can see how Python is more clean and appealing to the human eye.
var age = 21;
if (age >= 18) {
console.log('You are old enough to vote!');
} else {
console.log('Sorry, you cannot vote yet.');
}
Let's look at what this does and break it down real quick before looking at the Python version. We create a variable (that's what 'var' is short for) of age and set it to a value of 21. Then we check to see if the age variable is greater than OR equal to 18. If it is, we let the user know they can vote. Otherwise, we tell them they can't. Pretty straightforward.
Notice the semicolon ( ; ) being used. In programming, it's basically a period. The first line is a statement. We create a variable, give it a value. That's it. It's over. So we end the statement. Same thing with the "console.log" portion. We use a function that basically prints out whatever we put in quotations. Those are statements, and they also end with a semicolon. Then, we have this nifty parenthesis that tell us what the conditions are, then curly braces to say what to do in what conditions. It may look weird to the every-day person, but it's just normal punctuation for us developers. But now, let's look at Python and see how much more readable it is.
age = 21
if age >= 18:
print('You are old enough to vote!')
else:
print('Sorry, you cannot vote yet.')
First off, you may notice there are no semicolons. This is because Python just assumes that the end of a line is also the end of your statement. You also don't have any parenthesis, which just makes it look even more like English, and no braces. It's much easier to understand to the everyday person. The lack of all these extra programming-punctuation marks makes it feel more natural and less abstract to those who aren't developers. This also makes it a lot easier to learn. So even though Python is a powerful programming language, it makes getting into the field much more approachable.
Python is open source, which means anyone can contribute. And since the language itself is open source, it's often used for open source projects. This had lead to countless libraries and modules being written in python, for python. Things like "Beautiful Soup" that helps you with web scraping, or a framework like Django or Flask that help you build full-on websites in Python.
Not much for doing stuff with the web? Maybe you want to do something with data science. Well, scientists aren't necessarily programmers. But if they want to have something to do the hardcore math for them, why not learn an easier language? This has lead to Python being extremely popular in the data science field as well. And the same can be said for why Python is so popular in other fields like Robotics or Machine Learning. People who aren't primarily developers, but maybe need something coded out for whatever reason, can just pick up this wonderful language to build out whatever it is they want/need. Sure, it may not be as elegant as having a seasoned programmer do it for you, but it's also free when you do it yourself. So if it's just a simple little script you want to write, do it yourself!
Python has a wonderful community filled with passionate people that love what they do, and jump at every opportunity to share their knowledge with anyone willing to learn. They even have terminology that just makes things more fun. Are you writing good, readable, maintainable code? We call that "pythonic". Are you a skilled developer in the language? Well, that makes you a Pythonist. Unless you're a true pioneer in the world of python, then you get to call yourself a Pythoneer. Sure, they're dumb little things that have nothing to do with the language itself. But little things like this are what make the craft, and the language, all the more enjoyable.
If you want to write a mobile application or downloadable/installable desktop software, Python probably isn't the best choice. Sure, it's possible, but it requires a LOT of workarounds and dependencies. We leave things like that to Java or Swift. But if you want to build a fast and capable web API, some process automation scripts, or anything along those lines, Python is just the language for you.