A+ will be down for a version upgrade on Thursday October 17th 2024 at 09:00-12:00.
This course has already ended.

The latest instance of the course can be found at: O1: 2024

Luet oppimateriaalin englanninkielistä versiota. Mainitsit kuitenkin taustakyselyssä osaavasi suomea. Siksi suosittelemme, että käytät suomenkielistä versiota, joka on testatumpi ja hieman laajempi ja muutenkin mukava.

Suomenkielinen materiaali kyllä esittelee englanninkielisetkin termit. Myös suomenkielisessä materiaalissa käytetään ohjelmien koodissa englanninkielisiä nimiä kurssin alkupään johdantoesimerkkejä lukuunottamatta.

Voit vaihtaa kieltä A+:n valikon yläreunassa olevasta painikkeesta. Tai tästä: Vaihda suomeksi.


Installing IntelliJ

As explained in Chapter 1.2, O1’s official programming environment is IntelliJ IDEA (just IntelliJ for short) and its plugin A+ Courses. These tools are installed on Aalto IT’s Linux workstations.

If you want to use IntelliJ on your personal computer, you’ll need to install it as described on this page. IntelliJ is available for Windows, macOS, and Linux, at no cost. The newer your operating system, the less likely it is that you’ll run into trouble while installing.

(Aalto IT also provides a virtual Linux desktop that you can access over the network from your own computer. The virtual desktop, which is also briefly introduced in Chapter 1.2, probably won’t give you the smoothest IntelliJ experience, though.)

To use IntelliJ IDEA (just IntelliJ for short) for programming on your on your personal computer, you’ll need to install it as described on this page. It is available for Windows, macOS, and Linux, at no cost. The newer your operating system, the less likely it is that you’ll run into trouble while installing.

These links take you to the appropriate installation instructions below on this page:

Version numbers matter!

Any tools that you use in O1 should be compatible with version 2.13.1 of the Scala programming language.

We use the IntelliJ version called Community Edition 2020.2. The recommended version of IntelliJ’s A+ Courses plugin is 1.8.

You’ll also need a Java toolkit (JDK); the recommended version is 11.

The instructions on this page will help you find the appropriate versions.

Windows

Step 1/5: Install IntelliJ

Download IntelliJ IDEA Community, version 2020.2. Make sure to pick the Community edition, not the commercial Ultimate edition. Choose the Windows (exe) installer.

With the installer downloaded, double-click to run it.

Unless you have a particular reason to do otherwise, the default responses to the installer’s questions will do.

If you’re going to continue to the next step right away, you may as well check the Run IntelliJ box in the last screen.

Step 2/5: Launch IntelliJ

If you didn’t already start IntelliJ at the end of the previous step, do it now. You can do that via the Start menu, for example (or via the file idea64.exe that is under the folder where you installed IntelliJ, in the bin subfolder).

On first launch, IntelliJ will ask you about sharing usage data and importing old settings. You can pick Do not import settings and press OK.

On the next screens, you could adjust certain settings, but don’t do that now. Just press Next a couple of times and you’ll arrive at the Featured Plugins screen.

Press Start using IntelliJ IDEA. IntelliJ suggests that you create or select a project, which is going to store your work. Select New Project. In the dialog that pops up, pick Empty project and press Next.

At the next prompt, under Project name, write a suitable name for your course project (e.g., o1 or o1assignments). Under Project location, you can mark which folder you’d like IntelliJ to store your files in; the suggested default will do, unless you wish to change it.

Press Finish. IntelliJ launches and shows you a tip-of-the-day, which you can close. A Project Structure window remains open.

Step 3/5: Fetch the JDK toolkit into IntelliJ

While programming in IntelliJ, you’ll need a toolkit known as the JDK. You can install it as follows.

There should be a Project Structure window in view. (If you misplaced the window, you can find it via the File menu.) In that window, under Project Settings, select Project.

You should see a drop-down menu named Project SDK. In that menu, is there an option labeled OpenJDK 11?

  • If it happens that yes, there is, pick that option.
  • If not, choose Add SDK → Download JDK in the drop-down menu. For Vendor, pick AdoptOpenJDK (HotSpot), and for Version, pick 11.0.8. You’re free to choose where to download the JDK; the default folder should do fine. Finally, press Download, and IntelliJ will fetch the toolkit.

