zlacker

[parent] [thread] 9 comments
1. crubie+(OP)[view] [source] 2023-05-19 22:26:08
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
replies(2): >>tzheng+K9 >>Subopt+ln
2. tzheng+K9[view] [source] 2023-05-19 23:49:30
>>crubie+(OP)
This. 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.
replies(1): >>lyu072+Lb
◧◩
3. lyu072+Lb[view] [source] [discussion] 2023-05-20 00:13:07
>>tzheng+K9
There 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.
4. Subopt+ln[view] [source] 2023-05-20 02:41:45
>>crubie+(OP)
And 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.

replies(2): >>killth+3p >>crubie+Yv
◧◩
5. killth+3p[view] [source] [discussion] 2023-05-20 03:11:15
>>Subopt+ln
Another 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);
replies(3): >>leeoni+Sp >>praecl+bv >>mlajto+FR
◧◩◪
6. leeoni+Sp[view] [source] [discussion] 2023-05-20 03:21:43
>>killth+3p
or add(a,b,c)
◧◩◪
7. praecl+bv[view] [source] [discussion] 2023-05-20 04:34:51
>>killth+3p
Yes that syntax works right now.
◧◩
8. crubie+Yv[view] [source] [discussion] 2023-05-20 04:48:52
>>Subopt+ln
I 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/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}`

replies(1): >>crubie+9J
◧◩◪
9. crubie+9J[view] [source] [discussion] 2023-05-20 08:27:33
>>crubie+Yv
I got nerdsniped and made a small library to test this concept. Might maintain

https://github.com/crubier/opov

◧◩◪
10. mlajto+FR[view] [source] [discussion] 2023-05-20 10:53:31
>>killth+3p
Indeed. "Object-oriented" fluent notation is basically equivalent to infix notation.

https://mlajtos.mu/posts/new-kind-of-paper-2

[go to top]