O'Reilly logo
live online training icon Live Online training

Learn the basics of Scala in 3 hours

From variables and methods to higher-order functions

Daniel Hinojosa

Scala is an amazing language that has propelled the JVM into the functional world. It's the language that created Spark, Kafka, Akka, Samza, Play, and Finagle, and its conciseness, expressiveness, and vast list of operations have made it one of the preferred languages in big data and messaging.

Daniel Hinojosa leads a fast-paced look at Scala, helping you hit the ground running with the language. Daniel covers key concepts, such as manipulating variables and string formatting, before jumping into objects, classes, and functions. Within the first 30 minutes, you’ll create a script and a runnable application. You'll leave with a firm understanding of Scala basics, preparing you for deeper dives into the language.

What you'll learn-and how you can apply it

By the end of this live online course, you’ll understand:

  • How to create a project using Scala
  • Fundamental Scala concepts, such as manipulating variables and string formatting and interpolation
  • How to use Scala objects and classes
  • How Scala functions bring everything together

And you’ll be able to:

  • Write basic Scala code that’s concise and readable
  • Think functionally rather than imperatively
  • Begin working with Scala in your own projects

This training course is for you because...

  • You're interested in learning Scala and want exposure to fundamental concepts and a roadmap for further learning.
  • You currently develop in another functional language and are interested in how Scala handles similar constructs.
  • You want to know if Scala is something that will work for your team’s next project.

Prerequisites

  • A basic understanding of a modern programming language (e.g., Java, Ruby, Python, C, C++, C#, or Perl)

Materials or downloads needed in advance:

No setup is needed. We will use scastie.scala-lang.org and dive right into the basics of the language.

Recommended preparation:

Recommended follow-up:

About your instructor

  • Daniel Hinojosa is an instructor, speaker, recent author, programmer, and consultant with over 20 years of experience working with private, educational, and government institutions. He is also currently a speaker on the No Fluff Just Stuff tour. Daniel loves JVM languages like Java, Groovy, and Scala, but he also dabbles with non-JVM languages like Haskell, Ruby, Python, Lisp, C, and C++. He is an avid Pomodoro Technique practitioner and attempts to learn a new programming language every year. Daniel is the author of Testing in Scala and the video Beginning Scala Programming as well as the teacher of a line of training courses, all for O’Reilly. In his downtime, he enjoys reading, swimming, playing with Legos, and cooking.

Schedule

The timeframes are only estimates and may vary according to how the class is progressing

Introduction (5 minutes)

  • Lecture: Scala overview; Scala's benefits; Scala's disadvantages

Hitting the ground running (15 minutes)

  • Lecture: Creating a script; creating a runnable application; using the REPL

Scala basics (15 minutes)

  • Lecture: 'val' and 'var'; manipulating variables; Byte, Short, Int, Long, Float, Boolean, Double, and Char; if, else if, else, while, do while, for-loops; string formatting and interpolation; Any, AnyVal, AnyRef

Scala methods (25 minutes)

  • Lecture Scala methods; Scala Unit
  • Hands-on exercises: Colliding types; isPrime

Break (10 minutes)

Scala type hierarchy (10 minutes)

  • Lecture on the new type hierarchy in Scala
  • Hands-on exercise: Polymorphism

Scala Option (10 minutes)

  • Lecture: Option and its children—Some and None

Scala Object (10 minutes)

  • Lecture: Singletons; companion objects
  • Hands-on exercise: Trying out an Object

Scala Unit (10 minutes)

  • Lecture: Unit

Scala magical DSL tricks (10 minutes)

  • Lecture: Infix methods; the magic apply method; right associative colons
  • Hands-on exercise: Creating and manipulating a list

Break (10 minutes)

Scala classes (10 minutes)

  • Lecture: Scala classes; case classes

Scala tuples (5 minutes)

  • Lecture: Scala tuples

Scala functions (25 minutes)

  • Lecture: Creating and understanding functions; using functions within collections
  • Hands-on exercises: Closure by example; doing a better isPrime