Press OK to close the Project Structure window.

Step 4/5: The A+ Courses plugin

A plugin named A+ Courses supports your coursework in IntelliJ. The plugin makes it very easy to fetch course materials and to submit your programs for automatic grading straight from IntelliJ.

Using the A+ Courses plugin is strongly recommended. Our ebook assumes that you do. (You could choose not to use the plugin, but it’s not convenient for you. See the alternative instructions at the bottom of this page.)

Here’s how to install the A+ Courses plugin:

  1. In IntelliJ, select File → Settings → Plugins.
  1. In the search field, enter A+ Courses and select the plugin in the search results. An Install button appears; press it.
  2. IntelliJ notifies you about installing a third-party plugin. Press Accept to okay that.
  3. IntelliJ informs you that A+ Courses requires the Scala plugin to be installed as well. Press Install.
  4. Press Restart IDE to finish up the installation.
    • If that button fails to show up, close IntelliJ yourself and relaunch it.
    • When restarting, you may be given a brief notice about “indexing” being unfinished. Don’t worry about it.

Once IntelliJ has restarted, look at the main menu bar at the top. You’ll find a new A+ menu. Use it to set up your O1 project:

  1. Select A+ → Turn Project Into A+ Course Project.
  2. A small dialog window pops up. In the language menu, pick English or Finnish. IntelliJ also tells you that it’s going to adjust some settings to suit the course. Press OK to approve.
    • Some of O1’s assignments come in two variants: a Finnish one and an English one. That language setting affects which ones you’ll submit. If you know Finnish, we recommend that you use the Finnish edition of this ebook and pick Finnish here. This setting has no effect on IntelliJ itself; it will be in English either way.
  3. IntelliJ suggests a restart to apply the new settings. Press Yes to restart. (It may take little while before the restart prompt appears.)
  4. There is now a A+ Courses -tab at IntelliJ’s right-hand edge. You’ll be able to find course content there when needed later.

Step 5/5: Configure A+ access for assignment submissions

Before you can submit assignments to A+ from IntelliJ, you’ll need to give IntelliJ permission to act in your name in A+. You do that by giving IntelliJ a “passcode”, (properly known as an API Access Token):

  1. Open up your profile page in A+.
  2. There’s a long string of characters under API Access Token. Copy the entire string to the clipboard. (That’s your personal code. Do not share it with other people.)
  3. In the IntelliJ menu, select A+ → Set A+ Token.
  4. Paste the access token at the prompt and press OK.

macOS

Step 1/5: Install IntelliJ

Download IntelliJ IDEA Community, version 2020.2. Make sure to pick the Community edition, not the commercial Ultimate edition.

Install the program simply by extracting the files from the downloaded package: Click the file to open it and drag the IntelliJ_IDEA folder from the package into your Applications folder.

Step 2/5: Launch IntelliJ

Launch IntelliJ from the file Idea.

On first launch, IntelliJ will ask you about sharing usage data and importing old settings. You can pick Do not import settings and press OK.

On the next screens, you could adjust certain settings, but don’t do that now. Just press Next a couple of times and you’ll arrive at the Featured Plugins screen.

Press Start using IntelliJ IDEA. IntelliJ suggests that you create or select a project, which is going to store your work. Select New Project. In the dialog that pops up, pick Empty project and press Next.

At the next prompt, under Project name, write a suitable name for your course project (e.g., o1 or o1assignments). Under Project location, you can mark which folder you’d like IntelliJ to store your files in; the suggested default will do, unless you wish to change it.

Press Finish. IntelliJ launches and shows you a tip-of-the-day, which you can close. A Project Structure window remains open.

Step 3/5: Fetch the JDK toolkit into IntelliJ

While programming in IntelliJ, you’ll need a toolkit known as the JDK. You can install it as follows.

There should be a Project Structure window in view. (If you misplaced the window, you can find it via the File menu.) In that window, under Project Settings, select Project.

