Re: This is why Scala Syntax annoys me
Posted: May 1, 2009 3:35 PM
> > > But it's still a fairly technical term - how about
> > > "eachOr" or "checkEach" whatever???
> > >
> > The way I'd say it in English is that the method
> > the question, "Does a n element exist in this
> > for which this Boolean "predicate" function is true?"
> > whole thing got shorted to simply, exists.
> I think Morgan's right that this is a very mathematical
> name for this. The statement would be:
> "at least one element exists such that [predicate] is true
> for that element."
> A more intuitive name might be: atLeastOne(). This is an
> example (not the best) of what I think will hold Scala
> back. It designed with a very academic mindset. I know
> that the intention was to cater to business with Scala but
> I don't consider it successful in that aspect. There are
> a lot of really smart developers out there who have never
> taken a class in discrete mathematics or studied set
> theory. If I were going to champion Scala where I work, I
> would be required to explain a lot of these terms. And
> this is one of the simpler concepts in Scala. A lot of
> really educated developers don't know what a fold is. I'd
> never encountered the term before I started learning
> Scala. It might be hugely useful but how will people know
> without an explanation in plan terms?
Scala was designed in academia, but by a guy who has a very practical outlook and was aiming to solve real world problems. I don't agree with all his naming choices either. For example, I think it would be better to have called "foreach" simply "each", like in Ruby. Because foreach seems to violate the camel case convention, and is longer. But exists honestly I never thought of as mathematical until the "backwards E" was brought in this forum discussion. I just figured he grabbed one English word from the English sentence you'd use to describe what the method call does.
I also didn't know what a fold was before I encountered Scala, but that surely doesn't mean it should be left out. It just needs to be explained, taught, learned. And you don't need to use it until you learn it, but of course if someone else uses it and you're reading their code, you'll have to learn it at that point. But fold is very fundamental and useful and should be learned by all Scala programmers eventually.
By the way, on fold, once in Junior high school I remember in some choir we prepared a round to sing at a conference, and I had to sing something that included "fold in eggs." It was a song about making a cake or something. I had never heard of "folding in eggs," and asked about it. I was told it is a baking term in which you mix the egg in one stroke at a time until it is mixed, and when I found out what folds mean in Scala, it reminded me of what it means in baking. You start with a start value (the egg), and then one element at a time, fold it into the collection. At the end, you have a different batter/collection that you can do something else with.