Our Recommended Setup
This section is our recommended setup for people new to programming, and describes how to setup Creative Scala with the terminal and Visual Studio Code. We need to install:
- the JVM;
- Git;
- a text editor (Visual Studio Code); and
- the template project for Creative Scala.
Installing the JVM
The easiest way to install the JVM is to install Coursier. It will also install some other useful Scala programs at the same time. Follow the instructions on the home page to install it.
Then follow the instructions below that are specific to your operating system.
MacOs
After installing Coursier:
-
Open the terminal. (Click the magnifying glass icon on the top righthand side of the toolbar. Type in "terminal".)
-
Install homebrew, following the instructions on its site.
-
Install
git
using homebrew. At the terminal, typebrew install git
-
Now install the text editor Visual Studio Code. Again type at the terminal
brew install --cask visual-studio-code
-
Install Scala support inside Visual Studio Code: Code > Preferences > Extensions and install:
- Scala (Metals)
- Scala Syntax (official)
-
Now we will use Git to get an SBT project that will work with Creative Scala. Type
git clone https://github.com/creativescala/creative-scala-template.git
Sharing Your Work
There is an alternative setup that involves first forking the Creative Scala template project, and then cloning it to your computer. This is the setup to choose if you want to share your work with other people; for example you might be taking Creative Scala with a remote instructor or you might quite rightfully be proud of your work and want others to see it.
In this setup you first fork the Creative Scala template. Then you make a clone of your fork. This alternative setup is described in more detail in the section on GitHub later in this chapter.
To finish, change to the directory we just created and run sbt:
cd creative-scala-template
sbt
sbt should start. Within sbt type run
and an image should appear. If it does you have everything correctly installed!
The final step is to load Visual Studio Code and use it to open Example.scala
, which you can find in src/main/scala
.
Windows
After installing Coursier:
-
Download and install Visual Studio Code using the installer on their site.
-
Open Visual Studio Code and add Scala support: Code > Preferences > Extensions and install:
- Scala (Metals)
- Scala Syntax (official)
-
Download and install Git. At the very end of the installer it gives you the option to open Git. Select that option. A window will open up with a command prompt.
-
In the Git command prompt type
git clone https://github.com/creativescala/creative-scala-template.git
-
Open a normal command-prompt. Click on the Windows icon on the bottom left of the screen. In the search box enter "cmd" and run the program it finds. In the window that is opened up type
cd creative-scala-template
which will change into the directory of the Creative Scala template project we just downloaded.
-
Type
sbt
sbt should start. Within sbt type
run
and an image should appear. It it does you have everything correctly installed!
If you've made it this far you've successfully installed all the software you need for work through Creative Scala.
The final step is to load Visual Studio Code and use it to open Example.scala
, which you can find in src\main\scala
.
Linux
Follow the OS X instructions, using your distributions package manager to install software in place of Homebrew.