You should see a drop-down menu named Project SDK. In that menu, is there an option labeled OpenJDK 11?

  • If it happens that yes, there is, pick that option.
  • If not, choose Add SDK → Download JDK in the drop-down menu. For Vendor, pick AdoptOpenJDK (HotSpot), and for Version, pick 11.0.8. You’re free to choose where to download the JDK; the default folder should do fine. Finally, press Download, and IntelliJ will fetch the toolkit.

Press OK to close the Project Structure window.

Step 4/5: The A+ Courses plugin

A plugin named A+ Courses supports your coursework in IntelliJ. The plugin makes it very easy to fetch course materials and to submit your programs for automatic grading straight from IntelliJ.

Using the A+ Courses plugin is strongly recommended. Our ebook assumes that you do. (You could choose not to use the plugin, but it’s not convenient for you. See the alternative instructions at the bottom of this page.)

Here’s how to install the A+ Courses plugin:

  1. In IntelliJ, select IntelliJ IDEA → Preferences → Plugins.
  1. In the search field, enter A+ Courses and select the plugin in the search results. An Install button appears; press it.
  2. IntelliJ notifies you about installing a third-party plugin. Press Accept to okay that.
  3. IntelliJ informs you that A+ Courses requires the Scala plugin to be installed as well. Press Install.
  4. Press Restart IDE to finish up the installation.
    • If that button fails to show up, close IntelliJ yourself and relaunch it.
    • When restarting, you may be given a brief notice about “indexing” being unfinished. Don’t worry about it.

Once IntelliJ has restarted, look at the main menu bar at the top. You’ll find a new A+ menu. Use it to set up your O1 project:

  1. Select A+ → Turn Project Into A+ Course Project.
  2. A small dialog window pops up. In the language menu, pick English or Finnish. IntelliJ also tells you that it’s going to adjust some settings to suit the course. Press OK to approve.
    • Some of O1’s assignments come in two variants: a Finnish one and an English one. That language setting affects which ones you’ll submit. If you know Finnish, we recommend that you use the Finnish edition of this ebook and pick Finnish here. This setting has no effect on IntelliJ itself; it will be in English either way.
  3. IntelliJ suggests a restart to apply the new settings. Press Yes to restart. (It may take little while before the restart prompt appears.)
  4. There is now a A+ Courses -tab at IntelliJ’s right-hand edge. You’ll be able to find course content there when needed later.

Finally, you can make it easier to launch IntelliJ later by attaching it to the macOS Dock. Right-click the IntelliJ icon in the Dock and select Options → Keep in Dock. Now you’ll be able to find IntelliJ in the Dock.

Step 5/5: Configure A+ access for assignment submissions

Before you can submit assignments to A+ from IntelliJ, you’ll need to give IntelliJ permission to act in your name in A+. You do that by giving IntelliJ a “passcode”, (properly known as an API Access Token):

  1. Open up your profile page in A+.
  2. There’s a long string of characters under API Access Token. Copy the entire string to the clipboard. (That’s your personal code. Do not share it with other people.)
  3. In the IntelliJ menu, select A+ → Set A+ Token.
  4. Paste the access token at the prompt and press OK.

Linux (Ubuntu)

Step 1/5: Install IntelliJ

Download IntelliJ IDEA Community, version 2020.2. Make sure to pick the Community edition, not the commercial Ultimate edition.

Install the program simply by extracting the files from the downloaded package: Click the file to open it. Extracts its contents in a folder of your choosing.

Step 2/5: Launch IntelliJ

Launch IntelliJ from the file idea.sh:

  • In the Linux Terminal, go to the folder where you extrated the files.
  • Enter ./bin/idea.sh to start the program.

On first launch, IntelliJ will ask you about sharing usage data and importing old settings. You can pick Do not import settings and press OK.

On the next screens, you could adjust certain settings, but don’t do that now. Just press Next a couple of times and you’ll arrive at the Featured Plugins screen.

Press Start using IntelliJ IDEA. IntelliJ suggests that you create or select a project, which is going to store your work. Select New Project. In the dialog that pops up, pick Empty project and press Next.

At the next prompt, under Project name, write a suitable name for your course project (e.g., o1 or o1assignments). Under Project location, you can mark which folder you’d like IntelliJ to store your files in; the suggested default will do, unless you wish to change it.

