there is nothing new under the sun

i’ve had the opportunity to do some c++ lately, and i’ve been reading up on stl iterators. i couldn’t help but notice similar use cases with input iterators and the generators found in python and now javascript, though the mechanisms are very different. two things stick out to me.

complexity

c++ iterators are so much more complex than generators. they introduce a hierarchy of categories that provides more control. they (at least basic c++ iterators) also conflate traversal and element access — something i understand that boost attempts to untangle.

is this complexity necessary? it probably allows for higher performance, and python and javascript don’t concern themselves with as much type information as c++. but is all of that worth the complexity it introduces?

i think it’s telling that python and javascript generators provide the lowest level of iterator functionality and leave the more complex stuff up to the application. i don’t see the necessity for the added complexity, but then again, i’m still pretty new to c++ ☺

it’s all been done before

either way i always find it interesting to learn about concepts that, while new to some languages, have existed for a while in others. there is still nothing new under the sun, but there are certainly opportunities to learn from prior experience.

blog comments powered by Disqus
© aaron stacy 2014, all rights reserved