4 ms·
I'm sorry, but this post is absolutely ridiculous in every way. I think most programmers understand what is meant when people say a programming "idiom", just l
by crazygringo 14y ago
I'm sorry, but this post is absolutely ridiculous in every way.
I think most programmers understand what is meant when people say a programming "idiom", just like most people understand that it's OK to call small representative computer graphics "icons" even though they're not physical religious symbols.
Words gain new meanings in new contexts, that's how language evolves. Complaining about it after-the-fact is just stupid. Nobody's going to start calling these "social mores" because of this article.
And as to why ".each" is a horrible looping construct, the only justification is that it's harder to teach. Well, sure, if you're teaching someone programming for the first time it's probably better to start with "for". That doesn't mean ".each" isn't superior for experienced programmers, though. The author doesn't address any of the advantages to ".each".
- pbiggar 14y agoYour comment is hyperbole in every way. The post made 2 points: - we should be calling "idioms" "social mores" - we should teach beginners simpler constructs instead of idiomatic ones, especially `for` instead of `.each` in ruby. Note that you agreed with his second point. He has no responsibility to address the upsides of `.each`, since that's not the point of his article. He wasn't talking about advanced programmers, he was specifically addressing why he didn't teach `.each` in his book, and why it shouldn't be taught to other beginner programmers.
- ioquatix 14y agoHow is .each any simpler than a for loop, conceptually they do the same thing.
- pbiggar 14y agoRead the article.
- ioquatix 14y agoYeah, I did...
- pbiggar 14y agoNot well. It's described for the entire final quarter of the article, in the section marked "Why .each Is A Horrible First Looping Construct".
- evincarofautumn 14y ago“for” is the raw loopy stuff out of which other looping constructs are made—it’s fairly arbitrary. If you’re implementing an iteration construct, then by all means “for” is the thing to use. But in normal use it’s best to express your intent through more common, composable constructs such as maps, folds, and zips. There’s certainly less overhead in reading a non-trivial loop written as a composition than one written as a raw “for”. So I don’t think “each” is any better than “for”—in addition to having uglier syntax in Ruby, neither conveys any more information than the other. It’s the same with std::for_each in C++, present only for consistency with its more meaningful siblings.
- pbiggar 14y agoI have no dog in this fight, I was just calling out the hyperbole on the ancestor comment.
- ioquatix 14y agoIf you didn't get my intent, the last part of the article which you recommended was highly biased and after reading it I was left questioning the author's motive.
- pbiggar 14y agoI don't see the bias or any reason to question his motive, so no, your intent was not clear. I think you'll need to spell this one out for me.
- thedufer 14y agoHe never argued that .each is a horrible looping construct. He calls it a horrible _first_ looping construct, that is to say that its bad for teaching to beginners. Your last paragraph says nothing that contradicts the article in any way. In fact, you beautifully summarized that portion of the article: > Well, sure, if you're teaching someone programming for the first time it's probably better to start with "for". That said, I was inclined to agree that idiom has simply picked up a new meaning. That's usually where I fall in debates about changing language. However, your straw man argument almost made me change my mind out of spite.
- tsurantino 14y agoI just spent the last two weeks learning the Ruby language (but I come from other programming languages). I'd argue that learning .each vs. normal looping has numerous benefits. First, this is the way most people loop most things in Ruby. More importantly, however, teaching .each enabled me to be more openminded towards learning "yield" and blocks. In a way, without having learned about .each first, and coming into Ruby with my preconceptions (or no conceptions), I would have been confused. I would have been writing Ruby as if I were writing Python or C, without really understanding the benefits of writing Ruby as Ruby ought to be written.
- webreac 14y agoLearning a new language requires that you adapt your way of thinking. Idioms are a way to familiarize with the spirit of a language. Starting to teach languages avoiding what makes the language so special is counter productive. As soon as your students know a basic way to program, they won't be inclined to learn the "good way".
- thedufer 14y agoI'm not sure how else to say this, but taking things out of context still does not make them wrong. This is about teaching the concept of programming. If you're learning a particular language, yes, use the idioms. If you're teaching someone how to code, teach concepts that cross languages.
- batgaijin 14y agoWe call people that interact with our software 'users' despite the drug connotation. Hardware stores don't say that, heck even pharma companies don't.