Others have said most of what I would have, but I’ll add one more point: TypeScript doesn’t (AFAICT) support operator overloading, and in ML you do want that. ML code is mostly written by scientists, based on papers they’ve read or written, and they want the code to resemble the math notation in the papers as closely as possible, to make it easy to check for correctness by eye. For example, here’s a line from a function to compute the split rhat statistic for tensors n and m, given other tensors B and W:
rhat = np.sqrt((n − 1) / n + (m + 1) / m * B / W)
In TypeScript, I guess you would have to rewrite this to something like
...which, like, clearly the scientists could do that rewrite, but they won’t unless you offer them something really compelling in exchange. TypeScript-tier type safety won’t do it; I doubt if even static tensor shape checking would be good enough.
Others have said most of what I would have, but I’ll add one more point: TypeScript doesn’t (AFAICT) support operator overloading, and in ML you do want that. ML code is mostly written by scientists, based on papers they’ve read or written, and they want the code to resemble the math notation in the papers as closely as possible, to make it easy to check for correctness by eye. For example, here’s a line from a function to compute the split rhat statistic for tensors n and m, given other tensors B and W:
In TypeScript, I guess you would have to rewrite this to something like
...which, like, clearly the scientists could do that rewrite, but they won’t unless you offer them something really compelling in exchange. TypeScript-tier type safety won’t do it; I doubt if even static tensor shape checking would be good enough.