Recently I had a discussion over Reddit over why would someone would use Python over other programming languages. The discussion was pretty good and thus I thought about writing a post about it.
First of all, let me give you my thoughts on Python. Python is a language I love and can be used in a wide variety of applications, though I agree that languages have their falls, I do believe its a great language for professionals to use, and also for beginners to enter the fascinating world of programming.
With that said, would I use Python on every single project? Likely not! but there are some areas where Python excels, and I want to highlight those, and explain why.
- API Development
- Data Science / AI
Let’s review them in detail.
There are some excellent frameworks for API development with Python, among those, there are 2 favorites among the development community, Django and Flask (on Flask I wrote an article on why I like it so much and a base project to set up your APIs, check it out here).
The conversation around API development went immediately into the direction of web frameworks, why? Well… I don’t believe that you should write your own web server or framework when you want to focus on writing the code for your API.
Some people also argue the use of Python for web development in general, though I generally don’t like to use those frameworks for the front-end part, and I prefer to build front-ends using React, or any other like VueJS or Ember for that matters.
If you are getting started with API development in Python, is likely you will end up using either Django or Flask, so you may ask, which one of the two should I use?
Django VS Flask
Both of these frameworks are great and will work for most situations, however, they follow different philosophies, some people like 1 more than the other and there are good reasons on both sides. Since both of these frameworks are so different in essence I’ll only give you the high-level differentiation between the two, and I recommend that you read more about them and that you tried them both before deciding which is the best for you and your project.
- Flask is a minimalistic framework, it provides simplicity, flexibility, and fine-grained control. It is very unopinionated (you can do with it what you want!)
- Django on the contrary is an all-inclusive framework. You get all from libraries to an admin panel, db interfaces, ORM, and even a solid directory structure for your apps out of the box.
If you want to learn more about this, here is an interesting article I found: https://testdriven.io/blog/django-vs-flask/. And there are a lot more options if you google Django vs Flask.
Data Science / AI
Any time you want to work with data, from scraping, data analysis, visualization, machine learning or AI, Python will be your best friend. There are a number of important libraries for each one of these tasks, and they are great libraries, highly used in research and production environments.
I’ll not go into details of the libraries, but I want to mention a few: Pandas, Numpy, Matplotlib, Seaborn, Tensorflow, Pytorch, scikit-learn, Keras, NLTK, OpenCV.
Thanks to these libraries, you can build production-ready projects in almost any Data Science or AI topics. Though there are some drawbacks of using Python for some of these applications (such as performance), for many situations it will make for a great selection.
What kind of projects are we talking about?
There are many many applications of python for data science and AI in general, I’ll mention here a few common projects Python is used for:
- Time series analysis
- Sales predictions
- Language processing
- Sentiment analysis
- Recommendation systems (like music, videos, etc)
- Computer vision
- Self-driving cars
- many more….
Scripting usually refers to small programs (usually executed through command line) that are designed to automate simple tasks.
Let me give you a few examples of scripts I wrote myself to automate parts of my day to day workflows:
- My blog: I use Evernote to collect everything I see on the web, and also to write my posts. But then, when it’s time to publish I take those notes and upload them into my blog as drafts. This process happens automatically on Python, whenever I marked a note as “ready to be published”, I run a python script that will copy the note, format, and draft into my blog system. Of course, there’s always something I need to manually fix before I actually can publish (mostly due to Evernote weird HTML? output).
- Backups: I like to make backups of my things in the cloud, but I also keep a copy in an external hard drive. I usually encrypt all that goes to the cloud (with the exception of Evernote, which doesn’t allow me). But when I make my backups into the drives, I use drive encryption, and I don’t want to have it double encrypted, so when I want to backup data into my drive, I run a python script which will decrypt the data and then move it to the drive.
Python is a very versatile programming language and thanks to its community and libraries you can pretty much do anything you want, though sometimes you shouldn’t. There’s no one language to rule them all, they all have advantages and disadvantages, and Python is no exception.
With that said, I do believe Python is great, and if you are curious you can build from games to embedded systems, all with Python, though probably those cases won’t be production-ready projects, maybe I’m wrong, if so please let me know, I’d like to hear about it.
Live Code Stream is also available as a free weekly newsletter. Sign up for updates on everything related to programming, AI, and computer science in general.
Celebrate Pride 2020 with us this month!
Why is queer representation so important? What’s it like being trans in tech? How do I participate virtually? You can find all our Pride 2020 coverage here.