Press Finish. IntelliJ launches and shows you a tip-of-the-day, which you can close. A Project Structure window remains open.

Step 3/5: Fetch the JDK toolkit into IntelliJ

While programming in IntelliJ, you’ll need a toolkit known as the JDK. You can install it as follows.

There should be a Project Structure window in view. (If you misplaced the window, you can find it via the File menu.) In that window, under Project Settings, select Project.

You should see a drop-down menu named Project SDK. In that menu, is there an option labeled OpenJDK 11?

  • If it happens that yes, there is, pick that option.
  • If not, choose Add SDK → Download JDK in the drop-down menu. For Vendor, pick AdoptOpenJDK (HotSpot), and for Version, pick 11.0.8. You’re free to choose where to download the JDK; the default folder should do fine. Finally, press Download, and IntelliJ will fetch the toolkit.

Press OK to close the Project Structure window.

Step 4/5: The A+ Courses plugin

A plugin named A+ Courses supports your coursework in IntelliJ. The plugin makes it very easy to fetch course materials and to submit your programs for automatic grading straight from IntelliJ.

Using the A+ Courses plugin is strongly recommended. Our ebook assumes that you do. (You could choose not to use the plugin, but it’s not convenient for you. See the alternative instructions at the bottom of this page.)

Here’s how to install the A+ Courses plugin:

  1. In IntelliJ, select File → Settings → Plugins.
  1. In the search field, enter A+ Courses and select the plugin in the search results. An Install button appears; press it.
  2. IntelliJ notifies you about installing a third-party plugin. Press Accept to okay that.
  3. IntelliJ informs you that A+ Courses requires the Scala plugin to be installed as well. Press Install.
  4. Press Restart IDE to finish up the installation.
    • If that button fails to show up, close IntelliJ yourself and relaunch it.
    • When restarting, you may be given a brief notice about “indexing” being unfinished. Don’t worry about it.

Once IntelliJ has restarted, look at the main menu bar at the top. You’ll find a new A+ menu. Use it to set up your O1 project:

  1. Select A+ → Turn Project Into A+ Course Project.
  2. A small dialog window pops up. In the language menu, pick English or Finnish. IntelliJ also tells you that it’s going to adjust some settings to suit the course. Press OK to approve.
    • Some of O1’s assignments come in two variants: a Finnish one and an English one. That language setting affects which ones you’ll submit. If you know Finnish, we recommend that you use the Finnish edition of this ebook and pick Finnish here. This setting has no effect on IntelliJ itself; it will be in English either way.
  3. IntelliJ suggests a restart to apply the new settings. Press Yes to restart. (It may take little while before the restart prompt appears.)
  4. There is now a A+ Courses -tab at IntelliJ’s right-hand edge. You’ll be able to find course content there when needed later.

Step 5/5: Configure A+ access for assignment submissions

Before you can submit assignments to A+ from IntelliJ, you’ll need to give IntelliJ permission to act in your name in A+. You do that by giving IntelliJ a “passcode”, (properly known as an API Access Token):

  1. Open up your profile page in A+.
  2. There’s a long string of characters under API Access Token. Copy the entire string to the clipboard. (That’s your personal code. Do not share it with other people.)
  3. In the IntelliJ menu, select A+ → Set A+ Token.
  4. Paste the access token at the prompt and press OK.

Additional Materials for Special Cases

Why do I keep needing to enter the A+ access token again (on Aalto’s Linuxes)?

IntelliJ stores your A+ access token. However, this storage fails in certain circumstances, causing IntelliJ to prompt you for the token once every session, which is a bit inconvenient.

If this happens to you on Aalto’s Linuxes, the probable cause is that you’ve changed your Aalto password. IntelliJ uses Linux’s built-in password store, but that storage fails after a password change.

You’ll find three alternative solutions below. After you apply one of them, you’ll still need to enter the A+ token once more, but it should then remain in storage even if you close IntelliJ or log off.

Solution 1: Change the storage’s password

