Why should we give a stuff?



Iterators are fairly ubiquitous


Iterators shape our view of the world


Iterators - iterators in general - are everywhere. I've done no analysis, but it's not unreasonable to suggest that in Java, they are one of the most widely used library classes, outside java.lang. We write the kind of for loops we've just looked at all the time. Because we use them all the time, they are a big part of how we use Java. They help form our notion of how Java works, and what a Java program is.

The same is true of Python. We use for-in and list comprehensions all the time. When we're working with a list, a list comprehension is the natural way to process the list. Python doesn't want you see its iterators, but there they just out view and they're shaping the way you program.

The Sapir-Whorf hypothesis argues that the nature of a language influences habitual thought by its speakers. Different patterns of language yield different patterns of thought. Sapir and Whorf were linguists, active in the early part of the 20th century, and they were taking about human speech and language. While their hypothesis is widely considered to be true (or rather not false), there's debate about how true it is, how strongly it applies. I think it also applies to programming languages, and I suspect you do too. I think it might actually apply more strongly, because programming languages have a restricted application and vocabulary.

We know different languages have different idioms. People say something is Perlish, or Pythonic. Remember Dave Thomas and his "more natural". Those of you who've worked with in a functional language after working with Java/C++/etc, how strange it initially felt, and then suddenly how everything could be solved with a quick bit of tail recursion. Baker is so caught up in his Lisp that he just can't see why anybody would do anything else. He brings out arguments so weak it's almost embarrassing.

I'm not taking a limited view of programming languages here, referring only to keywords and syntax, but to the language, it's standard and common libraries, the language ecosystem if you like.

We looked at Ruby earlier. Ruby likes to keep its iteration within itself. If your class implements each, you can get a whole load of stuff out of the library for free. This way of doing things is, Dave Thomas says, "more natural".

What about a tree?