Home > News content

How did the father of Python "copy" design ideas from TypeScript

via:博客园     time:2019/5/5 17:38:11     readed:158


Author: Nick Heath Translator: Ignorance

At a recent PuPPy charity event in Seattle, Van Rossum talked about Python's early history and his views on Python's future.

Van Rossum said that the design of Python type annotations was inspired by TypeScript. He said:

At the end of the event, Van Rossum confirmed that what he had previously said about the TypeScript feature was optional type checking.

Type checking can help developers discover certain types of errors and avoid them sneaking into software systems. In statically typed languages, developers often specify variable types of function parameters when declaring a function, such as using int to specify an integer type or STR to specify a string type. When using dynamic typing languages, developers do not need to specify function parameter types. This design is designed to reduce the burden of developers.

However, Van Rossum says that dynamic typing is not good for code libraries of large projects. He said:

Although Python is still a dynamically typed language, in 2015 Python 3.0 added a type prompt function that allows developers to check whether the parameter types passed to the function are correct (available type checkers are: http://mypy-lang.org/).

These annotations are optional, allowing developers to combine dynamic and static types without affecting the speed of code execution. In addition to type hints (PEP 484), Python also introduces a series of other features (PEP 526, PEP 544, PEP 561, PEP 563), providing various hooks for type checking.

In a previous speech, Van Rossum said that Dropbox, the company's chief engineer, began introducing type annotations into the Python code base in 2015, and by 2018, 2 million out of 6 million lines of code had added type annotations.

Python's type hints are also used by many other companies, including Facebook, Quora and Lyft. Type checkers are also starting to use type prompts to validate Python types.

Van Rossum says that TypeScript provides similar type annotations that type checkers can use to validate types. Type annotation is one of the useful features of TypeScript that attracts developers to use it to develop large applications.

TypeScript author Anders Hejlsberg, who also participated in the PuPPy campaign, believes that typology is true

English text:


China IT News APP

Download China IT News APP

Please rate this news

The average score will be displayed after you score.

Post comment

Do not see clearly? Click for a new code.

User comments