[Python-Dev] Type hints -- a mediocre programmer's reaction
Steven D'Aprano
steve at pearwood.info
Tue Apr 21 15:16:19 CEST 2015
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 <insert new language here> 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:
http://flowtype.org/
Matz is interested in the same sort of gradual type checking for Ruby as
Guido wants to add to Python:
https://www.omniref.com/blog/blog/2014/11/17/matz-at-rubyconf-2014-will-ruby-3-dot-0-be-statically-typed/
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
More information about the Python-Dev
mailing list