If you still remember your first Aalto password, you can change the password storage’s main password to correspond to your current Aalto password:

  1. Open the applications menu and find Passwords and Keys.
  2. Right-click Login and select Change password.
  3. Enter your old password and press Continue.
  4. Enter your current Aalto password (twice) and finish with Continue.

Solution 2: Re-initialize the password storage

If you don’t remember your earlier password, you can create a new login.keyring file to replace the old password storage.

In Linux’s Terminal, enter these commands to remove the old file:

  • cd ~/.local/share/keyrings/
  • cp login.keyring login.keyring.BACKUP
  • rm login.keyring

Create a new login.keyring with your current Aalto password:

  1. In the applications menu, find Passwords and Keys.
  2. Select File → New... → Password Keyring and press Continue.
  3. Enter login as the file name. When prompted enter your Aalto password and press Continue.

Solution 3: Store the access token differently

You can make IntelliJ store the token in a different way:

  1. In IntelliJ, select File –> Settings –> Appearance & Behaviour –> System Settings –> Passwords.
  2. Under Save passwords, pick In KeePass.
  3. The default location that IntelliJ suggests should be OK. Press Apply and OK.

What if A+ Courses does not work on my computer or I don’t want to use it?

If you don’t use the A+ Courses plugin, you’ll have to go to more trouble fetching, configuring, and submitting O1’s programming assignments and when using IntelliJ’s REPL, which we’ll be using a lot.

We strongly recommend that you use the plugin. However, if you don’t, the instructions below may be of use.

Initializing the O1 project (without the A+ Courses plugin)

Install IntelliJ as instructed above, but when you launch it for the first time, do a few things differently.

Before creating a new project, in the Welcome to IntelliJ IDEA screen, install the Scala plugin:

  1. Select Configure –> Plugins.
  2. If Scala does not immediately show up in the list, enter Scala in the search field. Select the Scala plugin and press Install.
  3. After installing Scala, IntelliJ needs to restart. Press Restart IDE.

Now select New Project. In the list of project types on the left, pick Scala. In the list that shows up, select IDEA. In the following screen, under Project name type a descriptive name for the project (e.g., o1). IntelliJ suggests a folder for the project, which you may edit if you wish.

Next, you’ll have to install appropriate toolkits (a JDK and a Scala SDK):

  1. Click the JDK drop-down menu and select Download JDK.
  2. Under Vendor, pick AdoptOpen JDK (HotSpot). Under Version, pick 11.0.8. You’re free to select a download folder. Then press Download and IntelliJ will fetch the selected JDK.
  3. Next to the Scala SDK drop-down menu, press Create. Then choose Download and pick version 2.13.1. Press OK.
  4. Press Finish. Your new project opens in IntelliJ. IntelliJ shows a tip-of-the-day, which you can Close.
  5. Select File → Project Structure... → Libraries. Press the little plus icon + and select scala-sdk-2.13.1.
  6. IntelliJ informs you that the selected toolkit will be associated with your project. Confirm with OK, then Yes.

Importing course settings to IntelliJ (without the A+ Courses plugin)

First, import O1’s project-specific settings:

  1. Exit IntelliJ.
  2. Download the settings file o1_2020_project_settings.zip and save it in a folder of your choosing.
  3. Open the zip file. Extract the .idea folder into your project folder so that its contents (partially) replace the contents of the project folder’s .idea subfolder.
    • That is, don’t nest the two .idea folders and don’t start by deleting the old .idea folder.)
    • It is possible that your operating system is configured not to show hidden files and folders (whose names begin with a period like .idea) in folder listings. In that case, you’ll want to adjust that setting.
  4. When extracting the files, you’ll be asked if you want to replace the identically named files already there. Do replace them.
  5. Restart IntelliJ.

Second, you should import O1’s generic IntelliJ settings:

  1. Download the settings file o1_2020_ij_settings.zip and save it in a folder of your choosing.
  2. In IntelliJ, select File → Manage IDE settings → Import settings.
  3. When prompted for a file, choose the file o1_2020_ij_settings.zip that you just downloaded.
  4. Make sure that all the boxes are checked and press OK.
  5. Confirm another Restart.

Fetching O1’s modules into IntelliJ (without the A+ Courses plugin)

