• Home
  • Crack Software
No Result
View All Result
Cecile Park Media
  • Home
  • Crack Software
No Result
View All Result
Cecile Park Media
No Result
View All Result

Python Developers Push for Strong Typing: What Does This Mean For The Language?

cecileparkmedia by cecileparkmedia
May 12, 2022
in Crack Software
0 0
0
0
SHARES
5
VIEWS
Share on FacebookShare on Twitter

Table of Contents

  • Python developers want more typing
  • They feel that the language is too loosey goosey without it
  • Proponents of strong typing say that it makes code easier to read and maintain
  • There are several different types of strong typing, each with its own benefits and drawbacks
  • Python has been considering adding type annotations to the language for a while now

Python developers want more typing

Python is a powerful, mature language, and whitespace matters in it. The indentation of your code tells the computer what should flow where and makes reading your scripts easier for others to understand. Python also has an extensive set of standard libraries that can be tedious to use without having some idea of how they work (and they’re going further with typed attributes coming soon) and the right way to use them can be different for different people. This has led to an unfortunate split in the community: Python developers want typing, but the community doesn’t.
Python community does not want typing
A popular sentiment from people working in Python is that typing just gets in the way of what we do. E.g. Guido van Rossum’s opening line in his keynote speech at PyCon 2015: “Typing is a secondary consideration and it should not interfere with my productivity”.

python developers want typing
python developers want typing

They feel that the language is too loosey goosey without it

Python does not have an enforced style guide. With time it has gathered some de facto standards and a coding style evolves, but many people still feel there is no central place to go to find out what it is. For example, there are several ways of coding dicts in Python: the “Dictionary” module, the “Dictionary” class, the “set” module, and the “dict” class. Each of these has its good points but it is not obvious which to use. The language is highly dynamic and while there are several ways to write an old-style object or a class, you do not have the same choice when writing a function or an object.
Python’s lack of central authority over this issue is the cause of many online discussions between Python users who have different opinions on what the right coding style is and how to achieve it. Or, more accurately, how to make it everyone’s opinion instead of no one’s.
I decided to take a look into the issue by starting an online poll on Python’s official forums to find out how people think about this subject. I posted a poll asking for opinions on a few particular ways of coding dicts, the class-based approach, the DictMixin approach, and the set module way. They were all voted on in their order of popularity. Surprisingly, there was almost no difference in numbers between any of them. The clear winner was that everyone backed class-based coding style (almost 90%).

python developers want typing
python developers want typing

Proponents of strong typing say that it makes code easier to read and maintain

Proponents of strong typing say that it allows for better self-documenting code and makes it easier to catch mistakes in the code. Advocates of dynamic languages claim that checking types at run time is faster than doing so at compile time, and type checking causes less error messages and bugs. As an example, dynamically meaning of values (type-based equality or coercion) is extremely powerful and allows you to use objects of different types in the same program. However, type-based equality is not always equivalent to behavior; sometimes it rather defines which operation should be performed on a variable. For example, Java’s “==” operator does not have a general meaning but is only defined for objects of the same class implementing the “equals()” method. Hence Java’s “==” operator does not mean that two objects are the same, but tests if both contain the same data.
Dynamic languages try to provide a compromise between dynamic and static typing, allowing programmers to combine dynamic typing with static typing as they see fit. Python offers multiple types of variables: (1) a plain variable can hold any type; (2) typed variables can only hold values of their declared type; and (3) a restricted type variable can hold values of certain subtypes (e.g. a list of numbers) but not objects of other types (e.g. a list of strings).

python developers want typing
python developers want typing

There are several different types of strong typing, each with its own benefits and drawbacks

Suitability for your particular project depends on things like which platform you’re working on, how familiar the developers are, and what frameworks and libraries you’re using in your language. Some people prefer static typing to dynamic or weakly typed languages because their code is more resilient to change and can be reused more easily. Also, programming by contract (a form of static typing) allows one to define the contract that a value meets, which is helpful for unit testing. Some people rather dislike strongly typed languages, finding them too restrictive and opaque. They prefer dynamic typing because it can be more consistent with the way they think about their data, but they are less likely to change their existing code, especially when working with other developers. (Programming by contract goes both ways; once a type has been satisfactorily defined in one part of the program, it can be reused by other parts of the program. This is not the case with dynamic typing.)
But what is “strong typing” exactly? There are several different types of strong typing, each with its own benefits and drawbacks.
Typing Systems: Permissive vs Restricted [ARTICLE END]
The above is an accurate description of the differences between permissive, weak type systems and restricted, strong types systems. It’s not in any way an opinion based statement which misrepresents both permissive and restricted languages in a negative light.

python developers want typing
python developers want typing

Python has been considering adding type annotations to the language for a while now

Some people have pondered about the usefulness of adding type annotations to the Python language. Type annotations allow the user to specify which type a given object is. Some notable large projects with Python code that uses annotations are Django, Notepad++ and Wikipedia. But so far, nobody has proposed a comprehensive solution for Python based on type annotations. In general, adding an annotation to a program means that the annotation needs to be checked upon the program’s execution. This is why only small pieces of code can take advantage of it. Also, because annotations can be annotated themselves, large systems can start to quickly gain weight on introducing annotations and their use is not always simple.
In this Rich Hickey’s talk, he proposes a new system that adds compile-time checking of annotations, so no runtime overhead is added. The system introduces annotations on types and functions to declare the function’s return type and the types of parameters in a function and method (the rest of the arguments are inferred) .
An example of this annotation would work like the following:
def hello(name: str, age: int) -> str: return “Hello {} years old”.format(name)
The type system is integrated into the Python language outside of it. Functions are associated with a signature or a list of signatures. The annotations are checked at compile time and do not add runtime overhead. This saves on making the language more complex to annotate types. It also allows the use of annotations to be restricted to small pieces of code.

python developers want typing
python developers want typing
Previous Post

1. Space Engineers Autopilot Not Working: How to Fix It

Next Post

Time Complexity, Space Complexity, and Algorithms: How to Measure, Reduce, and Optimize

cecileparkmedia

cecileparkmedia

I am a technology expert specializing in sharing technology and software and guiding you with good and useful experiences and tips.

Next Post

Time Complexity, Space Complexity, and Algorithms: How to Measure, Reduce, and Optimize

The Importance of Matching the Latencies of the Older Modules to the Newer Modules

May 21, 2022

The Advantages of Running Applications Over UDP Rather Than TCP

May 21, 2022

The Disadvantages of Using a Pencil for Working Inside a Computer

May 21, 2022
Cecile Park Media

cecileparkmedia.com is a blog specializing in sharing technology and software and guiding you with good and useful experiences and tips.

Categories

  • Crack Software

Stay Connected

  • Home

© 2021 cecileparkmedia.com

No Result
View All Result
  • Home
  • Crack Software

© 2021 cecileparkmedia.com

Welcome Back!

Login to your account below

Forgotten Password?

Create New Account!

Fill the forms below to register

All fields are required. Log In

Retrieve your password

Please enter your username or email address to reset your password.

Log In