

It’s helpful to think of these factors as weights on a scale - some factors will tend to tip the scales in favor of sequences, and some will tend to tip the scales in favor of collections. There are a few main factors that can affect performance. In fact, in many cases, collections can be more efficient than sequences! But there are certain characteristics that can totally blindside you if you’re not aware of them. Yes, sequences are known for their performance benefits over standard collection operations.


And if you’re looking to understand exactly how they’re implemented, you should take a look at the second article, Inside Kotlin Sequences.Īll caught up? Great - let’s go! Sequences vs. If you’re asking yourself what a sequence is, you should definitely read the first article in this series, Kotlin Sequences: An Illustrated Guide. Then, we’ll look at how Kotlin’s sequences stack up against Java streams, a similar concept. That’s the question we’re going to answer in this third and final article in this series! We’re going to look at the trade-offs of each, including the main things that affect their performance. “When should I use sequences, and when should I use normal collections?” One of the most common questions I get about Kotlin’s sequences is this:
