INTRODUCTION TO PROGRAMMING WITH PYTHON (2015)

CHAPTER 2. WHY PYTHON IS THE PERFECT LANGUAGE

In an age where machines are becoming highly intelligent and are continuously simplifying human-machine interactions, it only makes sense to use an intelligent programming language.

Existing statically typed languages such as Pascal, C, or other subsets of C++ and Java introduce verbose syntax that cloud the actual process of problem decomposition and design of data types that have to be programmed.

Hence, for someone who does not know how to code, these languages seem unnatural. Furthermore, the additional complexity of the syntax only slows down the pace of ingraining the methodology of programming.

This is where Python brings in the power of simple and consistent syntax, backed by a large standard library with real problems.

Notwithstanding the rise in its popularity in American colleges as reported by the Association for Computing Machinery, Python has effectively replaced Java as the first language of choice for budding programmers.

So what is making Python the perfect language after two decades of being in the field?

#1— MINIMAL SETUP

Installing and running Python is extremely simple. All you have to do is download the file and either run it through the Terminal program (for Mac), or the PowerShell program (Windows), and Lo and behold! You’re running Python.

#2 — WRITING A PROGRAM IS AKIN TO WRITING IN ENGLISH!

Python is a universal language. This means that its syntax and coding lingo is exceptionally simplified and easy.

Python is the closest thing to writing a logical argument in English. The commands are simple and the additional baggage of grammar (programming syntax such as brackets, colons, quotes, etc) is minimal. You grasp how to systematically break down a problem into simpler steps, and you can easily code it in Python.

In a phrase: a great first experience for any beginner.

The standard first hands-on programming experience that all beginners go through is to print something on the screen using coding. This is normally the words “Hello World”, among others.

Python makes it literally a matter of writing a sentence

print("Hello World")

Compare this to the following (Java):

public class HelloWorld {

    public static void main(String[] args) {

        System.out.println("Hello, World");

    }

}

Furthermore, when you move ahead into the course, other examples of simplified programming will leap out, including simple reading/writing of information, string processing, GUI’s, website code, Databases, websites, etc.

Its simplicity and ease of programming is the reason why it has been adopted by so many people and for such a wide range of tasks. This is further made enjoyable by the fact that a very large community of enthusiastic developers is always a buzz to aid new comers become initiated into the fold.

#3 — PYTHON IS EASY TO READ

Python is designed to be an easy read.

“Readability” of a code may and seem unimportant right now, but it becomes the defining factor when the code becomes larger and more complex.

Readability is very important, because unlike a course book, the chapters (or chunks of code) are not always arranged to work in a step-by-step or linear order. At times coding blocks in the far recesses of the code need to be called earlier, or later, multiple times throughout the code, and so on.

Ease of readability is important for sharing a code between a team, for troubleshooting a program, and for making changes to it. In traditional languages, reading becomes increasingly difficult as because of all the non-English grammatical syntax.

Python uses indentation to give structure to the code, and though programmers who are migrating from a different language to Python may be heard complaining about the lack (and near absence) of braces, it is one of the key benefits of Python: it simply de-clutters the work environment!

Think of indentations like the headings in your word processing software (H1, H2, H3, H4, H5, and so on). In coding the headings are normally curly brackets (“{}”) that have to be added at the start and end of the paragraph.

As a result, two types of communication are happening simultaneously: braces to tell the machine about the program, and the indentations to tell the reader (another programmer) what the program is about.

Now imagine NOT having to add brackets and indentation and follow a legend you have created earlier to keep your program readable. Python does this by offering a single structure to denote a program: making it easier for humans and computers alike to read it with ease.

#4 — YOU DO NOT HAVE TO COMPILE THE PROGRAM TO RUN IT

When you’re learning something new, mistakes are bound to happen. How those mistakes are shown to you often plays a crucial role in how motivated you are to try again, or how affected you are by the mistake that you have made. With Python, all errors are identified at run time instead of showing a failure to compile error. This makes it easier to identify and fix mistakes immediately.

This is incredibly useful when you will be designing a complex algorithm where changes are made continuously. Where other programming languages will waste time taking you through the compile-run-debug cycle, Python simply shows the result (or the problem) in the same interpreter.

Hence, you can make innumerable changes to a piece of code and execute it in real-time in the interpreter. This boosts the learning process as you can consciously make errors, see its impact, and troubleshoot the program. This dramatically reduces the development cycle, and becomes especially useful for rapid prototyping of your code.

#5 —PYTHON IS OPEN

Python is an open on two accounts:

1)     Open source as programming language

2)     Built using Open objects

As an open source platform, its liberal distribution license allows the language to be used for coding programs/apps that can seamlessly be integrated as an extension of other propriety languages.

In terms of coding architecture, Python is great at introspection because the code is based on discrete chunks of programs (known as objects). We will get technical later, but for the moment “being open” means that it will be really hard for you to write dirty code or sidestep proper coding methods to solve problems.

Hence, Python forces you to write better code from the beginning, and this proves very helpful during debugging.