Nirbhay Pherwani
2 min readNov 3, 2023

--

Thank you for your kind words and for engaging with the article! I'm happy to answer your questions:

1. Kotlin, like any other widely used language, is continually evolving. The features covered in the article represent some of the advanced functional programming aspects that can significantly improve your code. There is always more to explore with Kotlin! While I've focused on functional programming in this piece, Kotlin has a broad ecosystem with many other features worth discussing. I'll surely follow up with more articles to delve into other powerful aspects of the language. Stay tuned!

2. Converting a list to a sequence with asSequence() does introduce a minimal overhead as it creates a new sequence wrapper around the original list. However, for most practical purposes, this overhead is negligible and can be outweighed by the benefits that sequences bring to the table, especially when dealing with large datasets. Sequences offer lazy evaluation, which means that for a list of 1 million items, operations are only computed when needed leading to performance improvements.

Basically, sequences won't do a thing until you ask them to, which means you could save a lot on operations that don't need to go through the whole list. But you know how it is with performance – it loves to play hide and seek. So, giving it a test run to see how it plays out in your specific scenario is always the best bet.

To sum it up, It's a thoughtful concern! When working with a huge number of items like a million, any additional step can contribute to overall processing time. However, the conversion from a List to a Sequence with asSequence() is quite efficient and generally won’t be the bottleneck.

The performance gains you get from lazy evaluation with sequences, especially if you're performing chained operations, often far outweigh the minimal cost of this conversion.

Hope that clears things up! Thanks for engaging with the article – makes all the writing worth it!

--

--