O'Reilly logo
live online training icon Live Online training

Learn the Basics of Scala in 3 hours

From tool setup and variable methods to higher-order functions and common functions like map, filter, and flatMap

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 a 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

  • 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:
- A machine with the latest JDK 8 or JDK 9, Scala, the latest IntelliJ or Eclipse with the Scala and Scala-IDE plugins, and SBT installed and set up

Recommended preparation:
- "Why Is Scala So Popular?" (article)
- Scala School Basics (website)
- A Scala Tutorial for Java Programmers (tutorial)

Recommended follow-up:
- Functional Programming in Scala
- Scala School

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 (25 minutes)
- Lecture and hands-on exercises: Creating a script; creating a runnable application; using the REPL

Scala basics (25 minutes)
- Lecture and hands-on exercises: '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

Break (10 minutes)

Scala methods (30 minutes)
- Lecture and hands-on exercises: Scala methods; Scala Unit

Scala Option (10 minutes)
- Lecture and hands-on exercises: Some; None

Scala Object (15 minutes)
- Lecture and hands-on exercises: Singletons; companion objects

Break (10 minutes)

Scala magical DSL tricks (10 minutes)
- Lecture and hands-on exercises: Infix methods; the magic apply method; right associative colons

Scala classes (10 minutes)
- Lecture and hands-on exercises: Scala classes; case classes

Scala tuples (15 minutes)
- Lecture and hands-on exercises: Scala tuples

Scala functions (15 minutes)
- Lecture and hands-on exercises: Creating and understanding functions; using functions within collections