There are two types of newcomers to Python:
Those who are starting to learn programming and have been told (correctly) that Python is the best language to learn, and
Those who are already proficient programmers in other languages but are moving to Python for the first time.
When we talk of Python for beginners we typically refer to the former group, and in this Beginner's Guide to Python blog post I'll outline why Python is so popular with those starting to learn coding.
But I'll also discuss some of the misconceptions or "old-fashioned" views that some programmers that come from non-Python backgrounds have of Python.
A Brief History of Python (sort of)
Python can now best be described as a middle-aged programming language, in its prime. It's certainly not an old programming language but we can no longer consider it as a young upstart either.
I've written elsewhere about my personal route into programming first, and Python later. When I joined the real scientific world as a PhD student, one of the dominant languages for scientific computing (certainly in my field) was MATLAB. I learnt all of my early programming through it. Python already existed as a very young language at the time, and when it started to become more popular, the scientific field was one of the first to start adopting it. I remember one of my PhD students trying to convince me to swap from MATLAB to Python (I had too much code written in MATLAB to consider the swap at the time).
In science and elsewhere, Python soon became one of the main players owing to one of its main attributes: it's quick and easy to write a program in Python.
But Python grew beyond the relatively narrow applications of science and over the years Python found its way to more and more diverse uses, from web development to data science to nearly every aspect of computing.
From Young Upstart to Mature Language
The defining characteristic of Python is that it's relatively easy to start writing code and getting things done. The language was designed to make it look as close as possible to spoken English (within the limits of programming languages, of course). As a programmer, you don't need to worry too much about the fine details of what's happening internally in a computer. Instead you can program at a higher level. Here's an example.
You need two bits of information in your program, the name of a player and the score in a game, for example. So you can write:
name = "Stephen"
score = 0
In programming, the type of data that is being stored matters. The first one of these is what's called a string – a string of characters. The second is a number, or more specifically a whole number, or integer. As a programmer you don't need to tell Python any of this – the language will determine by itself that name contains a string and score is storing an integer.
This may seem obvious, but it's not. In other languages, the programmer needs to state this explicitly. Now let's assume somewhere in the program we have:
score = score + 1.5
The player's score needs to be increased by 1.5 so score is no longer a whole number now. No problem, Python can take care of this and the programmer doesn't need to worry about it (not so in all languages).
Now, this is not necessarily a feature you want for every application in computing, but in many applications this allows a programmer to write code more quickly, using fewer lines of code, and very importantly, making the code more readable and easier to update.
There are other similar examples when comparing Python to other languages and in all instances, Python is designed to make writing code quick and relatively easy.
Python is a Multi-Purpose Language
Not all coding languages are suited for all needs. Some have very specific niche applications, others are best used for very high-end specifications, but very few are very good at very many applications. Python is one of those very few languages. And once you factor in how quick writing code in Python is compared to other languages, you have a stand out winner in 2020.
Like many programming languages, Python has libraries that can be used for certain applications. These are collections of commands that are specific for a certain use. Python has a very large and broad set of libraries available. These include libraries to deal with subjects as varies as finance, astronomy, web development, data science, machine learning, writing games, statistics, and the list goes on…
Why is this important? Anyone who needs to write a computer program for any application will find libraries that have commands that they need. This means they don't have to write everything themselves, from scratch. A programmer can therefore quickly write code and focus only on the specific task they want to explore, without having to waste time writing lots of tools that may be needed along the way. The speed with which a Python project can be written, compared with other languages, plays a significant role in Python's popularity.
Any Drawbacks? Yes, but Let's also Deal with Misconceptions
The features that make Python a great language are not always what's needed, though. This is why we have many programming languages, because they all have some advantages and some disadvantages
In certain areas of software development, a programmer needs to have more control on what happens "behind the scenes" of a computer program. This is an area where a language such as C or C++ comes in useful. So no, Python is not always the right solution.
Also because of Python's aim at making writing code quick, the execution and memory requirements of a Python program may not be as efficient as with other languages. If the raw speed of a program is of utmost importance, then Python is probably not the language for that application.
For most applications, the relatively slow execution of a Python program will not make any difference in the end (if a program takes 2 seconds to run instead of 1, that's perfectly fine). The speed of development does though. Code that may need a day to write in C++ may be completed in an hour in Python, say.
The Google Video versus YouTube Story
Here's an example of the importance of speed of development. Way back in the earlier days of the internet, Google had already grown to a reasonably-sized company and they set up a team of hundreds of developers to develop Google Video: a platform to store videos that users could search for and watch (sound familiar?)
A small start-up called YouTube had a team of 20 developers. No way they could compete with the mighty Google, you might think.
However YouTube kept coming up with new and exciting features at a very rapid rate. Google, with their much larger team of developers, couldn't keep up.
Reason: Google developers were using C++, YouTube however was using Python (and still does) and therefore could deploy new ideas more quickly. As a result, Google Video doesn't exist today (although later Google went on to acquire YouTube, of course).
Python has also evolved a lot in recent years. It's no longer as slow as it used to be, and in many applications, libraries such as NumPy and asyncio have made Python rather quick and a lot more memory efficient. I have also seen a clear shift in the type of programmers who are shifting to Python in recent years. It's no longer just scientists and data analysts who rely on Python, more and more programmers coming from pure computer science backgrounds are focusing their attention on Python.
Final Word: The One Certainty About Python
In all the debates one can have about Python vs other languages in terms of speed, memory and other technical aspects, there is one thing that is absolute and unquestionable:
Comments