r/javascript • • Mar 30 '18

TensorFlow.js

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

101 comments sorted by

View all comments

101

u/CiezkiBorsuk Mar 30 '18

we are actively working on creating node.js bindings to the TensorFlow C API

This makes me so happy, because when they are done I lose the last reason to ever use Python in my life ^-^

30

u/2Punx2Furious Mar 30 '18

You don't like Python?

4

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

No, I don't. Code without types is unreadable because it requires me to remember the flow of information. I would really love to use TensorFlow from Scala, Java, C# or TypeScript. Ideally, there would be a language for machine learning that does compile-time dimension checks (you can probably do something like that with templates in C++, but package management isn't a thing in the world of C++).

Just try reading some of the code in the research TensorFlow models. It sucks. Not because the concepts behind it are hard, but because a ton of information is hidden.

Also, Python's lack of a strict project structure is very annoying. I can take any modern JVM project and it will follow a strict hierarchy, with a proper, unified place for dependencies (Maven POM, Gradle build file or SBT build definition), while even big companies such as Google don't set up the Python projects consistently.

EDIT: Also, fuck the lack of punctuation. Goddamn Google and their 2-space tabs, so infuriating! I just want my auto-indent!

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.