Comment

Comment by munificent

Tangential but:

> My homegrown theory is that the idea of array.each { ... } as the main syntax for cycles was the first “aha!” of the new language development for its author

> The style that flourishes with this new shortcut is representing computation as a chain of small blocks, declaratively describing transformations from inputs to outputs. The style that is native to Ruby, the first mainstream language to have enumerable.transformation { ... } as the main cycle construct, and, I believe, played a role in normalizing “map”, “reduce”, and “filter” as a way of thinking about how things are handled.

Matz got that from Smalltalk. That's why most of the enumeration methods in Ruby match the names of similar methods in Smalltalk ("collect", "reject", "select", etc.) and not the corresponding names in functional languages ("map", "reduce", "filter"). The "each" method is the odd one out because that's called "do" in Smalltalk and "do" is a reserved word in Ruby.

Smalltalk definitely isn't mainstream today, but it did have its day in the sun where it was one of the better-known languages.

parent munificent 3 years ago

Discussion

Live from the official Hacker News API

A modern reader for Hacker News · SvelteKit + Skeleton