Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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!

share|improve this question

closed as too broad by Bart van Ingen Schenau, gnat, MichaelT, Kilian Foth, GlenH7 Feb 6 '14 at 16:49

There are either too many possible answers, or good answers would be too long for this format. Please add details to narrow the answer set or to isolate an issue that can be answered in a few paragraphs.If this question can be reworded to fit the rules in the help center, please edit the question.

Scala is by most accounts a complex language so don't feel discouraged! Anecdotally I'm a quite competent Haskell programmer and I thought Scala was way more complex :) The best way I've found to learn anything, is to alternate between a book and a project. For Scala I'd suggest a compiler and the staircase books but to each their own – jozefg Feb 2 '14 at 5:43
Thanks for the encouragement! What's the staircase book? – jcm Feb 2 '14 at 6:19
recommended reading: Where to start? – gnat Feb 2 '14 at 11:31
I tried Scala a few years ago from a Java perspective and didn't really get it. Recently, I started a course at on functional programming in Scala. It is a drastically different enough approach that my Java background didn't get in the way. Instead I am (re)learning to think in immutable data structures, reasoning about algorithms, set theory, type theory and all the other fun stuff I don't get to practice in a real job. Don't worry; there is still real usefulness of Scala in the real world. – BobDalgleish Feb 2 '14 at 13:16
Scala is a big new ecosystem to pick up (the core language itself isn't that big - it's mostly the libraries and concepts). If you stick the the shallower end of things for awhile, and pick up one concept at a time, things will really start to come together. Stuff that looks like bizarre cooked-in special-syntax will usually turn out to fall into some more generic category of thing that can be abstracted across the whole language. But it definitely takes some playing and reading to figure out what those things are. – KChaloux Feb 3 '14 at 20:06

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:

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 :)

share|improve this answer

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!.

share|improve this answer
In addition I would recommend taking a look at Scala Frameworks or Toolkits concerning areas of your interest. In my experience having a project you like working on makes things easier. Check out Lift or Play Framework for example when you're into Web-Development or Akka if Concurrent or Distributed applications are your thing. – juwi Feb 2 '14 at 13:31

Not the answer you're looking for? Browse other questions tagged or ask your own question.