Scala from Scratch: Exploration
Minimum price
Suggested price

Scala from Scratch: Exploration

About the Book

Scala from Scratch: Exploration is the first in a series of two books that teach you the Scala programming language. Readers that have some experience with an object-oriented or imperative language, like Java, Ruby, or Python, will get a comprehensive overview of what Scala brings to the table. The goal is to get you excited about Scala and give you a strong foundation for writing your first applications and continuing your journey. By the end of the book, you will have a good idea of what it's like to work with Scala, and you will have written a small, but complete command-line application based on a Functional Core, Imperative Shell architecture.

In this book you will learn about functional and object-oriented aspects of Scala. You will learn how to write expressive, intent-revealing code using pattern matching, functional sequence processing and for comprehensions, and how to design data types that enforce their business invariants in a functional way, without throwing exceptions. You will get a first glimpse at Scala's powerful type system and how to abstract over concrete types, and you will learn all there is to know about working with Option, Scala's approach at avoiding the million dollar mistake of null references.

If you are excited and want to continue your journey, you will be able to do with the upcoming second book in the series, Scala from Scratch: Understanding, which will go even deeper into the topics explored in this book and will discuss advanced language features and patterns.

Community Copies

If you're a member of a marginalised community and can't afford to buy this book, feel free to claim one of the free community copies. Copies are limited, but I will add more whenever someone donates one.

There in currently 1 community copy available.

Donating a copy

If you would like to support members of a marginalised community who can't afford the book, please consider donating a community copy by choosing the Donate a Community copy package.


Have you read the book? I would be very grateful for reviews and ratings at the book's Goodreads page.

About the Author

Daniel Westheide
Daniel Westheide

Daniel Westheide is a software engineer living in Berlin, Germany. He is a senior consultant at INNOQ and co-organizer of ScalaBridge Berlin, the Berlin chapter of the ScalaBridge organization. He cares about empathy and inclusivity, and about the ethical, social, and ecological consequences of his work.

On his website, he discusses functional programming, architecture, as well as anything related to the software development process. He is not only interested in programming languages, but also a human language enthusiast. Moreover, he is passionate about specialty coffee, social science fiction, and tabletop roleplaying games.


The Book
  • PDF

  • EPUB

  • WEB

  • English

Minimum price
Suggested price
Donate a Community Copy

Get the ebook and donate a free community copy. This can then be claimed by a member of a marginalised community who can currently not afford purchasing a copy of this book or someone who cannot pay for this book for other reasons.

  • PDF

  • EPUB

  • WEB

  • English

Minimum price
Suggested price

Bundles that include this book

Bought separately
Bundle Price

About the Contributors

Ann-Marie Rechter
Ann-Marie Rechter

Freelance Illustrator and Designer

Ann-Marie is responsible for the cover illustration. She is a freelance illustrator and designer from Hamburg, Germany.

She regularly posts some of her artwork as illumarie_art on Instagram.

Table of Contents

  • Credits
  • Preface
  • 1. With a REPL yell
    • 1.1 What’s a REPL?
    • 1.2 Install fest
    • 1.3 Doing the math
    • 1.4 Greetings from Mr. Boole
    • 1.5 Values and variables
    • 1.6 The thin line between compile time and runtime
    • 1.7 Local type inference
    • 1.8 Calling methods
    • 1.9 Summary
  • 2. Scala, the functional language
    • 2.1 The purely functional way
    • 2.2 More about writing functions
    • 2.3 If-expressions
    • 2.4 Functions as values
    • 2.5 Escaping the loop
    • 2.6 Summary
  • 3. Scala, the object-oriented language
    • 3.1 Classes and objects
    • 3.2 Singleton objects
    • 3.3 Visibility modifiers
    • 3.4 Traits
    • 3.5 Everything is an object
    • 3.6 Am I equal? Yes I am!
    • 3.7 Summary
  • 4. Scala, the expressive language
    • 4.1 Named and default arguments
    • 4.2 A first glance at pattern matching
    • 4.3 Case classes
    • 4.4 Tuples
    • 4.5 Processing sequences, the functional way
    • 4.6 More sugar with for comprehensions
    • 4.7 Type aliases
    • 4.8 No strings attached
    • 4.9 Summary
  • 5. Tools for modular code
    • 5.1 Inner classes, objects, and traits
    • 5.2 Packages
    • 5.3 Imports
    • 5.4 Package-level visibility modifiers
    • 5.5 Package objects
    • 5.6 Summary
  • 6. Bringing value to your classes
    • 6.1 Value classes
    • 6.2 Extension methods
    • 6.3 Summary
  • 7. Scala type system 101
    • 7.1 Type constructors
    • 7.2 Polymorphic methods
    • 7.3 Polymorphic extension methods
    • 7.4 Summary
  • 8. The strict brown fox jumps over the lazy dog
    • 8.1 By-name parameters
    • 8.2 Lazy values
    • 8.3 Summary
  • 9. Know your options
    • 9.1 The basic idea
    • 9.2 Creating an option
    • 9.3 Working with optional values
    • 9.4 Options are collections
    • 9.5 For comprehensions
    • 9.6 Chaining options
    • 9.7 Purely functional data types
    • 9.8 Option in the standard library
    • 9.9 Summary
  • 10. Putting it all together
    • 10.1 Talking to the product owner
    • 10.2 Architectural decisions
    • 10.3 Setting up the project
    • 10.4 The functional core
    • 10.5 The imperative shell
    • 10.6 Packaging the application
    • 10.7 Summary
  • 11. Downtime
    • 11.1 Summary
    • 11.2 The road ahead
    • 11.3 Taking action
  • Notes

The Leanpub 60 Day 100% Happiness Guarantee

Within 60 days of purchase you can get a 100% refund on any Leanpub purchase, in two clicks.

Now, this is technically risky for us, since you'll have the book or course files either way. But we're so confident in our products and services, and in our authors and readers, that we're happy to offer a full money back guarantee for everything we sell.

You can only find out how good something is by trying it, and because of our 100% money back guarantee there's literally no risk to do so!

So, there's no reason not to click the Add to Cart button, is there?

See full terms...

80% Royalties. Earn $16 on a $20 book.

We pay 80% royalties. That's not a typo: you earn $16 on a $20 sale. If we sell 5000 non-refunded copies of your book or course for $20, you'll earn $80,000.

(Yes, some authors have already earned much more than that on Leanpub.)

In fact, authors have earnedover $12 millionwriting, publishing and selling on Leanpub.

Learn more about writing on Leanpub

Free Updates. DRM Free.

If you buy a Leanpub book, you get free updates for as long as the author updates the book! Many authors use Leanpub to publish their books in-progress, while they are writing them. All readers get free updates, regardless of when they bought the book or how much they paid (including free).

Most Leanpub books are available in PDF (for computers) and EPUB (for phones, tablets and Kindle). The formats that a book includes are shown at the top right corner of this page.

Finally, Leanpub books don't have any DRM copy-protection nonsense, so you can easily read them on any supported device.

Learn more about Leanpub's ebook formats and where to read them

Write and Publish on Leanpub

You can use Leanpub to easily write, publish and sell in-progress and completed ebooks and online courses!

Leanpub is a powerful platform for serious authors, combining a simple, elegant writing and publishing workflow with a store focused on selling in-progress ebooks.

Leanpub is a magical typewriter for authors: just write in plain text, and to publish your ebook, just click a button. (Or, if you are producing your ebook your own way, you can even upload your own PDF and/or EPUB files and then publish with one click!) It really is that easy.

Learn more about writing on Leanpub