Python: A Gateway to Programming for Non-Programmers

Introduction

When Guido van Rossum introduced Python it didn’t revolutionize the world of programming at first, it was its simplicity, accessibility, and cross-compatibility, making it the perfect gateway for the non-programmers in the scientific space that help see a boom in the world of data analytics. The rejection of its modern formatting and structure always left open a gate of criticism that would and still is difficult to shake. Even with this, I claim that Python, even as it continues to develop, will become one of the more preferred programming languages for various reasons.

Python’s Human-Readable Syntax

Python stands apart in its approach to programming language structure. Unlike many mainstream languages that rely heavily on mathematical operators, and (considering the time to which Python was introduced) heavy to exclusive usage of the static type declaration. Python’s use of reserved words that reflect a standard in making the code more readable, akin to human languages, such as the usage of “in” within the usage of iteration, not only makes Python appealing to beginners but also breaks the barrier for non-programmers to delve into data analytics without the fear of misinterpreting their results.

Breaking Traditional Language Structures

Python dared to diverge from the familiar syntax of its C-derived predecessors (known for being one of the most efficient, powerful, and preferred languages of its time and often today), choosing accessibility over-familiarity. This innovation allows non-programmers to leverage Python’s capabilities for data analysis, drastically reducing the learning curve typically associated with programming.

Interoperability and Cross-Language Compatibility

Python’s real prowess lies in its interoperability. The ability to run Python’s compiled bytecode in a virtual environment of another language elevates its utility, offering cross-language compatibility that is often absent or rudimentarily implemented in other languages. Noting this, if we wanted to develop in Python a Java or C# targeted project, then that is on the table when considering a development pipeline.

Python’s Overlooked Strengths

Despite the myriad of surface-level benefits Python offers, traditional programming often overlooks them. However, these features, in reality, present an intuitive way to introduce various programming concepts without getting mired in complex syntax, typical of other high-level languages.

Python’s Scalability and Community Support

Python’s value extends far beyond its initial simplicity. As users progress in their coding journey, Python grows with them. Its robust community provides a plethora of resources, allowing learners to easily integrate complex features, frameworks, and tools into their repertoire, thus continually enhancing their skills and knowledge.

The Impact of Language Structure on Innovation

The choice to stick to traditional programming structures might have been sensible in the past, but it raises questions about fostering innovation. Spending countless hours developing a tool for a specific feature might seem redundant when it could have been accomplished more effectively with a new tool or language. Every programming language and tool has unique methods and uses that can enhance or limit the efficiency of development, which in turn impacts the rate of innovation.

Comparing Programming Languages

Comparing programming languages is a complex task that extends beyond just tallying pros and cons. Every major language has its distinct position and usage that varies depending on several factors – where it’s used, the application it’s built for, the versions in use, and even the programmers involved in the project. The first time learning a language and working with it in a production environment can yield vastly different experiences.

The Factors Determining the Choice of Language

The choice of a programming language hinges on multiple factors. Often, it’s guided by the motivations and guidelines provided by an instructor. This influences the learning process of the student and the efficiency of the language in producing the desired results.

Web Development and Language Choices

Consider web development as an example to understand the practical implications of language choice. To achieve efficient results within a reasonable time frame, developers often need to use complex tools, frameworks, and other forms of middleware. This, however, can form a barrier for newcomers. In the Java realm, frameworks like Spring Boot exist, while in C#, we have ASP.NET with tools like Razor and Blazor. These enable developers to build web applications and other web-related tools using their native languages. Although these frameworks are fundamentally different, they serve a similar purpose: enabling programmers to create for the web.

A note to also be had while learning a tool, framework, or middleware, they don’t often reflect the wider nature of the programing language in use. For instance, when we want to make a data structure (let’s say a Binary Search Tree, BST), we would do that at the language level itself, not within a framework/tool/middleware. But if we wanted to learn about web sockets and moving data, we would stick very close to the tools themselves. At this point would neither our BST nor web socket knowledge would be of any help to one another, aside from structural knowledge gain.

Resistance to Syntax Innovations