At the top of each ebook chapter, you’ll find links to the related course modules (i.e., example programs and base code for programming assignments). With A+ Courses, you don’t need those links, because IntelliJ will download and install the modules in a snap, but you can do the same manually.

Follow the module link and download the corresponding zip file onto your computer. Extract its contents in your project folder. Once you do that, the files will show up in IntelliJ’s Project view on the left, but you still need to mark them as submodules of the overall O1 project.

Open the new module’s folder in IntelliJ. Right-click the file with an .iml name suffix. Select Import '[Module name]' Module.

Submitting assignments (without the A+ Courses plugin)

The A+ Courses submits your work directly from IntelliJ. As an alternative, you can use the web forms that you find in the ebook chapters.

Many web browsers let you drag and drop the file straight from IntelliJ into the field below. If it doesn’t work for you, click in the web form and locate the file within your project folder.

Launching the Scala REPL in a specific module (without the A+ Courses plugin)

Without the A+ Courses plugin, IntelliJ does not know how to set launch the REPL so that the code you write is easily accessible from within the REPL.

If you don’t use the plugin, you’ll need to create a new run configuration when you start working with a new module:

  1. Select Run → Edit Configurations.
  2. Click the little plus icon + at the top left.
  3. In the list, select Scala REPL.
  4. In the Name field at the top, enter a descriptive name such as “REPL [Module Name Here]”.
  5. Under Use classpath and SDK of module:, select the appropriate module.
  6. Press Apply and OK.
  7. You can now launch that run configuration to start the REPL. One way to do that is to find it the drop-down menu in IntelliJ’s top right-hand corner and press the play button play.

Apart from taking care of run configurations for the REPL, the A+ Courses plugin saves your fingers by automatically importing certain relevant packages of Scala code (such as package o1) after you’ve started the REPL. Without the plugin, you’ll need to every package that you need whenever you use the REPL. For example:

import o1._import o1._
import o1.goodstuff._import o1.goodstuff._

Chapter 1.6 says more about packages and Scala’s import command.

Feedback

Credits

Thousands of students have given feedback that has contributed to this ebook’s design. Thank you!

The ebook’s chapters, programming assignments, and weekly bulletins have been written in Finnish and translated into English by Juha Sorva.

The appendices (glossary, Scala reference, FAQ, etc.) are by Juha Sorva unless otherwise specified on the page.

The automatic assessment of the assignments has been developed by: (in alphabetical order) Riku Autio, Nikolas Drosdek, Joonatan Honkamaa, Jaakko Kantojärvi, Niklas Kröger, Teemu Lehtinen, Strasdosky Otewa, Timi Seppälä, Teemu Sirkiä, and Aleksi Vartiainen.

The illustrations at the top of each chapter, and the similar drawings elsewhere in the ebook, are the work of Christina Lassheikki.

The animations that detail the execution Scala programs have been designed by Juha Sorva and Teemu Sirkiä. Teemu Sirkiä and Riku Autio did the technical implementation, relying on Teemu’s Jsvee and Kelmu toolkits.

The other diagrams and interactive presentations in the ebook are by Juha Sorva.

The O1Library software has been developed by Aleksi Lukkarinen and Juha Sorva. Several of its key components are built upon Aleksi’s SMCL library.

The pedagogy of using O1Library for simple graphical programming (such as Pic) is inspired by the textbooks How to Design Programs by Flatt, Felleisen, Findler, and Krishnamurthi and Picturing Programs by Stephen Bloch.

The course platform A+ was originally created at Aalto’s LeTech research group as a student project. The open-source project is now shepherded by the Computer Science department’s edu-tech team and hosted by the department’s IT services. Markku Riekkinen is the current lead developer; dozens of Aalto students and others have also contributed.

The A+ Courses plugin, which supports A+ and O1 in IntelliJ IDEA, is another open-source project. It was created by Nikolai Denissov, Olli Kiljunen, and Nikolas Drosdek with input from Juha Sorva, Otto Seppälä, Arto Hellas, and others.

For O1’s current teaching staff, please see Chapter 1.1.

Additional credits for this page

This page was written by Niklas Kröger and Juha Sorva.

a drop of ink
Posting submission...