Graham’s Guide to Learning Scala

Share Button

From The Archives: This article is one of the all-time most popular posts from my previous blog Graham Hacking Scala. I thought it worth updating and re-printing it here.


It’s a pretty widely-accepted view that, as a programmer, learning new languages is a Good Idea™ . Most people with more than one language under their belt would say that learning new languages broadens your mind in ways that will positively affect the way you work, even if you never use that language again.

With the Christmas holidays coming up and many people likely to take some time off work, this end of the year presents a great opportunity to take some time out from your week-to-week programming grind and do some learning.

With that in mind, I present “Graham’s Guide to Learning Scala”. There are many, many resources on the web for learning about Scala. In fact, I think there’s probably too many! It would be quite easy to start in the wrong place and quickly get discouraged.

So this is not yet another resource to add to the pile. Rather, this is a guided course through what I believe are some of the best resources for learning Scala, and in an order that I think will help a complete newbie pick it up quickly but without feeling overwhelmed.

And, best of all, it has 9 Steps!

[Note: Many of the resources have a slant towards teaching programmers that know Java, but I imagine if you know any other popular OO language like C++, C#, Ruby, Python, Objective-C or Smalltalk, you shouldn’t have a problem picking it up.]

Are you ready? Here goes…

Step 1: Lay the Foundation

Read ‘Introduction to the Scala Language’ on scala-lang.org

This single page is a succinct but dense description of Scala and will let you know what you’re in for, and why you should keep going.

Step 2: Get the Tools

Download and install the latest Scala release

Download and install the latest IntelliJ IDEA *Community Edition* release

Open IDEA and install the ‘Scala’ plugin

Step 3: Hello, World!

Create a new IDEA project with a Scala module.

Create a new file called HelloWorld.scala and paste in the following code:

object HelloWorld {
  def main(args: Array[String]) {
    println("Hello, world!")
  }
}

Hit Ctrl-Shift-F10 to run it.

Congratulations! First Scala program done and dusted!

Step 4: Commute your Java skills to Scala

Read Daniel Spiewak’s ‘Scala for Java Refugees’ series.

This should give you enough knowledge and experience with Scala syntax to be able to write Scala that does most of the things you can do in Java.

Make sure you enter the code examples into IDEA and try them out as you go. I suggest typing them out instead of copy-paste, because that’s likely to give you exposure to common syntax mistakes and compiler errors.

Step 5: Open Your Eyes

Read through the ‘Tour of Scala’ on scala-lang.org

These short pages will give you some exposure to some of the more advanced features of Scala. Don’t worry if you don’t understand everything – just keep reading. You’re not trying to learn how to use all these things, just to know that they’re around.

Step 6: Learn the Basics, the Ins & the Outs

Read chapters 1 to 8 of Dean Wampler & Alex Payne’s ‘Programming Scala’ (O’Reilly)

This is where the learning gets heavy. We’re talking about more than half a book here. You’ll learn everything from basic syntax (some of which you’ll already know from the Refugees series) to Scala’s more advanced patterns for object-oriented programming, an introduction to Scala’s functional programming capabilities and some of the curly edges of Scala’s type system.

Again, make sure you try out running the code samples in IDEA. I suggest you also have a play around with some of the concepts in your own little test classes. Any time you find yourself thinking “I wonder if I can use this feature to do this?”, grab a keyboard and find out for yourself.

Step 7: Open the Dragon Scroll and Release your Scala Fu

Take a break from learning and do some hacking!

Think of a simple idea that you’d like to implement in Scala, then code it! (Seriously, I recommend keeping it REALLY simple.) If you can’t think of something yourself, you can steal my idea of writing a function to perform word-wrapping.

Step 8: Take a Walk around the Grounds

Read the rest of ‘Programming Scala’ (chapters 9 to 14)

The rest of the book covers some of the peripheral libraries and concepts in Scala that contribute to making it a great language, like Actors for multi-threaded programming, “herding” XML input and output and building blocks for creating domain-specific languages, as well as reviewing some of the tools that have sprung up in the Scala ecosystem.

Step 9: Join a Scala Community

All the steps so far have been leading you towards getting a good grounding in the language and some of the ecosystem that surrounds it. There’s much, much more to be learnt though, both about Scala itself and also about functional programming techniques that can help you make the most of it.

I think joining a community of like-minded Scala hackers is probably one of the best ways to extend the limits of your programming experience. Meetup.com has a list of 87 Scala meetup groups across the world. If your city doesn’t have one, why not start one? All you need to do is find a few local Scala people by searching Twitter and ask them if they want to start meeting just to chat. From personal experience I can tell you that sometimes meetups like this will introduce you to ideas that are more complex than any code you’ve ever seen, but part of the point of having these communities is to challenge each other to grow beyond what we already know.

Go Forth and Hack!

This is where the directed part of the journey ends, but hopefully it’s only the first step.

What you do with Scala next is up to you, but by this point you know more than enough about Scala to start using it seriously at home or even at work, for fun, or for making some serious cash! If you do make some serious cash by hacking Scala, please remember how it all started and send a little monetary “Thank you” my way. ; )

