4 ms·
This is huge! For me the one thing preventing Typescript to replace python is the lack of availability of CV ML libraries. WebGPU and this kind of libraries cha
by crubier 3y ago
This is huge! For me the one thing preventing Typescript to replace python is the lack of availability of CV ML libraries. WebGPU and this kind of libraries changes everything
- tzhenghao 3y agoThis. Just to riff off an example, a lot of the APIs in common DL frameworks like PyTorch revolve around numpy or pickle formats. These are Python first semantics.
- lyu07282 3y agoThere is so much stuff in scipy and opencv alone that it will take forever for another language to catch up to. Unfortunately, because python is suuuuuuuch a mediocre language in comparison. Type annotations were such a lost opportunity in python, it's such a horrible implementation.
- SuboptimalEng 3y agoAnd operator overloading. TS code tends to look like this `c.add(b.add(a))` or `add(add(a, b), c)` instead of `a + b + c` as you might write in Python. That was my biggest pain-point with using TS for graphics related projects. If operator overloading existed, then TS would be a no brainer for entry level graphics + AI/ML projects. Edit: This gets more complicated when doing operations that force you to manually respect PEMDAS. For example, `add(div(a, b), multiply(c, d))` in TypeScript would simplify to `a / b + c * d` in Python. The TS version is unreadable.
- killthebuddha 3y agoAnother option that's not quite as good as `a + b + c` but that is possible with TypeScript is a fluent API: const sum = a.add(b).add(c);
- leeoniya 3y agoor add(a,b,c)
- praeclarum 3y agoYes that syntax works right now.
- mlajtos 3y agoIndeed. "Object-oriented" fluent notation is basically equivalent to infix notation. https://mlajtos.mu/posts/new-kind-of-paper-2 https://mlajtos.mu/posts/new-kind-of-paper-2
- crubier 3y agoI actually think that tagged template strings in JS/TS could be a much better version of operator overloading! https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Template_literals#tagged_templates https://developer.mozilla.org/en-US/docs/Web/JavaScript/Refe... This would give access to any math notation in a more flexible way, implementing a custom DSL in a type safe but expressive way. Imagine writing stuff like const result = math`${a} + ${b} / ${c}`
- crubier 3y agoI got nerdsniped and made a small library to test this concept. Might maintain https://github.com/crubier/opov https://github.com/crubier/opov