Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

This list really sort of stretches the imagination on what language level generator support looks like.

Certainly in Java you can use the `Iterator` interface to get generator like behavior. But that's both a whole lot more complex and more verbose. Primarily because you have to coordinate the `hasNext` method with the `next` method.

With python and yield syntax, that naturally falls out without a bunch of extra code juggling.



Sure, some of those (C, Java, C++ templates) are pretty weak, but C#, Ruby, ES6, and lots of the other language or library implementations are not. Its far from a unique Python feature.


Java methods like Stream#filter and Stream#flatMap are easier than rolling your own iterator; you can even ask that work be done in parallel.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: