Comment

Comment by zmmmmm

> I'm surprised comprehensions in particular haven't spread to more modern languages.

I've come to dislike list comprehensions. Simple ones are ok but they do not handle incremental complexity well. Invariably it means code slowly becomes really unreadable as time goes by because nobody wants to rewrite the list comprehension when one more little tweak stuffed in there will do the job.

I much prefer object-functional chaining style ala Scala, Groovy, Ruby etc:

    some_giant_list
      .findAll { it.foo > 20 }
      .groupBy { it.bar }
      .countBy { it.value.size() > 5 }
They scale much better over time as new constructs get inserted as functional additions in the sequential pipeline.
parent zmmmmm 6 years ago

Discussion

Live from the official Hacker News API

A modern reader for Hacker News · SvelteKit + Skeleton