Neither is not a good comparison. Using the [... for ... in ... if ...]
syntax avoids creating temporaries for the unfiltered interim results, boolean indexing OTOH would require them. filter
operates on existing iterators, the comprehension syntax creates iterators and collects them; a pretty common use case.
The point is not to avoid any kind of parallel solution — that neither desirable nor practical — but to have a small number of orthogonal building blocks that combine well. For this particular purpose, control flow already works very well.
On a somewhat related note, I admire how clean Julia is from a control flow perspective. Basic (non-coroutine) control flow has combounding (begin
, ( ; )
), two kinds of loops (for
, while
), branching and short-circuiting boolean ops, and the standard exception handling constructs. And that’s it! We can build the rest easily from these components. (Technically for
is redundant once we have while
, but it meshes so well with iteration that it is worth it).