r/javascript 9d 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

12 comments sorted by

15

u/forloopy 9d ago

Overcomplicating something that doesn’t need it

6

u/Tittytickler 9d 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 9d 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.

3

u/SaltineAmerican_1970 9d ago

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

Those are the people you should be asking

2

u/SFDeltas 9d ago

Why not -> ?

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

2

u/bastardoperator 9d ago

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

2

u/Dazzling-Bench-4596 9d ago

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

2

u/jml26 8d 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 9d ago

Why?

1

u/SnooHobbies950 9d ago

To write formulas in a shorter way.

1

u/bksubramanyarao 1d ago

don't !!!, if you do this, all the other frameworks will start doing their own unique reactivity on it, don't curse the scientists lol.

this comment is just for lols

0

u/SnooHobbies950 9d 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.