r/javascript • u/SnooHobbies950 • 1d ago
AskJS [AskJS] I'm thinking of creating a JS dialect for scientists
What do you think of the ~> operator? It is be similar to |>, but it operates over lists.
let v = [1, 2, 3] // this is a vector
let w = v ~> it * 2 // equiv. to `v.map(it => it * 2)`
let w = v *> 2 // shorthand for `v ~> it * 2`
The dialect would be primarily aimed at statesmen and scientists.
5
u/Tittytickler 1d ago
Could be a cool project but not sure why someone would use this over Python, which everyone else in that space already uses.
3
u/skidmark_zuckerberg 1d ago
Why would you even need JS for this? There are better languages for scientific style work. I don't think scientists have a need for JS entirely. And that is not a vector, it's an array in JS.
2
2
2
u/Dazzling-Bench-4596 1d ago
You should look into PureScript. It’s not the same thing but it’s basically Haskell that compiles into JavaScript.
2
u/SaltineAmerican_1970 1d ago
> The dialect would be primarily aimed at statesmen and scientists.
Those are the people you should be asking
1
0
u/SnooHobbies950 1d ago
The idea was to create a list of operators that make it easier to operate with vectors and matrices. But I'm not sure if this makes much sense.
11
u/forloopy 1d ago
Overcomplicating something that doesn’t need it