3 ms·
I was hoping for APL/J-style stuff or something like using `map` and `forEach` but no. That's a big letdown.
by bctnry 7y ago
I was hoping for APL/J-style stuff or something like using `map` and `forEach` but no. That's a big letdown.
- necovek 7y agoI would consider those "some kind of loop".
- squiggleblaz 7y agoI was hoping for a massive parallel solution! You just run the same function on a million cores at once, with different inputs. But I think there's a big difference between a language that lets you expect that iteration b will happen after iteration a, vs a language that merely gives you guarantee the result is derived from application of the function onto the necessary inputs. The latter can be correctly parallelised, but the former can only ever be executed in serial. `map f [1,2,3]` (in Haskell) can be solved in parallel or in serial. `[1,2,3].map(f)` (in modern JS) must be executed in serial, since f might be the result of `() => { var j = 0; return (i) => { j += i; return j }}`.
- myhf 7y agoFor some clarification of the "loopless" terminology in J: https://code.jsoftware.com/wiki/Vocabulary/Loopless https://code.jsoftware.com/wiki/Vocabulary/Loopless
- akavi 7y ago`map` is strictly less "powerful" than a "loop", so I'd argue that's misleading. Which I'd also argue is a good thing. Using the least powerful construct available both communicates to future readers of the code, and allows higher level optimization (eg, `map` is trivially parallelizable, an arbitrary loop is not)
- thaumasiotes 7y agoBut `map` is not a primitive. It's just a function implemented with... a loop. It's hard to argue that that doesn't make it "some kind of loop".