Live data from Hacker News

C's 'while' is spelled 'for' in Go

tour.golang.org

31–34 of 34 posts

Re: C's 'while' is spelled 'for' in Go

#31
post #24
post #4

It's kind of sad that "for" is the keyword programming languages settled on for the loop construct. Ever since its counterpart "do" was dropped from the for-statement, it's just been utterly nonsensical. I mean how on earth does the word "for" convey a loop? With the recently designed languages like Go and Swift taking so many cues from the Pascal side of the ALGOL language family, how nobody thought to pick up "repe…

While we're being pedantic, "do" is a terrible keyword. I mean, everything in an imperitive program is a request to "do" something. And "do ... while(x)" is a terrible construct because it hides the loop complexity far from the place where a programmer needs to see it.

> "do" is a terrible keyword.

Not at all. "do" helps a lot to make the code read like English and thus more understandable.

Re: C's 'while' is spelled 'for' in Go

#32
post #27

Earlier quoted context omitted.

Wish they'd called it `grob` and called `return` `bolver` so that we can accept they're just syntactic constructs instead of pointlessly assuming meaning from what are just syntactic constructs. sum = 0 grob (i=0; i Brilliant.

I feel like this is what learning to program is like when english isn't your first language

I learned programming before I learned English. I was always confused by PRINT vs INPUT: which one reads and which one writes? So yeah, it could have been grob and bolver or anything.

Re: C's 'while' is spelled 'for' in Go

#33
post #23

Earlier quoted context omitted.

Python's "for customer in customers" can't be clearer in my opinion.

"for each customer in customers" is how you'd say that in plain english. Some languages do use foreach as a keyword echoing that.

In math you have the "for all customers there exists a customer that". Maybe I should write up a formal INTERCAL proposal that this should be the proper loop construct in 2020, spelled out in plain Math English like that.

Re: C's 'while' is spelled 'for' in Go

#34
post #32
post #27

Earlier quoted context omitted.

I feel like this is what learning to program is like when english isn't your first language

I learned programming before I learned English. I was always confused by PRINT vs INPUT: which one reads and which one writes? So yeah, it could have been grob and bolver or anything.

Ironically, I was undone here by bad pedagogy. The text I was reading said something about "`getch` being the opposite of what you expected since you'd think it gets the character from the computer and prints it to the screen, while `putchar` does the opposite of what you expected and doesn't give you the chance to put anything into the computer".

Now, clearly whoever wrote that text had their own conception of the thing, but my mental model was that the computer is executing the program so it is getting the character from me with `getch` and it is putting the character on the screen with `putchar`. So the actual functionality seemed right.

But when you combined that with the text saying that it was counter-intuitive I was like "Oh okay, got to remember it was counter-intuitive. It's the opposite of what I'd think" and so the text induced me to misunderstand. Fortunately I was a child so I learned pretty rapidly that lots of people write total crap (irrespective of the conception, the author should not have pushed it so hard) and it didn't damage my mental model at all.

Post reply on HN