Addendum: Getting Help

Perhaps it was a little presumptuous of me to effectively say “go away now and code”. Chances are, you’ll need some help as you keep experimenting, learning and doing more and more cool stuff with Scala.

The two best places that I’ve found to connect with other Scala users are the scala-user mailing list run by scala-lang.org and, for curly technical problems that you just can’t figure out yourself, stackoverflow.com. Reading through other people’s Scala questions on Stack Overflow can also be a great way to pick up new ideas, and you should also check out this great list of nifty features in Scala.

[Update] Alternative: A Scala Course by the Creator

The learning tools I’ve outlined above are aimed chiefly at people who like to learn by reading and experimenting. If you’re more of a watcher/listener, you might enjoy this online Scala course on Coursera that someone on Hacker News pointed me to, in which Martin Odersky, the creator of Scala, teaches functional programming and Scala across 7 weeks worth of lecture videos, quiz questions and “homeworks”.

Image credit: Liberté by Pseudopix

Want to learn more?

Share Button

20 thoughts on “Graham’s Guide to Learning Scala

  1. Pingback: Do something useful with your holidays: Learn Scala | My Daily Feeds

  2. Great introductory article. Being the greedy person I am, I would have liked to see the tentative time ( I know it can change for different people but a guessestimate would have been fine 🙂 to be spent on each stage of knowing Scala.

    • Thanks, Anubhav. That’s a good question.
      My gut feel is that if you’re a good programmer and have a week off work, you should be able to get most of this done and be fairly proficient by the end of the week.
      If you’re a good programmer but just want to follow this in your spare time, you should easily be able to get through the first 6 steps in a week or two and be writing useful code, but it would take a bit longer to get through the rest of it.

  3. I think I disagree with almost every step you mentioned. 🙂

    – Avoid scala-lang.org at all costs, apart from the news section, the site is not maintained anymore. Use docs.scala-lang.org instead.

    – Ignore the ‘Tour of Scala’, it’s a complete misnomer and should be called ‘random features with outdated, broken code examples’. Again, every link to the website (not docs) is a complete waste of time.

    – Use the Eclipse IDE and its worksheet functionality.

    • Thanks for your comments, Simon.
      I don’t agree with your logic that because a website is no longer being added to that the existing content should be wholesale ignored. From what I see, docs.scala-lang.org is a work in progress at this point. (The front page says “So hang on, content is soon forthcoming.”)
      I haven’t used Eclipse for Scala so perhaps I’ll try and find some time to check out this worksheet thing you’ve suggested.
      Cheers,
      Graham.

    • Thanks for your comment, Juan. You’re right – extending App is the obvious choice for experienced Scala programmers. For what it’s worth, the Scala Tutorial for Java Programmers on docs.scala-lang.org contains the same code as I have above. The point of that step is not to teach best practice for writing apps but simply to get one thing compiled and running with zero explanation.
      Cheers,
      Graham.

  4. Scalatron (scalatron.github.com) is another resource to consider, either on your own or with a few friends. It’s a bot programming game with bots written in Scala. It has a step-by-step Scala tutorial and because there’s an optional browser front-end and the compiler is built into the game server, no setup is required at all – just download and launch.

  5. Pingback: This week in #Scala (23/11/2012) | Cake Solutions Team Blog

  6. I would replace step 4 with the book “Scala for the Impatient”. That book is really short and just gives you basic syntax in the most direct and concise possible way. Its a good idea to be get grounded in syntax before moving on to deeper concepts in the language.

    I also came across this Scala tutorial which covers a lot of ground:
    http://www.naildrivin5.com/scalatour

  7. Pingback: Graham’s Guide to Learning Scala | Open Source Code | Scoop.it

  8. Good list. I’ve recently started with Scala and had a similar experience, documented at scalaruss.wordpress.com if you’re interested. I started with Eclipse, but there were niggles which encouraged be over to IntelliJ, happy with it.

  9. Nice tutorial sir, i recently started reading Spark, so i need to learn about Scala. I found various tutorial of scala, but this one is best way to learn scala. thank u

  10. Pingback: Scala Programming Resources

  11. Pingback: Top 10 Reasons Java Programs Envy Scala (Presentation) - Evolvable Me

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.