Replies: 1 comment
-
Hey @404-, Thank you for your interest, and this is actually a great question! It's not explicitly mentioned anywhere in the documentation, but perhaps it should! So Kotlin(X) Coroutines requires However there is no performance impact, since stacktrace creation is disabled. So the performance impact you're referring to comes from stacktrace creation, which occurs on construction of any subclass of KotlinX Coroutines disables stacktrace creation for For reference, Arrow, KotlinX Coroutines. We replaced the |
Beta Was this translation helpful? Give feedback.
-
While the new Raise DSL seems neat, I'm wondering what possible performance impact it might actually have. Given that the return type of
raise
isNothing
, I can only assume that under the hood the main mechanism relies on exceptions for flow control (please, correct me if I'm wrong). Unless something has changed, one of the JVM Commandments has always been: Thou shall not use Exceptions for simple flow control. Which brings me to my original concern: does the usage ofraise
come at the price of a measurable performance overhead?To drive the point home, consider two possible implementations of a simple function responsible for making sure a number is positive:
For the sake of the argument, imagine this function is a part of some application's critical path (e.g. a tight, performance-critical loop). Would the second implementation be expected to have a significantly negative impact on performance?
Beta Was this translation helpful? Give feedback.
All reactions