When I learned C++ and Java a long time ago, I loved Bruce Eckel’s books Thinking in C++ (two volumes) and Thinking in Java .
They had very clear and detailed explanations and I learned a lot from them. So I value his opinion. Bruce also often wrote very positively about Python, a language I like a lot.
A few days ago, he published a great article about Scala:
It is a very interesting article which shows that Scala is not complex – at least not more complex than Java. He writes “… Scala should be a lot easier than learning Java!”.
I agree. When you use the subset of Scala that let’s you do with Scala what you can do with Java, it is not more difficult at all, probably even easier than Java.
Here are a few reasons why I think Scala seems more difficult:
1) Programmers think they can master Scala within a few days or weeks
Programmers are used to Java and learning something new is always an effort. Not everyone is willing to really make the effort. To truly master Java, it takes years of practice. Some programmers think after programming in Java for 10 years or more, they should become as proficient in Scala as they are in Java within a few weeks. But that’s not how it works, no matter how easy a language is. You can write simple or even somewhat complex programs in Scala after a few days studying it, but to truly master it, it will take a lot of time and effort. But this can be very rewarding. I am still relatively new to Scala and don’t claim to be an expert or even understand everything about the language. But when I play with it, learn or read something about, I always have fun and learn something. But I know to give it time to become an expert. If you just started with Scala, give it time. When you are stuck, ask on the mailing lists or try a different website or book with explanations. Don’t give up. Even if you end up not liking Scala very much, you will definitely become a better programmer by learning it.
2) Programmers don’t know anything or not much about functional programming
Java is not a functional programming language. If a programmer has been using mostly Java and C++ for the last years, he may have created great software with Java in an object oriented way. This works great with Java and there is absolutely nothing wrong with that. I love Java and OOP is a great way for building software. But when people start playing with Scala they are also confronted with functional programming. You can do Scala in a pure OOP way but you will get more out of the language if you also master functional programming (FP). Because most programmers don’t have much experience with it, it seems very difficult and strange at first. But like I wrote above, you will have to give it some time to really understand it. It will be worth it and you will even think differently about your Java code when you’ve played more with high order functions, closures and recursion. FP is not always better or worse than OOP. It is another tool that is good to have in your toolbox. Sometimes FP is a better fit, sometimes OOP and sometimes a combination. This is why Scala supports both.
3) Many Scala websites are blogs can seem intimidating to beginners
When someone is really good at a language, he or she often want’s to show it. This is why Ruby sometimes looks very complicated when a Ruby guru writes a blog post with 50 lines of code and 10 different meta programming techniques within them.
The same is true for Scala. In many blog posts and websites, you find stuff about Monads, advanced FP, very concise but not necessarily very readable code and other things you won’t need in your daily business and other stuff that is way too confusing for a beginner.
This can be and sometimes is very intimidating for beginners who just want to read a file with Scala.
That doesn’t mean I don’t like those blogs, but I think the Scala community should publish more simple stuff.
4) Lack of a good cookbook for Scala
Many programmers learn by examples of how to do everyday tasks like opening files, sending an emails or building a socket server. For many languages there are great cookbooks with hundreds of recipes about how to do that. Such a book does not yet exist for Scala. I think it could really help to bring even more people to this wonderful language.
Conclusion: Scala is not difficult – just keep on learning
This are just a few reasons why I think Scala sometimes seems more difficult than it really is. If you don’t know Scala yet, I highly recommend reading Bruce Eckel’s article mentioned above.
If you already know some Scala but struggle a bit to grasp some of it’s concepts, keep on learning. As I wrote, you cannot become a Scala expert within 3 weeks. Keep pushing until you are comfortable with Scala and you will very likely really love it. And if you don’t you will nonetheless have learned a lot. (Btw, this holds true for all languages).