There’s an interesting paradox within the programming community. Despite being a hotbed for innovation and interdisciplinary structures, we tend to resist changes to the tools we use daily, especially in the syntax of our preferred programming languages. The simplification or deviation from the ‘standard’ often incites criticisms or gets ignored altogether. But why is it so?

Questioning the Status Quo

Major companies like Microsoft and JetBrains have developed languages with unique syntax or structural differences, yet these innovative alternatives often struggle to compete with their more mainstream counterparts (Visual Basic and Kotlin respectively). Why are these simplifications, designed to make coding languages more human-readable, not more widely accepted? Coding shouldn’t feel like deciphering a cryptic language littered with mathematical symbols.

Barriers to Adoption

The reluctance to adopt new languages could be attributed to various factors. Perhaps the production environments lack support for the new tools, or these tools are not feature-rich enough to consider. Often, there’s simply no perceived need for a new tool in the current circumstances. Developers, comfortable with their existing tools and methods, may resist change. Then consider the deep level of the adoption, the hardware, and performance. If the current hardware cannot run or perform the same operation within the same usage of time and energy, then from a business level it losses its advantages position, and further consideration can be concluded. If the energy at the beginning (the developer’s energy to make cost) is less than the total energy usage in production, this metric isn’t a convincing argument, because the energy later lacks calculable measurements, it’s an unknown with many unknowns. Whereas the development now with a tried and true language has a greater amount of data points to calculate the development cost, and can even give data points to the evaluation of production cost.

This quick evaluation would lead to say, even if everyone at company X wanted to use the new fancy tools, we could never justify the risk to take on the unknown cost.

Understanding Python’s Simplicity

In comparison to languages such as but not limited to C#, Java, or C++, Python’s structure adheres firmly to a key principle: readability. For the sake of illustration, juxtapose Python with C++. Keeping in mind, the perspective here is entirely subjective, and meant to give some light to commonly grouped programming languages that have common duties, strengths and are often in the same circles.

Let’s take a simple variable declaration as an example:


Fig 1. 
#include <iostream>

int main() {
    int number = 1;
    std::cout << "Hello, World!" << number << std::endl;
    return 0;
}

Look at Figure 1, we have some boilerplate C++ (yes I can include the <stdlib> as there are a few ways to get this done). Here we have to pull in a library just to get something echoed to the console. Now we have a main and within it, we declare an integer, have a console out with a string, then concatenate it with our integer. Now, I will forgive the line count for the time being as the main focus is on the tools and all the actions needed to perform these steps.

Now, let’s consider the same action in Python:


Fig 2. 
number = 1
print("Hello, World!" , number)

In Fig 2, we see in a typical fashion of Python, that we just have these 2 moving parts, a variable of some kind being assigned to a value, and a console print line. Functionally, Figure 2 does the same overall task as the Figure 1 example. Now this is the goal, having the same functionality available with less. This a classic case of less is more.

Comparing Loop Structures

Another example that highlights the simplicity of Python is its loop structures.
(we will ignore line count for these figures/examples, as these can be altered and adjusted in many different ways).

Compare a ‘for’ loop in C++:


Fig 3. for(int i = 0; i <= n.length; i++)
               { 
                    cout << "i" << endl; 
               }

Python equivalent:


Fig 4. for i in range(len(n)):
               print(i)

The Python loop is simpler and easier to read, despite the often-criticized spacing-based syntax. Though this might be considered subjective, and further experimentation to find any objectivity in this case would be challenging, I’m running off the bases that reducing the usage of mathematical operators and substituting (and in some cases excluding mathematical operators) with direct English’s readable replacements. Now another tool that can even simplify this further is using the “enumerate(n)” instead of “range(len(n))” but this is a lesser-known tool that doesn’t work the same.

Unique Aspects of Python

Python includes some unique elements that might initially confuse developers coming from different languages. This includes using ‘None’ instead of ‘Null’, ‘len()’ instead of ‘.length’, and ‘is’ instead of ‘==’ for comparisons (In this last example, these operators are not truly comparable, as they their usages might be similar, what is happening on the backend is not the same, this is only to show how changes to accommodate readability have merit). However, many of these choices are rooted in enhancing the language’s legibility, a core reason why Python appeals to so many developers, including myself.

