Hi Kotlin Team, Do you plan to purpose a Number Ge...
# multiplatform
v
Hi Kotlin Team, Do you plan to purpose a Number Generator (Math.Random in js / java.util.Random in java) in the Kotlin Standard Lib ? In my multiplatform project we had to implement a Linear Congruential Generator directly in pure kotlin to do the job but even if it's relatively easy to implement it's not the best option we think.
l
@vmichalak Do you have your pure kotlin random generator implementation in a gist we can see? About it being in the stdlib, it's already somewhere in YouTrack if I'm not mistaken, you should vote on it
v
I search on YT but i doesn't find. TOO MUCH ENTRIES when i search "random" 😛
l
@vmichalak I searched
random stdlib
and found it: https://youtrack.jetbrains.com/issue/KT-17261
v
Thanks you ! I'm dumb 😛
l
Thanks @vmichalak for the gist!
@vmichalak Not so dumb given you made a pure Kotlin random impl 😜
😊 1
n
I ported the Java Mersenne Twister implementation to Kotlin and typealias it to Random on the JS platform.
v
Mersenne Twister vs. Linear Congruential ... FIGHT ! 😂
l
Which one should win? Let's argue! Personally, I like Linear Congruential conciseness. Your moves @natpryce & @vmichalak
👍 1
n
TBH… I have no idea about the algorithms. I picked Mersenne Twister only because I could paste the code into IntelliJ and it automagically turned it into Kotlin
🎩 1
🎉 4
v
Linear Congruential is the default algorithm for Java, C, Visual Basic, Delphi, etc... Because is really easy to understand and is one of the faster rng algorithm !
l
@kyonifer You should post this as a comment in this issue to help the Kotlin team: https://youtrack.jetbrains.com/issue/KT-17261