Take the 2-minute tour ×
Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. It's 100% free, no registration required.

I work with C# professionally and I write code like this all the time.

private IEnumerable<Something> GetAlotOfSomething()
{
    if (somethingA.IsReady)
        yield return somethingA; 
    if (somethingB.IsReady)
        yield return somethingB; 
    if (somethingC.IsReady)
        yield return somethingC; 

    // ... More complex logic
}

var specialSomethings = 
    GetAlotOfSomething()
    .Where(s => s.IsSpecial); 

Then one day I have to write a bit of VB6 or JScript and I end up writing so much boilerplate just to get things done. Anyone thoughts?

share|improve this question
    
No. I do not feel that way. –  Paul Nathan Sep 14 '10 at 21:09
    
@Paul - Says the guy with 200 C++ tags. :) –  ChaosPandion Sep 14 '10 at 21:12
    
I do say so. I have worked with upwards of 10-15 languages at this point. I do not feel that this is a must-have in a modern language. –  Paul Nathan Sep 14 '10 at 21:13
3  
I feel C# will soon discover macros... –  Pavel Shved Sep 14 '10 at 21:15
1  
@Pavel - I know what macros are but I can't see the reason you posted that comment. –  ChaosPandion Sep 14 '10 at 21:28
add comment

2 Answers

up vote 4 down vote accepted

Iterators (generators etc) are certainly great features that I use a lot. I don't qualify them as necessary, but I will certainly choose languages that have them when I get a choice.

share|improve this answer
    
OK so maybe I am being a bit dramatic, but still they are a definite productivity booster. –  ChaosPandion Sep 14 '10 at 21:13
add comment

They're... Handy.

But you can always just write your own if necessary. The big wins come from standard library / framework support.

share|improve this answer
1  
Underneath the hood they are trivial to implement but writing your own doesn't read gain you much with out the syntax sugar. –  ChaosPandion Sep 14 '10 at 22:24
1  
@Chaos: consider the use of iterators in C++'s STL: no direct syntax support (prior to 0x), but fantastically useful because so many generic algorithms supported them. You implement your own iterator according to the pattern, and suddenly find the rest of your work done for you... (well, to a point) –  Shog9 Dec 18 '10 at 3:52
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.