3 ms·
For loops and their map/filter/reduce functional equivalents to me are just that: equivalent constructs, two styles/paradigms of doing the same thing. Can you e
by ereyes01 7y ago
For loops and their map/filter/reduce functional equivalents to me are just that: equivalent constructs, two styles/paradigms of doing the same thing. Can you elaborate on why one is poorer and the other much more productive in absolute terms?
- tqkxzugoaupvwqr 7y agoNot OP. I work with TypeScript and Go, and switching back and forth, I find it much easier to express my thoughts in TypeScript and just write them out without getting bogged down in the tiniest details every single time I want to map, filter or reduce something. Go is verbose in that way which makes me lose my train of thought because of a lot more typing, and it makes it harder for me get the gist of code because I have to actually read and not gloss over the Go loops to make sure they do what I think they do. TypeScript/JavaScript: const itemIDs = items.map((item) => item.ID) Go: itemIDs := make([]uint64, 0, len(items)) for _, item := range items { itemIDs = append(itemIDs, item.ID) }