Exploring Data Types and Casting in Python

In Python, data types and casting play a crucial role in managing and manipulating data. While I won’t cover each data type in detail, let’s focus on some casting examples. When converting from a float to an integer, Python simply discards the decimal part. Consider this:


Fig 5. 
thisFloat: float = 1.9
thisInt: int = int(thisFloat)
# Result: thisInt = 1

For string casting, any primitive data type can be converted to a string. However, converting a string to an integer requires the string to be fully compatible with an integer, i.e., no special characters, decimals, spaces, or hexadecimal values. For example:


Fig 6.
thisString = "007B"  # Hexadecimal signed 2's complement for the value of 123
thisInt = int(thisString, 16)  # Here we specify the base to be 16 for hexadecimal
# Result: thisInt = 123

This example shows that Python is intelligent enough to handle different types of data efficiently and effectively.

Discovering Python’s Common Data Structures

List

A Python list is dynamic, accessible, and often the first choice for a process that requires unknown capacity, random direct access, and the ability to be iterated through. Lists can be defined in several ways:


Fig 7.
thisList = []  # Fig 7a
thisList: list = []  # Fig 7b
thisList = functionRetList(): return []  # Fig 7c

Set

A set in Python is an unordered, iterable collection of unique elements. Checking if a specific element is contained in the set is usually more efficient than using a list. Sets can also store mutable data types or structures and eliminate repetitions of elements. Here’s how we can create sets:


Fig 8.
seeSet = {1,2,3}  # Fig 8a
seeSet = set([1,2,3])  # Fig 8b

Dictionary

A dictionary in Python is a key-value system for storing complex data. While values can be any type, keys must be immutable. Dictionaries allow access to values through keys and offer iteration over key-value pairs.

Tuple

A tuple is an ordered collection of objects which is immutable. Tuples can be accessed randomly, just like lists, using square brackets. Here’s how we define tuples:


Fig 9.
theTuple = (1,2,3)  # Fig 9a
theTuple: tuple = (1,2,3)  # Fig 9b

String

In Python, strings are more than just data types – they’re complex data structures, similar to a list of characters. Strings support random access, slicing, interpolation, Unicode, and finding. Here are some ways to create strings:


Fig 10.
myString = 'hi'  # Fig 10a
myString: str = 'hi'  # Fig 10b
myString = """Triple quote for multi-line strings"""  # Fig 10c

These data structures form the basis for writing complex programs in Python, demonstrating the language’s flexibility and legibility.

Bonus – Understanding Authorization Checks

In our case, we are checking whether the user is authorized or not, and based on that, we provide the necessary responses. Let’s see how we can do it:


Fig 11.
def check_auth(self):
    if current_id:
        user = current_id.get_dict()
    else:
        return False

In this case, we first check if there’s an identification for the user. If there’s no id, we know that they don’t have authorization, and we return False. If an id exists, we retrieve the user by their id from the database and store the user in a dictionary.

Next, we need to check if the user has a policy value. If they don’t, we return False. If a policy value exists, we perform a check on the authorization instance. We’ll use the current access request object and any list of resources needed to perform the check. We’ll store any allowed pages in a list to maintain the session of page access.

This is a simple example of authorization checks. In a real-world application, additional checks would need to be made such as verifying HTTP header data, checking IP addresses for loopback signals, or checking CRUD requests to an open web socket.

Links and Citations

5 thoughts on “Python: A Gateway to Programming for Non-Programmers”

  1. I loved as much as you will receive carried out right here The sketch is tasteful your authored subject matter stylish nonetheless you command get got an edginess over that you wish be delivering the following unwell unquestionably come further formerly again as exactly the same nearly very often inside case you shield this hike

  2. you are in reality a good webmaster The website loading velocity is amazing It sort of feels that youre doing any distinctive trick Also The contents are masterwork you have done a fantastic job in this topic

  3. My enthusiasm for your work has matched my own. Your visual presentation is polished, and the high-quality content you’re producing is admirable. However, you appear to be concerned about the possibility of delivering something that will cause anxiety. I’m aware that you’ll be able to address this issue quickly.

Leave a Comment

Your email address will not be published. Required fields are marked *