[Python-ideas] Optional Static Typing -- the Python Way

Andrew Barnert abarnert at yahoo.com
Sun Aug 24 21:00:01 CEST 2014


On Aug 24, 2014, at 4:59, Steven D'Aprano <steve at pearwood.info> wrote:

> On Thu, Aug 21, 2014 at 02:30:03PM +0000, Brett Cannon wrote:
> 
>> P.S.: Off-topic for this email but something I don't think has been
>> mentioned more than once, type hinting like we are proposing is exactly
>> what Dart does and it is nice. Built-in API documentation of interfaces
>> along with IDE support at the API makes all of this worth it.
> 
> For anyone not familiar with Dart, I think it is worth reading the Dart 
> justification for static type hinting in a dynamic language:
> 
> https://www.dartlang.org/articles/optional-types/
> 
> https://www.dartlang.org/articles/why-dart-types/
> 
> It's not quite the same as Guido's proposal, for example in Dart the 
> type hints have no runtime effect at all, but I think it demonstrates 
> that this is a proven approach and can work well with a dynamic language 
> like Python without compromising the dynamic nature of the language.

Great reference.

It's also worth looking at Boo (http://boo.codehaus.org), which was intentionally designed to read like Python, while also having static typing. So, it was designed in the opposite direction: given the CLR compile-time type system, modify Python syntax and semantics as little as possible to implement it. And it was also designed for completely different goals (mainly performance). But it does show how a type system pretty similar to the one Jukka and Guido are envisioning can fit into a language pretty similar to Python, which makes Boo code a useful example for "how readable could this be in real-life code?" questions.


More information about the Python-ideas mailing list