Why core of Tensorflow js is written in Typescript

1,137 views
Skip to first unread message

Eugene Krevenets

unread,
Apr 1, 2018, 3:04:48 PM4/1/18
to TensorFlow.js Discussion
I know that TypeScript is quite a popular language for Google opensource projects. And there is a popular thought that projects in Typescript are easy to support.
But is there was motivation to use TypeScript in this particular project (https://github.com/tensorflow/tfjs-core). Maybe it gives performance or architecture benefits or so?

Omar Sanseviero

unread,
Apr 1, 2018, 4:16:53 PM4/1/18
to TensorFlow.js Discussion
I interned in Google last year in Google Cloud, and I want to share my opinion about TypeScript. I think it's a great language when you're working on big projects. Working with multiple libraries becomes much easier - programming and debugging is way faster thanks to the language. You're able to catch bugs before compiling your project. I had my doubts at the beginning, but I found TypeScript to be a great time saver. It does solve many problems that there are in JavaScript. I don't know if there are any performance or architecture benefits specifically for tfjs.

Shanqing Cai

unread,
Apr 2, 2018, 10:09:29 AM4/2/18
to TensorFlow.js Discussion
Different people have different opinions on strong/static typing, but as one of the developers of TensorFlow.js, I agree with Omar's observation that strong and static typing leads to faster and safer development, because it gives you more effective autocompletion, refactoring, linting, bug catching, etc. This leads to overall higher confidence in our code, even without running unit tests.

But I'd like also to add that strong typing has its own unique advantages in the context of machine learning: It provides the possibility to statically analyze the code and pull out the computation graph from the code. Look at the Swift for TensorFlow announcement made at the same dev summit as TensorFlow.js.

Daniel Smilkov

unread,
Apr 2, 2018, 10:16:28 AM4/2/18
to Shanqing Cai, tf...@tensorflow.org
Also, it is worth noting that while TensorFlow.js is implemented in TypeScript, we compile it down to JavaScript when publishing on npm, and all our examples and API docs are written in ES6 Javascript.

Daniel


--
You received this message because you are subscribed to the Google Groups "TensorFlow.js Discussion" group.
To unsubscribe from this group and stop receiving emails from it, send an email to tfjs+uns...@tensorflow.org.
Visit this group at https://groups.google.com/a/tensorflow.org/group/tfjs/.

Zahid Islam

unread,
Jul 8, 2018, 4:07:05 PM7/8/18
to TensorFlow.js Discussion, ca...@google.com
Is there a specific reason why Typescript was chosen over Dart or was it just the team's stylistic preference?
Reply all
Reply to author
Forward
0 new messages