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

0 Upvotes

11 comments sorted by

11

u/forloopy 1d ago

Overcomplicating something that doesn’t need it

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

u/SFDeltas 1d ago

Why not -> ?

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

2

u/bastardoperator 1d ago

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

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

u/jml26 14h ago

If (and it's a big if) I was trying to come up with something like this, I'd propose:

let v = [1, 2, 3]; let w = v * 2; // [2, 4, 6]

1

u/WingersAbsNotches 1d ago

Why?

1

u/SnooHobbies950 1d ago

To write formulas in a shorter way.

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.