Programming Languages Have Social Mores Not Idioms
learncodethehardway.org
Programming Languages Have Social Mores Not Idioms
1–10 of 179 posts
Re: Programming Languages Have Social Mores Not Idioms
#2Re: Programming Languages Have Social Mores Not Idioms
#3Re: Programming Languages Have Social Mores Not Idioms
#4Re: Programming Languages Have Social Mores Not Idioms
#5I've never really understood the Ruby community's attitude toward for loops. I learned Ruby as my first language and read many blog posts and instructional books that told me to absolutely avoid the for loop. Of course when I started to learn JavaScript and C, I had to figure out their versions of the for loop then, and it made me start wondering why there had been such opposition to something that seemed to be a nor…
To my mind, anyway, using each/collect/inject expresses intent much more clearly than a for loop. If a clearer approach is available, why not take advantage of it?
Re: Programming Languages Have Social Mores Not Idioms
#6Re: Programming Languages Have Social Mores Not Idioms
#7Now "idiomatic" also has two senses. First, it can mean "having to do with idioms". Second, it can mean "peculiar to a particular group, individual or style". (See http://www.merriam-webster.com/dictionary/idiomatic)
So, I think when people speak of idioms regarding programming languages they're using the second of the above senses. While this sense might be characterized as having to do with social mores, I don't think it's a misuse of the word "idiom". People don't mean to say that .each statements are non-compositional in the way that "kick the bucket" is. Indeed, given that programming languages have formal grammars/semantics it's hard to imagine what non-compositionality would be at all (though I'm sure any good Perl programmer could probably give some examples!)
Re: Programming Languages Have Social Mores Not Idioms
#8Re: Programming Languages Have Social Mores Not Idioms
#9Did K&R explain everything about the preprocessor with their "Hello, world!" example? Or the implications of different return codes from main(), what 'return' from a function even means, etc?
Re: Programming Languages Have Social Mores Not Idioms
#10I've never really understood the Ruby community's attitude toward for loops. I learned Ruby as my first language and read many blog posts and instructional books that told me to absolutely avoid the for loop. Of course when I started to learn JavaScript and C, I had to figure out their versions of the for loop then, and it made me start wondering why there had been such opposition to something that seemed to be a nor…
I don't think using a for loop is "taboo" among Rubyists in general, just for iterating over each element of an array, where Array#each, Array#collect, and Array#inject are preferred. This probably comes from the influence of Lisp and its emphasis on writing code as a series of list operations. To my mind, anyway, using each/collect/inject expresses intent much more clearly than a for loop. If a clearer approach is a…
However, Ruby uses the methods you mention, "collect" and "inject", and these in turn have a few synonyms. And as best I can tell, Ruby's 'filter' variant, 'find' collides with ActiveRecord. What's the general community take on these functions? Which name is commonly used, and how do you do filter in Rails?