<Measured> 0.4.1 has been released. This update ad...
# multiplatform
n
Measured 0.4.1 has been released. This update adds support for other KMP targets like iOS and all Apple platforms, Android Native, Linux, etc. Measured makes units of measure simple by providing intuitive, strongly-typed units that combine using normal mathematical operations.
Copy code
val velocity     = 5 * meters / seconds
val acceleration = 9 * meters / (seconds * seconds)
val time         = 1 * minutes

//  d            = vt + ½at²
val distance     = velocity * time + 1.0 / 2 * acceleration * time * time

println(distance                ) // 16500 m
println(distance `as` kilometers) // 16.5 km
println(distance `as` miles     ) // 10.25262467191601 mi

println(5 * miles / hours `as` meters / seconds) // 2.2352 m/s
Slack Conversation
🙌 1
a
Excellent start. I've been deep in the indriya / java uom libraries and for what its worth, I appreciate the effort this takes. I will definitely be checking it out and open to helping as needed.
👍 1
n
i’d love to explore code generation instead of hand-coding the various combinations of units. let me know if you have any experience/interest in this sort of thing when you start playing with it.
a
I absolutely have experience with code generation. KSP (Kotlin Symbol Processing) is great for this. I've typically been a fan of configuring generation externally rather than with annotations and such like kotlinx serialization does, but for a library like this that's not really an important distinction as its just saving time. Kotin Poet is a method a lot of people use for codegen, but for a library I'll often just generate the code using a templating language so it is formatted, documented, and ultimately included in the source rather than done at build time and left out of the code.