scala-code-along
A short intro to Scala.
The provided code is ment as inspiration for interactive live coding sessions lead by someone who wants to share the joy of Scala. We code-along together step-by-step by typing/pasting code snippets into the Scala interactive shell, also known as the Scala REPL.
Preparations before coding along:
- Download latest Scala using http://scala-lang.org/download/ or mirrors provided below by LTH, Lund University in Sweden.
- Open a terminal window (bash | powershell | cmd)
- Run the
scala
command - Type or paste these code snippets line by line as we code along together
Scala download mirrors at cs.lth.se
-
Scala command line tools (
scala
,scalac
,scaladoc
, etc) -
Kojo IDE for easy scripting with api for 2D graphics and simple game dev
-
Recommended reading for java programmers:
- [Part of "Scala for the impatient"] (http://fileadmin.cs.lth.se/scala/scala-impatient.pdf) 6MB, first 110 pages Copyright Cay S. Horstmann 2012.
-
Download SimpleWindow etc. in cs_eda016.jar 51kB and JavaDoc for cs_eda016 to test Java interoperability:
- put the jar on the REPL's class path with
scala -cp cs_eda016.jar
- or if you have compiled some
object Main extends App
thatimport se.lth.cs.window.SimpleWindow
, run your class file Main.class using:- Windows:
scala -cp "cs_eda016.jar;." Main
note the quotes, semicolon and dot - Linux:
scala -cp "cs_eda016.jar:." Main
note the quotes, colon and dot
- Windows:
- put the jar on the REPL's class path with
Scala?
What is- Scala is a statically typed object-functional programming language
- Scala runs as fast as Java on the Java Virtual Machine
- Scala can call any Java byte code, including all classes in the JDK
- Scala's standard library includes a powerful collections library
- Scala has more powerful abstraction mechanisms compared to Java
- Scala is more regular compared to Java
- Scala is as concise as many dynamic scripting languages
- Scala is statically typed; thus both safe and fast
- Scala is used by Twitter, LinkedIn, Netflix, Coursera, ...
- There are many useful Scala libs and frameworks: Play, Akka, Scalatra, ...