Here is one of my biggest gripes with Scala.
It has a very irregular syntax.
Here are two examples straight from Odersky's book.
for (p <- persons; n = p.name; if (n startsWith "To")
yield n
for {
p <- persons
// a generator
n = p.name // a definition
if (n startsWith "To") // a filter
} yield n
These are equivalent for expressions. In my opinion there is a huge problem with this.
Sometimes I can do for() sometimes for{} and they are the same.
I think this reflects poor design. Someone thought they were clever and got the grammar to do the same thing so they left it.
But syntax, including punctuation, is very important in how quickly someone can read text and comprehend it.
Now, if someone is reading Scala code, they have to be very careful about how they mentally parse and interpret a block of code.
These are valuable mental cycles that must to be spent on the syntax of the language, instead of the semantics of the code.
When looking at Java or C for example, a developer doesn't have this issue.
A for loop always uses parens, period end of story. There is no time spent thinking about paren vs brace. Or semi colon vs missing semi colon.
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment