Scala Notes: Getting Started
This is the first in a series of very short articles I am calling scala-notes where I will share my notes and or my favorite links about Scala related topics. Hopefully this will prove to be a motivator for me to mine the giant stack of paper notes I have written about scala… In any case I hope this exercise proves useful for somebody.
Getting Started with Scala
When you get started with a language you need a “Hello, World”. (This example works if you install Scala, rather than using it from SBT
.) So here is one:
$ vi HelloWorld.scala
object HelloWorld extends App {
println("Hello, world!")
}
$ scalac HelloWorld.scala
$ scala HelloWorld
Hello, world!
What is Scala?
The official answer is here, but to me it is simply an object-functional programming language on the JVM. The more interesting part is the functional part, but because it also supports object oriented design on the JVM, it makes for a simpler transition from Java than say moving directly to Haskell. If you are a Java programmer maybe you should avoid scala? Don’t say I didn’t warn you. ;-)
Functional
Here are some functional programming links (mostly videos). Some relate to scala more than others.
Videos
Erik Meijer Functional Programming Fundamentals Thirteen lectures.
Erik Meijer Many useful videos.
Brian Beckman Many useful videos.
Bodil Stokke: What Every Hipster Should Know About Functional Programming A fun look at some functional programming terms.
Functional Thinking with Neal Ford A good introduction to the kind of thinking used in Functional Programming. Includes examples in various programming languages (not just Scala). Gets especially pragmatic at about 31:00.
Books
Functional Programming in Scala by Paul Chiusano and Rúnar Bjarnason This is an outstanding book. It can be treated as a course in Scala by going through the exercises in each chapter.
SICP: Structure and Interpretation of Computer Programs, by Abelson, Sussman, and Sussman Read or re-read this one. No, seriously, do it right now. You will be glad you did.
General Scala
Links
A Tour of Scala A nice tutorial.
Scala School! From ∅ to Distributed Service Twitter’s excellent tutorial.
A Glossary of Scala and Functional Programming terms taken from the Programming in Scala book
Cheat Sheet for Scala Syntax or Cheatsheet at scala-lang.org The version at scala-lang.org is a copy of Brendan O’Connor’s Cheat Sheet for Scala Syntax.
progfun wiki cheatsheet This originated from the Functional Programming Principles in Scala class. I can’t recommend the class enough.
Reactive cheetsheet This originated from the Principles of Reactive Programming class. Really great class.
Scala information from stackoverflow.com Good stuff here. Some overlap but that is fine.
Scala style guide Be aware that some of these style decisions will save you headaches. One example is the curly brace alignment. It has been difficult to change my brace style to fit the recommendation but it is better than dealing with parsing problems.
Books
Scala by Example by Martin Odersky Useful book. This link to a PDF version.
Programming in Scala, First Edition by Martin Odersky, Lex Spoon, and Bill Venners The link is to the first edition which is made freely available online.
Scala for the Impatient by Cay Horstmann The link is to a freely available subset of the book in PDF format.
The Scala Language Specification Scala Reference I consider this the Scala Reference rather than a true specification regardless of the title.
If you have some favorite links for getting started with Scala, then please share them in a comment.