- My post is not intended to be a replacement of the original piece ("Learning Scala? Learn the Fundamentals First"), but rather a criticism of the unnecessary complexity used in his example.
- My example is not supposed to be equivalent from a teaching perspective. It is merely a supposition that if you want to add 1 to a field in a container there are easier ways to do so. And by easier, I mean easier to read. As a reader you are left with the impression that this is how it's done in Scala, and it's not.
- I do not advocate not learning the fundamentals first. I do, however, think that trying to cram 5 fundamentals into one line of code is not conductive to learning those 5 fundamentals. Maybe it works person to person, but it does not work in a blog post.
- My example is not supposed to be cleaner than the original line of code, more on that later.
To reiterate my position from the first post: I firmly believe that if you create an unnatural amalgam of many new concepts in the form of a short code snippet, you will confuse and maybe scare would be converts away. I.e., it is detrimental to getting more people using Scala. This is especially true if you claim that the snippet "is a really simple example".
As to the allegation that my code isn't as clean as the original, I can only agree. At least if immutable is cleaner than mutable.
class Cake(var name:String, var egg:Int)Fixed. But now I would have to explain yield too. That would be my second example, building on the knowledge gained from the first example.
...
for (cake <- cakes) yield { new Cake(cake.name, cake.egg + 1) }
No comments:
Post a Comment