This is a short introduction to Scala for the Women Who Code meet up in Workday's Dublin office.
This introduction is based on the book Atomic Scala by Bruce Eckel and Dianne Marsh. The fist half of this book is available free online.
- We are going to setup a Scala development environment.
- Then then we will explore basic Scala syntax in the REPL (Scala Shell).
- Next we will look at classes and objects.
- Before finishing looking at collections and functional programming.
To keep things simple I am going to use git, sbt and the atom editor for this introduction. There is also a docker image containing the code and a full command-line development environment.
Or just use a online Scala REPL
There are a number of online Scala REPLs that will let you work through this code.
Scala is a JVM language you will need to install the Java Development Kit to follow this tutorial. If installing this for the first time select version 8. You can also use version 7 if its installed already.
The source code for this tutorial is available on github. Ensure that git is installed on you local machine, there are detailed instructions here.
Then to download the code use the following command line
git clone https://github.com/IainHull/women-who-code-scala-intro.git
cd women-who-code-scala-intro
TODO
If you cannot use Git you can download the source code for each step as a zip file here.
SBT is the Scala build tool once it install and configure our scala commandline environment.
Full details on how to download and install SBT are here. If you do not want to install SBT onto your system follow the manual instructions to download and run SBT from a temp directory.
Run SBT from the command-line, then in the SBT shell run compile
and console
. Console runs the Scala REPL. To exit the REPL type :quit
. To exit the SBT shell type 'exit'
$ sbt
> compile
> test
> console
scala> :quit
> exit
I am using the Atom editor, its a friendly open source editor. You are free to use what ever IDE or editor you like.
Pull and run the women-who-code-scala-intro docker image. Be warned this image is about 800Mb, download this in advance.
docker pull iainhull/women-who-code-scala-intro
docker run -it iainhull/women-who-code-scala-intro
Now run sbt from the docker command-line.
# sbt
Absolutely not. Experience with any object oriented or functional language will do. I will introduce all the scala features as we use them.
Using types for correctness is common functional technique, but it can just as easily be applied to object oriented code. The code we will be working on will be very simple, but time allowing we will explore more advanced functional concepts like type-classes.
A laptop and a sense of adventure.
The source code we will hack on will be provided in a github repo.
All code and documentation is licensed under the Creative Commons Attribution 3.0 Unported License. See LICENSE.md for more information.