Skip to content

seanpm2001/Learn-Scala


/Scala-full-color.svg

Learning Scala (programming language)

I know very little about the Scala programming language. This document will go over all of my knowledge of the Scala programming language.

Hello World in Scala

This is how you make a normal Hello World program in Scala:

@main def main() = {
  println("Hello, World!")
}

It is similar to Java.

Simple Hello World in Scala

A more simple version of the Hello World program for Scala can be writtern with just 1 line:

println("Hello World")

Comments in Scala

Comments in Scala are the same as in languages like Java, C, C++, etc.

Single line comments

Single line comments in Scala are written like so:

// This is a single line comment in Scala
Multi-line comments

Multi-line comments in Scala look like this:

/* This is
* a multi-
* line
* comment */

Break keyword in Scala

Scala does not support the break keyword.

Classes in Scala

Classes in Scala are simplified version of Java classes known as singletons of which they only contain 1 type (and not multiple, like in Java: static, void, public etc.)

class scalaClass(
    println("Scala class")
)

/!\ This example has not been tested yet, and may not work

Functions in Scala

Functions in Scala are simple and straightforward. They are defined like so:

def printFunction {
    println("The print function has been printed")
}

/!\ This example has not been tested yet, and may not work

Other knowledge of the Scala programming language

  1. Scala is a language by Martin Odersky

  2. Scala is not a semicolon and curly bracket language, but it is a semicolon language

  3. Scala uses the *.scala file extension by default, and also uses the *.sc file extension. I don't know if it uses any other file extensions.

  4. Scala is designed to remove the problems with Java

  5. Scala is said to have a learning curve, and has been removed from several companies usage, such as Twitter and Yammer

  6. Scala was created in 2004

  7. Scala is one of the top 50 programming languages (as of 2022, July 31st, it ranks #34) source: TIOBE index

  8. Scala is a language recognized by GitHub (as of 2022, Tuesday, August 2nd)

  9. Scala recognizes everything as an expression

  10. Scala is very similar to Java

  11. No other knowledge of the Scala programming language

Additional comments

  1. I have not yet memorized the names of the developer

  2. No other additional comments available


File info

File type: Markdown document (*.md *.mkd *.mdown *.markdown)

File version: 1 (2022, Tuesday, August 2nd at 8:30 pm PST)

Line count (including blank lines and compiler line): 172


File history

Click/tap here to expand/collapse the history for this file

Version 1 (2022, Tuesday, August 2nd at 8:30 pm PST)

Changes:

  • Started the file
  • Added the title section
  • Added the Hello World in Scala section
  • Added the Simple Hello World in Scala section
  • Added the Comments in Scala section
  • Added the Single line comments subsection
  • Added the Multi-line comments subsection
  • Added the break keyword in Scala section
  • Added the Classes in Scala section
  • Added the Functions in Scala section
  • Added the other knowledge of the Scala programming language section
  • Added the Additional comments section
  • Added the file info section
  • Added the file history section
  • No other changes in version 1