Scala for human beings

Getting started with Scala , the easy way

Divan Visagie
From The Couch
Published in
4 min readJun 9, 2016

--

NOTICE: This article centers around the usage of Typesafe/Lightbend activator which has officially been announced to be shutting down. This is good news however as the process has been simplified a lot, visit Lightbend’s getting started guide for details.

Scala is currently my favourite programming language , but there are a few bumps in the road one may run into when you are trying to get started. So I have decided to tell you what tools and resources I personally think are the most intuitive in order to at least get started without having to fiddle with editor plugins.

Environment and tools

I will not be explaining the install processes for these tools, which can be very different on different platforms , they have install instructions of their own. What we are covering here is the hard part; finding out you actually need them.

Scala runs on the JVM , so you are going to need Java and the JDK.

Scala’s download page puts not a fork but a trident in your road, Scala libraries? Or Lightbend (previously Typesafe) Activator? Or use some subclass of “tool that does too much but is useful sometimes when re-factoring” . While you may end up starting projects manually with sbt when you are familiar with the language and it’s build tools , right now , you are already getting bored installing all this stuff and you just want to see hello world pop up on the screen so that you may move on with your life, you can come round to learning sbt later. Choose Activator.

Right , you now have Activator installed , congratulations !! You installed something that wasn't an IDE and therefore are smarter than your average platform locked nincompoop.

Setting up a project

Think of Activator as ‘The thing that makes Scala projects’. Activator can be used in two different ways.

You could use the new command and generate projects solely from command line :

Selecting minimal-scala will generate you a command line app with unit-tests. Running sbt test in the generated directory will give you a nice green test and sbt run will print you your “Hello, World!”

The second way is to use the activator ui command, which launches a web page with some nice clicky options on it. We will do this for now , because it also provides a code editor, I don’t want to make recommendations on editor choice, and you really just want to write some code already!

Running the command will spin up the following UI in your web browser:

Those seeds you see in the templates list on the left are the same seeds you saw when running activator new. Personally , If I need a basic Scala unit tested app I will use the command line, but the search functionality in the UI is much easier when I am trying to find other seeds, yes , there is a nice lengthy list , it’s quite nice for getting your project going.

Selecting the “Hello Scala” tutorial will generate you the same seed project we generated earlier from the command line and take us to what can best be described as a web based “IDE”. The difference with the tutorial template is that it has, well a tutorial on whats going on:

Once you have followed along until the end and have written the next big text printer…

… You may feel inclined to follow the next-step links which are great resources by the way, Scala School even gets you a little into Twitters stack. But if you are just starting out , I would suggest first checking out Scala Exercises by 47 Degrees , It’s a nice interactive online tutorial that is very well done and covers the language very well.

--

--

Divan Visagie
From The Couch

I write about tech and anything else I find interesting