Why Python Should Be Your First Programming Language

Everyone has their own reasons for wanting to learn to program. Some see programming as a potential high paying job, others see it as a unique way to apply their intelligence, or express their ideas. Some see it as a way to start making games, or creating apps for the App Store.

Any way you look at it, learning to program is like learning a new superpower. Once you’ve gone through the journey, you can make software do almost anything you’d like. You literally create new realities for people to inhabit and change the world around them.

The most difficult part of becoming a programmer though, is getting started. It’s the same with any journey. Knowing where to begin, what programming language you should choose, what book you should work with, and whether or not you should use a formal class to structure your learning.

Regardless of what your programming goals are, Python makes a great first language, because Python’s simple structure makes it easy to learn the basics.

But, at the same time, Python and it’s libraries are powerful enough to be able to do anything you’d want to do with a programming language.

That being said, let’s dive into more specific reasons why it makes sense to choose Python as your first programming language.

Easy Installation (and Free!)

Getting Python up and running is easy, regardless of the platform you’d like to develop on.

For Linux, getting the interpreter installed is just a sudo apt-get install python away. On Windows, there’s the great Anaconda package, and with this you’re ready to start writing code.

Installing libraries is also extremely easy, both for beginners and more advanced users.

With pip install, you can quickly add most libraries to your working Python environment. As a more advanced user, you can make use of virutalenv to be able to create unique library environments for each of your projects.

Easy to Read

Of all the things that make Python such a great language to learn, being easy to read has to be at the top of the list.

Python is about as close to written language as a programming language can get. The language designers decided whitespace (returns and spaces) should be significant, and this gives Python code a look almost like a poem.

This space around Python code makes readability one of the primary focuses of the language. Meaning, when you read somebody else’s code, (or even your own!) it’s easy to quickly visually decipher which parts of the code belong to one another.

Plenty of Example Code

Speaking of which, there is plenty of great example code written in Python. A Github search for Python code can turn up millions of lines to read through.

As a beginner, you may wonder how you’ll be able to tell what good Python code looks like, and what doesn’t.

To me, this is a matter of taste, and is something you should develop on your own, without guidance. At first, you may not know anything. But if you look around, eventually you’ll find some code style that resonates with you. Usually it’s very simple, tending to less lines.

Great Documentation

If Python code is visually obvious, and you can just read other people’s example code if you get stuck, why would documentation matter?

Python libraries in general have a great pattern of providing example code for the most common tasks. For example, the great `requests` library has examples of how to download the library, grab an entire page, and display it right on their homepage.

These sorts of examples are mostly a hallmark of Python library documentation. Each library gives the most basic, common examples in code, allowing you to quickly implement your first attempt at a solution before going deeper.

Great Libraries

Requests. Turtle. Pygame. WxPython. Flask, Django. Tensorflow.

Each of these is a library that gives Python its super powers.

Requests allows you to connect to any website on the internet and send and request data from it. It turns these sites directly into variables you can work with from within Python itself.

Turtle lets you use Turtle graphics to learn the concepts of programming. It works directly in the Python interpreter, and gives beginners an easy way to see what it’s like to start writing code.

WxPython lets you build desktop applications. It works across multiple platforms, and gives you a way to start building visually interactive applications that look and feel like traditional desktop apps.

Flask and Django allow you to build powerful interactive websites. Instagram uses Django for their backend processing of the app, and Pinterest uses the same. Flask has been used to build multiple APIs used in apps you use every day.

And finally, Tensorflow gives you the tools to build your own deep learning and AI applications. It’s been used to develop some of the most exciting advances in language and image recognition in the past few years, and its models can be directly embedded into any application.

Quick Idea Turnaround with iPython and Jupyter

Jupyter and iPython are two different ways of working interactively with Python itself. Rather than typing our commands into text editors and running them as parts of our entire program to check if they work, iPython and Jupyter take in our commands and run them line by line.

In this way, we can quickly check if our language syntax is right, or what an error might be before having to write a full program. They give us a way of playing around with our code without having to run all of it at once.

Integration with Editors (autocomplete)

Emacs, Vim, Visual Studio Code, Atom.

Python has intellisense integration with the major editors. This means you can start typing out your Python commands, and your text editor will let you know all the commands and variable names that are available from within your code. This means less errors when you’re just beginning.

Works for Multiple Paradigms (games, web, math, deep learning, video)

As we hinted at with the libraries available for Python, there is a huge set of available addons (again, called libraries) to make Python do anything you’d like. From building a game, to building websites, doing scientific math problems, editing videos, deep learning, it’s all there and available.

Reasonably Fast language

For a beginner, Python is just fast enough. Your programs get run almost immediately, even though they’re not compiled.

Python spins up quicker than a language like Java which needs a JVM to be running before it can get started. This means your programs run fast enough, and speed isn’t usually an issue with anything beginners want to build.

Cross Platform (Linux, Mac, Windows)

Python programs can be built and shipped to run on Linux, Windows, and Mac. You can do development on any environment, regardless of what operating system you’re working with. And depending on your approach, your code should mostly work with all platforms.

Well Paid Language When Done Professionally

Python is one of the highest paid languages for programmers generally. Starting with a language that’s easy to learn, allows you to experiment with different programming ideas, and gets paid at the top of all developers? Why not start with Python?

Why Not Python for First Language

Only want to make traditional native apps for iOS

Apple releases new APIs and features with almost every iOS release. Although it’s true you can create apps in Python (using a library like Kivy), it’s not going to be an ideal environment for building applications that feel like native iOS apps, with the latest features.

Want to make 3D game engines from scratch

Python is a higher level language. This means you won’t have direct access to make some of the speed tweaks associated with static, lower level languages. So you wouldn’t necessarily want to build a game engine using Python, because it won’t take advantage of things like parallel computation that is so necessary for a modern 3D engine.

Need to take advantage of heavy computational power

Again, as discussed before, Python is a higher level language for programming. It also has a glaring problem with running on multiple cores, called the GIL, or global interpreter lock.

The global interpreter lock means a running Python program can’t use multiple cores for a single shared memory instance. This hinders some potential speed gains from the multiple cores we’re now seeing in modern processors.

Someone who wants to focus on extracting every last bit of speed from multiple cores wouldn’t necessarily want to fight against this in Python, although it is being addressed.

Want to start from the lowest level of abstraction

Because it’s a higher level language, some of the built in Python data structures don’t necessarily match the traditional, computer science version of data structures optimized for the computer’s architecture.

For instance, in C, arrays are created with a set size, along with a set size for each element in the array.

In Python, lists can be resized and added to transparently. They also can have different sorts of elements inside of them, with different memory footprints.

Coming to Python as a first language, you may miss the opportunity to see the reasons for traditional data structures right away. However, I personally don’t think it hurts to learn Python first, and then go back to the traditional data structures later. It just makes the process of learning easier in general. Less things to worry about at the same time.

Get Started Today

If you’re looking for a course to get started with programming in Python, I recommend you get my book, Make Art with Python. It’s built for total beginners, and includes videos for each chapter, walking the reader through all the difficult gotchas that might come up.

It’s the perfect introduction to programming, especially for people who have struggled with getting started in the past. Multiple readers have let me know they’d tried multiple courses in the past to begin, but nothing stuck. And Make Art with Python has finally gotten them to stick with it. This is what I’m most proud of with this book.