[Python-Dev] Type hints -- a mediocre programmer's reaction (original) (raw)
Steven D'Aprano steve at pearwood.info
Tue Apr 21 15:16:19 CEST 2015
- Previous message (by thread): [Python-Dev] Type hints -- a mediocre programmer's reaction
- Next message (by thread): [Python-Dev] Type hints -- a mediocre programmer's reaction
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
On Tue, Apr 21, 2015 at 01:25:34PM +0100, Chris Withers wrote:
Anyway, I've not posted much to python-dev in quite a while, but this is a topic that I would be kicking myself in 5-10 years time when I've had to move to Javascript or because everyone else has drifted away from Python as it had become ugly...
Facebook released Flow, a static typechecker for Javascript, to a very positive reaction. From their announcement:
Flow’s type checking is opt-in — you do not need to type check all
your code at once. However, underlying the design of Flow is the
assumption that most JavaScript code is implicitly statically typed;
even though types may not appear anywhere in the code, they are in
the developer’s mind as a way to reason about the correctness of the
code. Flow infers those types automatically wherever possible, which
means that it can find type errors without needing any changes to
the code at all. On the other hand, some JavaScript code, especially
frameworks, make heavy use of reflection that is often hard to
reason about statically. For such inherently dynamic code, type
checking would be too imprecise, so Flow provides a simple way to
explicitly trust such code and move on. This design is validated by
our huge JavaScript codebase at Facebook: Most of our code falls in
the implicitly statically typed category, where developers can check
their code for type errors without having to explicitly annotate
that code with types.
Quoted here:
http://blog.jooq.org/2014/12/11/the-inconvenient-truth-about-dynamic-vs-static-typing/
More about flow:
Matz is interested in the same sort of gradual type checking for Ruby as Guido wants to add to Python:
Julia already includes this sort of hybrid dynamic+static type checking:
http://julia.readthedocs.org/en/latest/manual/types/
I could keep going, but I hope I've made my point. Whatever language you are using in 5-10 years time, it will almost certainly be either mostly static with some dynamic features like Java, or dynamic with optional and gradual typing.
-- Steven
- Previous message (by thread): [Python-Dev] Type hints -- a mediocre programmer's reaction
- Next message (by thread): [Python-Dev] Type hints -- a mediocre programmer's reaction
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]