MrValdez's Blog

Reasons to use Python

Posted on May 12, 2018

I'm a polyglot computer programmer. I am proficient with C, C++, Visual Basic 6.0, C#, PHP, and Python. I have basic knowledge with Java, Go, and Pawn[1], but I am very confident I can code with these if I have the manual available.

I personally like Python the most. In this post, I'll point out the advantage of using Python.

Miss Kobayashi's Maid Dragon is an anime where the main character is surprisingly not a teenager but a young adult who have a job as a programmer. Her using Python is just a nice bonus.

As a quick summary, here are the reasons I'll discuss on this post:

  • Readability and Simplicity
  • Easy to understand even by non-coders
  • No need to think of memory management
  • Open source libraries for all the tasks you need
  • Heavily used in Information Technology
  • Used in Mathematics and Science
  • Used in Animation
  • Python is fun
  • Speed of making a working prototype
  • Philosophy in designing the language made it consistent

Readability and Simplicity

In programming class, students are taught the Pseudocode, a non-existing programming language created to teach programming and to show non-coders how a specific code work. The idea is that programming is complex and only "smart people" wizards can code the incantations to make software do what they want. So Pseudocode is used to let mere mortals understand the complexity.

But what happens if the source code is readable enough that a beginner programmer can understand the complexity? What happens if the complex programming can be simplified by abstracting common code patterns into syntactic sugar?

Python was designed to be readable and by happy coincidence, it made code easy to understand. Why learn Pseudocode when you can instead use a working programming language?

Easy to understand even by non-coders

As a teacher, I teach computer programming. In my experience, motivated non-coders can learn Python in less than a day. This gave me the belief that Python should be a beginner's first programming language.

The code might be from, but they took the time to translate the comments. Because comments are important, right? (youtube clip link)

No need to think of memory management

Many times as a teacher, students would ask me technical questions. Most of the time, I would be able to code something explaining the answer in Python. If I were to use C, I would have to pre-plan what data types I need to use and during coding, I need to remember to free() any malloc().

With Python, I'm more focus on the algorithm without the distraction of telling the computer how many bytes I might need for the program.

Open source libraries for all the tasks you need

Years ago, I noticed a trend with education where they champion open source and that it should replace proprietary software[2]. I was in high school at that time, and I made the wrong assumption that only wizards can contribute to open source (see above). I was wrong and I wish education would also champion contributing to the ecosystem.

Because what happens if the barrier to entry is lowered because of the code's simplicity? A boom in open source libraries in almost all topics that you can think of. Do you want games? Python have open source frameworks for making and playing games. Do you need to make a report for Excel? Someone already made a python library for that task, somebody else improved the code, and everyone contributed to the documentation. Want to make a program using the bible? Sure, why not?

And new open source are created everyday. Anyone can code and the barrier to entry is low, so anyone can become part of the community.

However, since everyone can contribute to open source, the quality is all over the place. This is still a positive in my eyes. Because a project that is unpolished but have merits to be useful, the nature of open source means that you can contribute and make it better for everyone. This is the philosophy and strength of Open Source (and what should be championed in education).

Heavily used in Information Technology

One time, I was asked what software can be made with Python. The popular answer are web servers and artificial intelligence. My answer is: everything. You can make anything you want with Python.

I was once told that no IT companies use Python (or that it is just a fad). I reply that Python is used in Google, Microsoft, Disney, NASA, Mozilla, IBM, Facebook, Instagram, and more. Some companies even use Python internally, so even if their public-facing services aren't Python, it's useful to learn the language.

Python is a general programming language and can make anything other programming languages can make.

Used in Mathematics and Science

Did you know that there are many mathematicians and scientists have need to develop custom-made software to run their experiments and test their theories? They hire people to write them code written in C, R, J, Matlab (I find it amusing that a lot of programming languages are named after letters), and more.

But in the last few years, there have been an increase in mathematicians and scientists learning how to code. The combination of readability and ease of understanding by non-coders have created new toolsets that are usable by these researchers.

The future is exciting with the new research that are being created with Python.

Used in Animation

I have to admit that I have limited first-hand knowledge on Python and Animation. But there are people who knows more than me and have written about it:

You can also use Python with 3D animation tools like Blender and Maya.

Python is fun

The above xkcd comic is true! After years of C++ and PHP programming, Python made programming fun for me again.

There are also a lot of inside jokes/easter eggs and some things are playful (the IDE that comes with Python is named after a famous comedian). The developers' playfulness should be expected as the programming language is named after a comedy troupe.

Speed of making a working prototype

Anecdote #1

During my doctorate class, one of my classmates asked for help with his doctorate. He needed a program that can extract height map values from a map. While he explained what he needed, I started making a prototype. In less than an hour (before we finished our coffee), I had something that he could use. This surprised him because it took him a long time to build his prototype.

Anecdote #2

This blog was created with Django in less than an afternoon. I have experienced with Django apps before, so its not my first time.

And while it's true that blogging software can make you a website in less than an hour, my blog is custom-made for my needs. Blogging software have a default vanilla state where you need to add plugins and themes for your needs. Their target audience are not coders so people like me who have technical knowledge and can do more than pre-built web software.

Anecdote #3

I am a hobbyist game programmer. I use game programming to teach computer science concepts in class.

I participate in the Global Game Jam where you have less than 2 days to make a game. In four of the game jams, I used Python.

During Global Game Jam 2018, I made 32 games in less than 2 days using Python. I can't imagine being able to do this with any other languages.

My writeup for this GGJ is still being written. In the meantime, you can look at the 32 games here:

Philosophy in designing the language made it consistent

The language designer of Python is not a beginner in designing and implementing programming languages. His experience means that he have ideas on what a programming language should look like and what elements are useful to a programmer.

Tim Peters, a core developer of Python captured the design principal of the language and wrote it down as the Zen of Python, to serve as a foundation for future updates.

Reasons not to use Python

In a future blog post, I'll talk about the reasons we shouldn't use Python.

[1]: During college, I was looking for a scripting language for my C++ game engine. It was a choice between Pawn, Python, and Lua. I choose Pawn at first, then transitioned to Python months later.

[2]: I also find it ironic that schools still teach Microsoft Word and how to powerpoint. I've gone into arguments on using LaTeX over MS Word for research papers. I've also gotten annoyed that powerpoint is synonymous with presentations; to the point that I've seen news reports and government officials using the term as if it makes them "tech-savvy". To me, they have the opposite effect on their power.

Categories: Programming, Python