r/javascript • • Mar 30 '18

TensorFlow.js

https://js.tensorflow.org/
471 Upvotes

101 comments sorted by

View all comments

Show parent comments

2

u/raiderrobert Mar 30 '18

Python 3.6 has type annotations: https://docs.python.org/3/library/typing.html

But I admit that project organization has room for improvement.

1

u/nickguletskii200 Mar 30 '18 edited Mar 30 '18

I know about the type annotations. The problem is that pretty much nobody else uses them, and they don't seem to be very expressive.

2

u/Jugad Mar 30 '18

The problem is that pretty much nobody else uses them

I thought every typed language uses them... I know this might come across as snarky, but seriously, can you explain what's the basic difference between type annotations/information in Python and, say, Java?

they don't seem to be very expressive

Why are they not expressive?

1

u/nickguletskii200 Mar 31 '18

I thought every typed language uses them... I know this might come across as snarky, but seriously, can you explain what's the basic difference between type annotations/information in Python and, say, Java?

It's not that there is a difference. It's just that Python developers don't write code with typings in mind. In Java and C# everyone makes a best effort to describe the contract using interfaces. In Python, everyone just writes classes with the same methods, and you can't really say "I want something that is Closeable" because nobody specifies that their class is Closeable.

That's why I don't think type annotations are expressive - they can be, it's just that in practice, they are not. In the end, you'll be writing things like Union[Dog, Cat, Rabbit] instead of is Pettablebecause Python programmers would just say that all these things extend an Animal and be done with it.