Live data from Hacker News

Programming Languages Have Social Mores Not Idioms

learncodethehardway.org

11–20 of 179 posts

Re: Programming Languages Have Social Mores Not Idioms

#12
Oh, oops. I was overly skeptical nearly to the end because I thought he meant a numeric for loop instead of a for-each loop. I misunderstood the entire distinction, because while there is little reason to pick .each over for-each, there are very good reasons to use some kind of 'each' method.

Re: Programming Languages Have Social Mores Not Idioms

#13

I always interpret "idiomatic" as "avoiding performance issues". In Python, for example, using the join method on strings is not only idiomatic, it's performant. Even if a particular idiom has no effect on performance, the worst that happens is I write idiomatic code. Not only that, but idiomatic coding allows me to write performant code without having to understand why it performs well. I don't know Ruby, so I can't…

Not always though. I don't know if this is still the case, but "while true" used to be more idiomatic in Python than "while 1" even though the latter had better performance due to the state of the cpython implementation at the time.

Re: Programming Languages Have Social Mores Not Idioms

#14

Why does the author insist that to teach each to a beginner he has to teach all of those concepts? Sure, to understand it fully you need to know about those things, but you can definitely get a beginner far enough along without explaining every detail. Did 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 f…

> Why does the author insist that to teach each to a beginner he has to teach all of those concepts?

Because you aren't teaching, and it merely becomes rote memorization. After all, what does || really mean? What does it do there? Without explaining it, it's magic. And instead of learning, the student must disassociate || with what it really and merely associate it with each.

On top of this, you'll have those wondering what || is, and bothered that they are using something without understanding it's importance.

> Did K&R explain everything about the preprocessor with their "Hello, world!"

No, but they explained what that line (#include ) did. They didn't just gloss over it. They covered every line, and every element, including the different braces.

So, either you teach what || is, or you ignore it, and that will only make things more difficult later on.

Re: Programming Languages Have Social Mores Not Idioms

#15
I don't know where on earth he got "By definition an idiom is something you remove from good clean writing," which is obviously not true (edit: and itself contains an idiom, "good clean", which you can recognize as an idiom simply by reversing the two words), but I think he's right about the important thing, programming language mores. It's crazy odd how what appear as purely technical constructs become nuclei for all kinds of tribal and emotional behavior.

Here's my explanation: the human brain is an identity machine. Apply it intensely to anything over time and you can't help but identify with what you're doing and how. As soon as identity is involved the complete human package kicks in, including emotion and tribalism (banding together with those of like identity in opposition to those of unlike identity). Opposite ways of doing things begin to seem like threats, criticism evokes defensive feelings and so on. If you think you don't function this way, try paying closer attention.

Re: Programming Languages Have Social Mores Not Idioms

#16

Earlier quoted context omitted.

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…

I, too, think like that, although Ruby's nomenclature frequently confuses me. Coming from Scheme/Haskell I'm quite at home with 'map', 'filter', and 'fold'. 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 comm…

I'd say that most Rubyists use #select, whereas #find is a more literate alias that few use outside of AR.

Re: Programming Languages Have Social Mores Not Idioms

#18
this is a remarkable example of the difference between a coder and programmer - a coder is unable to grasp the insignificance and meaninglessness of a subtle difference between two very similar concepts, while programmer can instantly see that there is nothing to be seen.)

Re: Programming Languages Have Social Mores Not Idioms

#19
not following the standard idiom of a particular programming language causes people to balk because it shows how unfamiliar the author is and how little code the author has read or been exposed to in that language. Its a huge sign that even though the author may be smart there probably beginner level bugs in the code.
Post reply on HN