0

Following statement has been taken from Introduction to Computation and Programming Using Python by John Guttag

Python is a general-purpose programming language that can be used effectively to build almost any kind of program that does not need direct access to the computer’s hardware. Python is not optimal for programs that have high reliability constraints (because of its weak static semantic checking) or that are built and maintained by many people or over a long period of time (again because of the weak static semantic checking).

The sentence in bold seems very vague , can anyone provide good explanation or example . ?

  • 2
    FWIW, there are very, very, very few languages "optimal for programs that have high reliability constraints or that are built and maintained by many people or over a long period of time". – MisterMiyagi Aug 23 '21 at 14:17
  • 1
    How is this question opinion-based? It is true that the quotes from that author *are* just an opinion, but we can certainly answer this in an objective fashion (for example, by pointing out long-running, well-maintained python programs), or point to libraries or language changing addressing the (perceived) issue, or by suggesting other techniques (like relentless testing) to make the typing irrelevant. – AnoE Aug 23 '21 at 14:18
  • Exactly , I also can't understand why people think this can lead to opinion-based . – Venkatesh Chauhan Aug 23 '21 at 14:21
  • @AnoE "long-running, well-maintained python programs" would not be examples of whatever the author meant. It would at best be a counter example. – MisterMiyagi Aug 23 '21 at 14:21
  • 1
    Explaining some ill-defined opinion still depends on guessing what that opinion is. Basically one would have to know *what exact* crude understanding of reliability, maintainability and hardware the author had in mind – which ultimately means applying ones own opinion on what they meant. – MisterMiyagi Aug 23 '21 at 14:25

1 Answers1

2

Python uses dynamic typing. That is, you can only know the type of an object with certainty at runtime.

A consequence of this is that the only way to know a piece of code uses the right data types is to run it. Thus, testing becomes very important. But testing all the code paths in a program can take a long time.

The problem is exacerbated when many people work on a program for a long time since it's hard to get devs to write documentation and to build consistent interfaces, so you end up having a limited number of people who understand what types should be used and everyone spends a lot of time waiting for tests to run.

Still, the author's view is overly pessimistic. Many companies have large Python codebases and are able to do so by having extensive, and expensive, test suites and oncall rapid response teams.

For instance, Facebook has hundreds of millions of lines of code of which 21% are Python (as of 2016). With this level of preexisting investment, in the short term it is much cheaper to develop ways of making Python safer than to migrate code to a new language (like Julia or Rust).

And we can see this in the ecosystem.

Python has been modified to address the typing problem through the introduction of type annotations. While these are not enforced at runtime they provide a fast (realtime) check of type safety that significantly reduces the need to rely on tests and can be used to enforce interfaces using tools like Pyre and mypy. This makes having a large Python codebase of the sort the author discusses much more manageable.

Richard
  • 56,349
  • 34
  • 180
  • 251