r/javascript • • Dec 05 '15

Microsoft Edge's JavaScript engine to go open-source

https://blogs.windows.com/msedgedev/2015/12/05/open-source-chakra-core/
317 Upvotes

84 comments sorted by

View all comments

Show parent comments

34

u/bterlson_ @bterlson Dec 05 '15

I don't know how to answer this. When in doubt, use Math.random() I always say.

Edit: this isn't an ama, but do you guys want one? I can try to set one up with the team. No promises of course :)

11

u/splargbarg Dec 05 '15

You might end up with an AMA anyway.

5

u/bterlson_ @bterlson Dec 05 '15

Going that way ;) But I'm just one perspective on a diverse team of badass engineers!

8

u/kenman Dec 06 '15

Please let us know if you intend to hold one, we'll support you however we can (such as an announcement sticky a few days in advance, stickying the AMA itself, etc.).

3

u/PitaJ Dec 06 '15

Awesome!

7

u/cosinezero Dec 05 '15

Do it, yes! Expect some haters, but...

6

u/AMorpork Dec 05 '15

dae microsoft evil

7

u/ivosaurus Dec 05 '15

New question: what RNG does your implementation of Math.random() use?

8

u/bterlson_ @bterlson Dec 05 '15

It's decent quality, if that's what you're asking. I don't know that it has a name per se. One of our devs recently posted more info here.

3

u/ivosaurus Dec 05 '15

Decent, as in the same one that was in use before 2002?

If it's indeed the same as Java's, then it's just a LCG. That is decidedly not decent quality.

12

u/bterlson_ @bterlson Dec 05 '15

"Decent" of course depends on use case. Math.random is decidedly NOT decent if you are doing any sort of cryptography, for example.

1

u/ivosaurus Dec 06 '15

Nope. Just statistically decent, which LCGs fail pretty hard.

3

u/franksvalli Dec 05 '15

Ok!

(Math.random() > 0.5) ? 'Google-sized GNU' : 'A hundred GNU-sized Googles';

11

u/bterlson_ @bterlson Dec 05 '15

Using a freshly built copy of ch.exe:

chakracore> type random.js
print((Math.random() > 0.5) ? 'Google-sized GNU' : 'A hundred GNU-sized Googles');

chakracore> Build\VcBuild\bin\x64_test\ch.exe random.js
Google-sized GNU

This is frightening to me.

1

u/JohnMcPineapple Dec 06 '15 edited Oct 08 '24

...

1

u/asdf7890 Dec 07 '15

I would avoid Math.random() - some implementations are decent but some are not, so for cross-platform usefulness finding a better RNG library (and being careful how you seed it) is the way to go.