I’m coming from a Java background and trying to learn Scala. At the moment I’m feeling pretty overwhelmed, there seems to be so much more to learn with Scala, so many different ways of doing the same thing.
I was wondering if anyone has any advice on where to start, and how long it took them to feel reasonably competent in the language?
Even little things like for loop comprehensions seem really powerful but it’s just another piece of syntax you need to remember!
5
I’ve been where you are, and almost gave up a few times. While by no mean an expert Scala developer, I feel I now have a firm grasp on the language – certainly enough for it to have thoroughly poisoned my relationship with Java.
The first thing I did was spend a few weeks playing around, reading various blogs and introductions to the language. That was a mistake, I didn’t learn (or at least understand) much that was useful, and felt entirely out of my depths.
The second thing was to spend some time working out problem that were technically simple but forced me to explore specific aspects of the Scala syntax on my own:
- 99 Scala Problems
- Project Euler
While this did not turn me into an expert overnight, it gave me enough familiarity with the language that it didn’t feel quite that impossible anymore.
With that boost in confidence, I finally did what I should have started with: get Programming in Scala by Martin Odersky, and attempt to read an entire chapter every couple of days. It’s a well written and comprehensive book, and if you already have a sound programming background, should not prove too daunting. There’s no need to make your first read too painful: skip the parts marked as optional, make sure you understand the concepts but don’t get bogged down in the details (in particular, I feel that the chapters on collections are overkill and can be skimmed). Knowing that a concept exists and where to read a comprehensive explanation of how it works is a tremendous help.
An alternative to reading the book is attending the Coursera class – it’s much less comprehensive, but covers most of the crucial points and is broken down into manageable, logical units. On the other hand, I don’t know whether it’s possible to access the lessons once the class is complete, and I also found that I was much less engaged while listening to someone (even someone as obviously smart and knowledgeable as Martin Ordesky) than when reading a book.
Another issue with Scala is the amount of vocabulary you’ve got to ingest – by-name parameters? for-comprehension? closure? If you feel overwhelmed by this, I found that a good mixture of the Scala Glossary and targeted stack overflow searches helped me out a lot (seek out answers by Daniel Sobral and Travis Brown). In fact, I went so far as to create an Anki deck with the glossary, and feel it was a big help.
Finally, this is probably obvious, but code, code, code. Find a side project you can work on, even if it’s something trivial. What I did was write a very simple Amazon crawler that would send me a tweet whenever an author I was interested in released a new book. It took longer than it probably should have, but this is when I fell in love with the language.
If you get that far, you’ll probably need no further help, but a good suggestion, once you’ve come to grasp with the language, is to delve deeper in the underlying concepts. You’re familiar with OOP, try to read up on functional programming – I can say with absolute certainty that it will blow your mind. Functional Programming in Scala should be released soon(ish), but the early access edition is already excellent. Another answer suggests Functional Programming for Java Developers, which I’m not familiar with but am inclined to believe is good (when has an O’Reilly book not been worth at least skimming?).
I hope this didn’t get too long winded and obvious, and honestly wish you the best. Scala has its faults, but it’s a wonderful language and will take your brain in directions you never knew existed. And I’ll be looking for your “Learning Haskell, feeling discouraged” in a year 🙂
Scala is a very different way of thinking to Java, so don’t be discouraged! I’d probably start with Functional Programming for Java developers so that you can get into the functional way of thinking.
Is there a Java and/or Scala user group near by? It’s always easier to learn a new language with a colleague.
Best of luck and keep persevering at it!.
1