Scala code and the Scala interpreter

Introduction to Scala

David Venturi

Curriculum Manager, DataCamp

What is Scala?

Scala is a general-purpose programming language providing support for functional programming and a strong static type system. Designed to be concise, many of Scala's design decisions aimed to address criticisms of Java.

Scala source code is intended to be compiled to Java bytecode, so that the resulting executable code runs on a Java virtual machine.

Introduction to Scala

What is Scala?

Scala combines object-oriented and functional programming in one concise, high-level language. Scala's static types help avoid bugs in complex applications, and its JVM and JavaScript runtimes let you build high-performance systems with easy access to huge ecosystems of libraries.

https://www.scala-lang.org/

Introduction to Scala

Scala fuses OOP and FP

Scala combines object-oriented and functional programming

Introduction to Scala

Scala fuses OOP and FP -> Scala is scalable

Scala combines object-oriented and functional programming

Introduction to Scala

Scala fuses OOP and FP -> Scala is scalable

Scala combines object-oriented and functional programming

Scala is object-oriented

  • Every value is an object
  • Every operation is a method call
val sumA = 2 + 4
sumA: Int = 6
Introduction to Scala

Scala fuses OOP and FP -> Scala is scalable

Scala combines object-oriented and functional programming

Scala is object-oriented

  • Every value is an object
  • Every operation is a method call
val sumA = 2.+(4)
sumA: Int = 6
Introduction to Scala

Scala fuses OOP and FP -> Scala is scalable

Scala combines object-oriented and functional programming

Scala is functional

  1. Functions are first-class values
Introduction to Scala

Scala fuses OOP and FP -> Scala is scalable

Scala combines object-oriented and functional programming

Scala is functional

  1. Functions are first-class values
  2. Operations of a program should map input values to output values rather than change data in place
Introduction to Scala

More answers to "Why use Scala?"

Introduction to Scala

More answers to "Why use Scala?"

Scala combines object-oriented and functional programming in one concise

Introduction to Scala

More answers to "Why use Scala?"

Scala combines object-oriented and functional programming in one concise, high-level language.

Introduction to Scala

More answers to "Why use Scala?"

Scala combines object-oriented and functional programming in one concise, high-level language. Scala's static types help avoid bugs in complex applications

Introduction to Scala

More answers to "Why use Scala?"

Scala combines object-oriented and functional programming in one concise, high-level language. Scala's static types help avoid bugs in complex applications, and its JVM and JavaScript runtimes let you build high-performance systems with easy access to huge ecosystems of libraries.

Introduction to Scala

The Scala interpreter

$ scala
Welcome to Scala 2.12.7.
Type in expressions for evaluation. Or try :help.
scala>
1 http://bit.ly/scala_repl
Introduction to Scala

The Scala interpreter

$ scala
Welcome to Scala 2.12.7.
Type in expressions for evaluation. Or try :help.
scala> 2 + 3
res0: Int = 5
res0 * 2
res1: Int = 10
1 http://bit.ly/scala_repl
Introduction to Scala

The Scala interpreter

scala> println("Let's play Twenty-One!")
Let's play Twenty-One!

Ace of spades and jack of spades

1 http://bit.ly/scala_repl
Introduction to Scala

Let's practice!

Introduction to Scala

Preparing Video For Download...