4 ms·
Thanks for providing the brilliant citations of Rob Pike! I like the most these ones: > Go is a project to make building production software easier and more pr
by valyala 2y ago
Thanks for providing the brilliant citations of Rob Pike! I like the most these ones:
> Go is a project to make building production software easier and more productive.
> Go code looks and works the same regardless of who's writing it, is largely free of factions using different subsets of the language
But I don't understand how these citations align with iterators in Go:
- Iterator functions are non-trivial to write and read because they return a function, which accepts a function, which accepts iterable items.
- The 'for ... range' loops with iterators are non-trivial to debug, since they __implicitly__ call iterator function and then __implicitly__ pass loop body converted to __implixit__ anonymous function, to the function returned by iterator function.
- Iterators do not replace existing functions - they add __new__ functions because of backwards compatibility. This complicates writing, reading and maintaining Go code, since there are multiple ways to do the same thing.
- Iterators encourage adding crappy iterator functions to the existing code, making it more complicated and harder to maintain.