Live data from Hacker News

Programming Languages Have Social Mores Not Idioms

learncodethehardway.org

111–120 of 179 posts

Re: Programming Languages Have Social Mores Not Idioms

#111

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…

He 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.

Re: Programming Languages Have Social Mores Not Idioms

#112
The more languages I dip into, and the more code I write, the more I realize people tend to just overdo things with no other purpose than to make things more complex. I love simple. My approach is to design the software in my head as if it was a system of independent components. This function does X, this function does Y, here I have a loop that uses function X to get the value that function Y needs to get value A. Never do I sit down and just write code that is "idiomatic". Don't care about it. When I started learning, all I did was write very simple code. Never did I use a class, or any OOP. My code was easy to follow, readable, and could be "translated" to run in any language. And that is one very important thing that I've learned. Design and code should be easy to translate from one language to another without much hassle. One should not rely too much on some language or framework in order do something.

My understanding of software engineering and computer science is that we should design with a clear mental pattern of what we need to build to get something done. This way, if there is some bug, we can trace it back in the design and not in the code. If we designed with the language in mind, then our software would be limited by the language itself. Then the bugs would just be harder to squash, because we now have to adapt our troubleshooting skills to the language and not the problem. In practice, anytime I face some bug, I just sit back and think about the design and not about the languge/syntax/idioms. It commonly takes me but a few minutes to mentally trace back the problem to the source. No debugger needed.

Zed, this is a fantastic piece, and I hope you include it as part of your books. Since you have shown to have such fine understanding of the problems begineers face, you should write a little booklet that should include things like the one mentioned here. Thank you for this post.

Re: Programming Languages Have Social Mores Not Idioms

#114

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…

He 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". Th…

I 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.

Re: Programming Languages Have Social Mores Not Idioms

#115
post #80

Earlier quoted context omitted.

To clarify, I don't think my original post implied that you were against teaching people how to learn each. Nor do I want to start out teaching beginning rubyists everything all at once. It was more to point out how important the mindset of each is. That's the mindset that you want to reach. And I'm not sure that teaching a construct that you'll never end up using is helpful. I think it just creates a mental construc…

> I'm not sure that teaching a construct that you'll never end up using is helpful. But that was precisely Zed's point! You will certainly end up using it, though you may never use it in Ruby . .each is not transferable, and for-loops are. Zed's teaching Ruby as an introduction to programming , not just to Ruby in itself.

.each as a concept of "iteration" is transferrable, no?

Also, I think there are some serious consequences when programming is taught in such a "diluted" way.

As a programmer who is constantly learning new concepts/languages, I am continually understanding the very real trade-offs when I write something in Ruby vs. C, not just in functionality, but in the design of the language itself.

By diluting, all languages start to blend in this ball where they become indistinguishable. Besides, if Zed is teaching an introduction to programming, it becomes completely arbitrary what language he chooses, and it therefore means he doesn't need to do variations of his lessons in other languages - unless of course he was going to meaningfully divulge into how these languages propose new ways of approaching a problem, etc. (but this would render this article's arguments moot, to a degree)

Re: Programming Languages Have Social Mores Not Idioms

#116
I'm curious. Zed Shaw writes that forcing beginners to learn these things without having them critically approach the alternatives is equivalent to indoctrination. IE. Python coders "must" write explicit code (although they have the means to write something more implicit/magical), Ruby "must" write .each (when they can do for, while, etc).

To me it seems like there are two consequences.

1) It's a huge burden on the beginner to be effectively aware of all the possibilities of doing things (like looping) in a language, and why one should be used where. In general, when a beginner picks up a language, he should be doing stuff and recognizing the trade-offs of what he's doing. Thus, he culminates critical awareness through choices and reflection of those choices.

I just can't imagine myself learning Python and hearing about doing things in a hundred different non-Pythonic ways. Unless I were to do it one way, and then later discover of my own accord that there is another way I can do it which has its associated cost/benefits.

2) If these "social mores" are indoctrination, and indoctrination is taboo, what if beginners stop writing .each loops? What if Python programmers start writing "magical" code? etc.

Wouldn't these Python programmers fragment the community and alienate/isolated themselves from a community which has firmly established conventions (for good reasons).

Either way, I love that this point has been raised. I've been looking into Ruby especially, and am always fascinated about how different the conventions and styles are.

Re: Programming Languages Have Social Mores Not Idioms

#117
post #52

Earlier quoted context omitted.

You are right, and once again I am not against using functional programming, OOP, message passing, or any of the things I mention about .each. I'm against using .each as a first looping construct. In fact, go look at your supposedly better last line of code and tell me if you think a newbie would even begin to comprehend that? Hell I'm a programming veteran and Ruby veteran and I want to metaphorically punch you in t…

I'm guessing Zed first learned to program using for loops so they look "natural" and easier for beginners to learn than functional callbacks. That seems like a testable proposition, but I'm guessing it isn't so. There aren't too many situations in life outside programming and racing where people go around in circles to get something done. Furthermore, the choice of print in the example begs the question. Are you teac…

Ruby gets `each` specifically and blocks in general from Smalltalk, so I'd be willing to bet there is research showing whether it is easy or hard to pick up. I'd further wager that the answer is that it is no harder. Loops are more "natural" for the machine, and therefore anybody who understands the machine; that doesn't mean they're more natural for the student.

Re: Programming Languages Have Social Mores Not Idioms

#119

Earlier quoted context omitted.

I'm guessing Zed first learned to program using for loops so they look "natural" and easier for beginners to learn than functional callbacks. That seems like a testable proposition, but I'm guessing it isn't so. There aren't too many situations in life outside programming and racing where people go around in circles to get something done. Furthermore, the choice of print in the example begs the question. Are you teac…

In a very real sense, imperative programming _is_ natural. Its much closer to how computers work. Whether this means that its an easier way to learn is up for debate. (For the record, I think it is easier for a majority of people, but that functional would be easier for a significant minority.) Your phrasing of that part just kind of bothered me. I think we already teach beginners that you calculate the sum of the sq…

Natural != how the machine works. Few of us have the faintest clue about how the laws of thermodynamics apply to the internal combustion engine or how solid state physics leads to semiconductors leads to electronics leads to electronic injection. Yet we all drive cars as naturally as we walk.

Re: Programming Languages Have Social Mores Not Idioms

#120

.each isn't a looping construct. It is mapping function. Looping constructs allow control over the loop iteration. Mapping functions do not. People probably shouldn't confuse them. Does Ruby actually have a looping function?

Going out on a limb here, but I think "for" is a looping function.

Does it's invocation syntax differ significantly from the invocation syntax of other functions? Is there another function with the same invocation syntax as for? What are for's arguments? What is it's results?

These are all relevant questions when determining if it is a function or not.

Just the simple fact that loop control is determined by a boolean and requires state implies that for isn't really a function.

For what it's worth, I think Zed has a point. If you're trying to introduce a broad array of concepts to a new a programmer, going with a mapping method associated with an iterable is kind of complicated if you want to explain the whole shebang.

Compare map from Haskell, Lisp, Python etc with each. In each of those languages, you only need to introduce:

1) Named values (as variables, or not) 2) Functions 3) Lists 4) The idea that a function can take a function as an argument

You do need all the additional stuff for each that he mentions.

Similarly, in languages that make higher order functions more difficult, and have implicit state, for is an easier thing to explain.

Post reply on HN