Noble Desktop Blog | Tutorials, Resources, Tips & Tricks

# Python Versus: A Look at the Fastest Growing Language

In recent years, Python has exploded to become one of the fastest-growing languages. Traditional object-oriented programming languages have many rigid rules, and Python often breaks the convention of these languages, offering simplicity to counter this rigidity. For novice programmers, it may be more beneficial to learn code through the lens of simplicity and elegance versus robustness and completeness. Both have their tradeoffs, and here are a few key examples of how Python separates itself from the pack.

## The Numbers

Imagine when you were younger, and your teacher was teaching you decimals for the first time. They were their own scary thing, a fancier kind of math that had its own set of rules. Not only that but the numbers you knew before were suddenly called integers, a word that as a kid was one that was hard to remember or pronounce. It’s the kind of surprise that has many kids giving up on math for adding complexity because at the end of the day, aren’t numbers just numbers?

Computer science originates from mathematics, and as computers were developed, code was developed with this mathematics in mind. Because numbers have theses rules, we type numbers either as integer (commonly int), or decimal (commonly float, less commonly float32, float64, or double). These types have different sizes and computational efficiency and retain all of their mathematical characteristics.

But because these numerical rules mean so much for computing, most languages require numbers to be declared from the very beginning and to set the type when necessary. In many languages, we would declare a variable and change a variable as follows:

As we leave academia and enter the workforce, we often forget the distinctions between the integers and floats, and these two different types of numbers are just considered numbers. In everyday life, how often do we see a distinction of a hundred dollars as \$100.00 or \$100? Since most Python code is written in Python 3, this line is blurred completely, as everything is simply just a number.

Python sees the everyday number, and for most people, this is a simplification that adds to Python’s appeal.

## Semicolons vs. Spacing

Python differs greatly from C++, Java, and JavaScript in that every statement in those languages ends in a semicolon, whereas Python ends every statement in each new line. By having a single statement for each line, Python becomes easy to read, and errors generated by missing semicolons become reduced.

Furthermore, structuring of functions and conditional statements in Python are handled with spacing. Each expression is indented on the next line, allowing for a structure where each thought is encapsulated in its own space and punctuation rather than in the traditional braces structure.

The following is a Python vs. JavaScript comparison:

### Python:

Visually speaking, both sets of code look similar, but there is a key difference. With other languages separated by semicolons and braces, indentation is optional. In Python, since there are no other ways to tell if a code belongs inside or outside an if statement, indentation is mandatory. As this indentation alters the code so that every nested piece of code represents a thought inside a statement, reading Python can be seen as easier, especially if code is not properly indented.

## Iteration

One of the tools that programmers use to do a repetitive task is iteration, a way to perform a task a number of times given some data. For example, if we were given an array of scores:

X = [90,91,93,92,95,94,97,99,75,83,86,92,100,78,20]

To print each number in the array, many languages would look at the index of each element of the array and create a for loop to print each number. For example, in JavaScript:

Here we are going through each index of X, and printing the number associated with each indexed item. After each iteration of the loop is processed, the variable i is increased by 1, as noted by “i++” (this is where C++ got its name).

Python, however, has built-in iteration functionality for their arrays, which in Python are called lists. Each item of the list can be accessed individually and in order, making this same for loop in Python as:

Additionally, Python has a shorthand for these loops called a list comprehension, which compresses the loop into a single line of code:

Python handles lists and other data structures through iteration very well, and this is one of the key advantages for Python being a language that can manage large data sets. The extra math of addition is ignored and every item can be accessed very easily.

## Conclusion

We have seen how Python differs from other programming languages in how it handles numbers, spacing, and handling lists. This distinction is sure to bring in people that don’t come from a strong mathematical background. However, the differences we learned are differences in syntax (how language is written). But syntax alone might not be the only reason to choose Python as a first programming language.

Every computer language is written for a different use case, and this might also be the deciding reason for choosing a computing language. Depending on the focus, a language may be better for web, data processing, or business applications. Python is a language that can do all of this seamlessly, so come check out our different Python classes to learn how to use Python for a variety of applications.