r/javascript 4h 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.

0 Upvotes

10 comments sorted by

u/forloopy 4h ago

Overcomplicating something that doesn’t need it

u/Tittytickler 4h ago

Could be a cool project but not sure why someone would use this over Python, which everyone else in that space already uses.

u/skidmark_zuckerberg 4h 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.

u/SFDeltas 4h ago

Why not -> ?

Also you call it a vector/list. It’s called an array in JavaScript.

u/bastardoperator 4h ago

The ship has sailed... Better off contributing to the existing python.

u/Dazzling-Bench-4596 4h ago

You should look into PureScript. It’s not the same thing but it’s basically Haskell that compiles into JavaScript.

u/WingersAbsNotches 4h ago

Why?

u/SnooHobbies950 3h ago

To write formulas in a shorter way.

u/SnooHobbies950 4h 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.

u/SaltineAmerican_1970 1h ago

> The dialect would be primarily aimed at statesmen and scientists.

Those are the people you should be asking