Save over 40% when you secure your tickets today to TNW Conference 💥 Prices will increase on November 22 →

This article was published on July 1, 2020

Python is great, but stop using it for every damn project


Python is great, but stop using it for every damn project Image by: Icons8 (Edited)

Recently, I had a discussion on Reddit about why someone would opt to use Python over other programming languages. The discussion was pretty good so I decided to write a post about it.

First of all, let me give you my thoughts on Python. This is a programming language I love and it can be used in a wide variety of applications, though I agree that all languages have their faults. I do believe it’s 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? Probably not. But there are some areas where Python excels, and I want to highlight those, and explain why.

  • API Development
  • Data Science / AI
  • Scripting

Now, let’s review them in detail.

[Read: 7 Python mistakes all beginner developers make — and how to avoid them]

API Development

There are some excellent frameworks for API development with Python and, among those, these are the two 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 immediately went 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, though I don’t like to use those frameworks for the front-end part, and I prefer to build front-ends using React, VueJS, or Ember.

If you are getting started with API development in Python, it’s likely you will end up using either Django or Flask. So you may ask: which one 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 one 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, but you should definitely read more about them before deciding which is the best for you and your project.

Philosophies:

  • Flask is a minimalistic framework. It provides simplicity, flexibility, and fine-grained control. It is very unopinionated (you can do whatever you want with it).
  • Django, on the contrary, is an all-inclusive framework. You can get libraries, 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/.

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 applications of Python for data science and AI in general. I’ll mention here a few common projects for which Python is used for:

  • Time series analysis
  • Sales predictions
  • Language processing
  • Sentiment analysis
  • Recommendation systems (like music, videos, etc)
  • Classification
  • Computer vision
  • Self-driving cars

Scripting

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 write my posts. But 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 can actually 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. When I want to backup data into my drive, I run a python script that will decrypt the data and then move it to the drive.

Conclusion

Python is a very versatile programming language and thanks to its community and libraries you can pretty much do anything you want with it, 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. Probably, those cases won’t be production-ready projects, but I may be wrong. If so, please let me know, because I’d like to hear about it.

This article was originally published on Live Code Stream by Juan Cruz Martinez, founder, and publisher of Live Code Stream. He is a Software Engineer with more than 10 years of experience in the field, working in a wide variety of projects, from open source solutions to enterprise applications. Happily married, with a kid, officially engaged to JavaScript, in a love relationship with Python, and pursuing the writer’s dream! You can read this original piece here.

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.

Get the TNW newsletter

Get the most important tech news in your inbox each week.

Also tagged with