https://kotlinlang.org logo
#multiplatform
Title
# multiplatform
v

vmichalak

01/04/2018, 9:57 AM
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

louiscad

01/04/2018, 9:57 AM
@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

vmichalak

01/04/2018, 9:58 AM
I search on YT but i doesn't find. TOO MUCH ENTRIES when i search "random" 😛
l

louiscad

01/04/2018, 10:00 AM
@vmichalak I searched
random stdlib
and found it: https://youtrack.jetbrains.com/issue/KT-17261
v

vmichalak

01/04/2018, 10:01 AM
Thanks you ! I'm dumb 😛
l

louiscad

01/04/2018, 10:02 AM
Thanks @vmichalak for the gist!
@vmichalak Not so dumb given you made a pure Kotlin random impl 😜
😊 1
n

natpryce

01/04/2018, 11:15 AM
I ported the Java Mersenne Twister implementation to Kotlin and typealias it to Random on the JS platform.
v

vmichalak

01/04/2018, 12:41 PM
Mersenne Twister vs. Linear Congruential ... FIGHT ! 😂
l

louiscad

01/04/2018, 2:16 PM
Which one should win? Let's argue! Personally, I like Linear Congruential conciseness. Your moves @natpryce & @vmichalak
👍 1
n

natpryce

01/04/2018, 2:25 PM
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

vmichalak

01/04/2018, 4:39 PM
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

louiscad

01/04/2018, 9:03 PM
@kyonifer You should post this as a comment in this issue to help the Kotlin team: https://youtrack.jetbrains.com/issue/KT-17261
2 Views