The Artima Developer Community

Programming in Scala cover

Fifth Edition
PrePrint™ Version 5
May 13, 2021
636 pages (eBook)

Programming in Scala, Fifth Edition (PrePrint™)
A comprehensive step-by-step guide
Updated for Scala 3!

by Martin Odersky, Lex Spoon, Bill Venners, and Frank Sommers

This book is the authoritative tutorial on the Scala programming language, co-written by the language's designer, Martin Odersky. This fifth edition is a major rewrite of the entire book, adding new material to cover the many changes in Scala 3.0. In fact we have added so much new material that we split the book into two volumes. This volume is a tutorial of Scala and functional programming. The second volume, which will be released as a PrePrint™ soon, is a deep dive into advanced aspects of Scala 3. The changes and new features covered in this version of this PrePrint™ include:

  • Quiet (indentation-sensitive) control syntax
  • Intersection and union types
  • Enums and Algebraic Data Types (ADTs)
  • Context parameters and given instances (the new approach to implicit parameters)
  • Trait parameters
  • Creator applications
  • New vararg pattern syntax
  • Extension methods

This edition of the book is complete except for a few finishing touches. We expect to release a final version of the eBook before the end of May, 2021, and that the paper book will ship in June. This PrePrint™ early access program will allow you to learn about Scala 3 from the source and provide helpful feedback to the authors that will make the book even better.

If you purchase just the eBook for $28.95, you will be entitled to receive periodic updates as the authors complete the book, as well as the final eBook when the book is finished, for no additional charge. If you purchase eBook + Paper Book combo for $66.95, you will be entitled to the PDF eBook updates, and we'll ship you the paper book when it is published, on or around June 15, 2021. (Once the book has been printed, you'll be able to purchase just the paper book here for $49.95.)

Buy It Now

Quantity Volume

About the book

The fifth edition of Programming in Scala is now available in PrePrint™ form! This book is the authoritative tutorial on the Scala programming language, co-written by the language's designer Martin Odersky.

The Scala language, which blends object-oriented and functional programming concepts, has been exploding in popularity in recent years. This book is a comprehensive, step-by-step guide to learning Scala. If you're a programmer wanting to do your next software project in Scala, looking to expand your horizons by learning new concepts, or currently using Java and want to expand your knowledge of functional programming—or all of the above—then this book is for you.

Table of contents

What Readers are Saying
List of Figures
List of Tables
List of Listings
1. A Scalable Language
2. First Steps in Scala
3. Next Steps in Scala
4. Classes and Objects
5. Basic Types and Operations
6. Functional Objects
7. Built-in Control Structures
8. Functions and Closures
9. Control Abstraction
10. Composition and Inheritance
11. Traits
12. Packages, Imports, and Exports
13. Pattern Matching
14. Working with Lists
15. Working with Other Collections
16. Mutable Objects
17. Scala's Hierarchy
18. Type Parameterization
19. Enums
20. Abstract Members
21. Givens
22. Extension Methods
23. Typeclasses
24. Assertions and Tests
About the Authors

About the authors

Martin Odersky is the creator of the Scala language. He is a professor at EPFL in Lausanne, Switzerland, and a founder of Lightbend, Inc. He works on programming languages and systems, more specifically on the topic of how to combine object-oriented and functional programming. Since 2001 he has concentrated on designing, implementing, and refining Scala. Previously, he has influenced the development of Java as a co-designer of Java generics and as the original author of the current javac reference compiler. He is a fellow of the ACM.

Lex Spoon is a software engineer at Semmle, Ltd. He worked on Scala for two years as a post-doc at EPFL. He has a Ph.D. from Georgia Tech, where he worked on static analysis of dynamic languages. In addition to Scala, he has helped develop a wide variety of programming languages, including the dynamic language Smalltalk, the scientific language X10, and the logic language that powers Semmle. He and his wife live in Atlanta with two cats and a chihuahua.

Bill Venners is president of Artima, Inc., publisher of the Artima Developer website ( He is author of the book, Inside the Java Virtual Machine, a programmer-oriented survey of the Java platform's architecture and internals. His popular columns in JavaWorld magazine covered Java internals, object-oriented design, and Jini. Active in the Jini Community since its inception, Bill led the Jini Community's ServiceUI project, whose ServiceUI API became the de facto standard way to associate user interfaces to Jini services. Bill is a community representative on the Scala Center advisory board, and is the lead developer and designer of the ScalaTest testing framework and the Scalactic library for functional, object-oriented programming.

Frank Sommers is founder and president of Autospaces, Inc, a company providing workflow automation solutions to the financial services industry. Frank has been an active Scala user for over twelve years, and has worked with the language daily ever since.

The first edition of Programming in Scala won the 2009 Jolt Productivity Award in the Technical Books category.

Praise for the earlier editions

Programming in Scala is clearly written, thorough, and easy to follow. It has great examples and useful tips throughout. It has enabled our organization to ramp up on the Scala language quickly and efficiently. This book is great for any programmer who is trying to wrap their head around the flexibility and elegance of the Scala language.

- Larry Morroni, Owner, Morroni Technologies, Inc.

The Programming in Scala book serves as an excellant tutorial to the Scala language. Working through the book, it flows well with each chapter building on concepts and examples described in earlier ones. The book takes care to explain the language constructs in depth, often providing examples of how the language differs from Java. As well as the main language, there is also some coverage of libraries such as containers and actors.

I have found the book really easy to work through, and it is probably one of the better written technical books I have read recently. I really would recommend this book to any programmer wanting to find out more about the Scala language.

- Matthew Todd

I am amazed by the effort undertaken by the authors of Programming in Scala. This book is an invaluable guide to what I like to call Scala the Platform: a vehicle to better coding, a constant inspiration for scalable software design and implementation. If only I had Scala in its present mature state and this book on my desk back in 2003, when co-designing and implementing parts of the Athens 2004 Olympic Games Portal infrastructure!

To all readers: No matter what your programming background is, I feel you will find programming in Scala liberating and this book will be a loyal friend in the journey.

- Christos KK Loverdos, Software Consultant, Researcher

Programming in Scala is a superb in-depth introduction to Scala, and it's also an excellent reference. I'd say that it occupies a prominent place on my bookshelf, except that I'm still carrying it around with me nearly everywhere I go.

- Brian Clapper, President, ArdenTex, Inc.

I bought an early electronic version of the Programming in Scala book, by Odersky, Spoon, and Venners, and I was immediately a fan. In addition to the fact that it contains the most comprehensive information about the language, there are a few key features of the electronic format that impressed me. I have never seen links used as well in a PDF, not just for bookmarks, but also providing active links from the table of contents and index. I don't know why more authors don't use this feature, because it's really a joy for the reader. Another feature which I was impressed with was links to the forums ("Discuss") and a way to send comments ("Suggest") to the authors via email. The comments feature by itself isn't all that uncommon, but the simple inclusion of a page number in what is generated to send to the authors is valuable for both the authors and readers. I contributed more comments than I would have if the process would have been more arduous.

Read Programming in Scala for the content, but if you're reading the electronic version, definitely take advantage of the digital features that the authors took the care to build in!

- Dianne Marsh, Founder/Software Consultant, SRT Solutions

Great book, well written with thoughtful examples. I would recommend it to both seasoned programmers and newbies.

- Howard Lovatt

The book Programming in Scala is not only about ‘How?,’ but more importantly about ‘Why?’ to develop programs in this new programming language. The book’s pragmatic approach in introducing the power of combining object-oriented and functional programming leaves the reader without any doubts as to what Scala really is.

- Dr. Ervin Varga, CEO/founder, EXPRO I.T. Consulting

This is a great introduction to functional programming for OO programmers. Learning about FP was my main goal, but I also got acquainted with some nice Scala surprises like case classes and pattern matching. Scala is an intriguing language and this book covers it well.

There's always a fine line to walk in a language introduction book between giving too much or not enough information. I find Programming in Scala to achieve a perfect balance.

- Jeff Heon, Programmer Analyst

Lucidity and technical completeness are hallmarks of any well-written book, and I congratulate Martin Odersky, Lex Spoon, and Bill Venners on a job indeed very well done! The Programming in Scala book starts by setting a strong foundation with the basic concepts and ramps up the user to an intermediate level & beyond. This book is certainly a must buy for anyone aspiring to learn Scala.

- Jagan Nambi, Enterprise Architecture, GMAC Financial Services

The book Programming in Scala outright oozes the huge amount of hard work that has gone into it. I've never read a tutorial-style book before that accomplishes to be introductory yet comprehensive: in their (misguided) attempt to be approachable and not "confuse" the reader, most tutorials silently ignore aspects of a subject that are too advanced for the current discussion. This leaves a very bad taste, as one can never be sure as to the understanding one has achieved. There is always some residual "magic" that hasn't been explained and cannot be judged at all by the reader. This book never does that, it never takes anything for granted: every detail is either sufficiently explained or a reference to a later explanation is given. Indeed, the text is extensively cross-referenced and indexed, so that forming a complete picture of a complex topic is relatively easy.

- Gerald Loeffler, Enterprise Java Architect

Programming in Scala is a pleasure to read. This is one of those well-written technical books that provide deep and comprehensive coverage of the subject in exceptionally concise and elegant manner.

The book organized in a very natural and logical way. It is equally well suited for a curious technologist who just wants to stay on top of the current trends and a professional seeking deep understanding of the language core features and its design rationales. I highly recommend it to all interested in functional programming in general. For the Scala developers, this book is unconditionally a must-read.

- Igor Khlystov, Software Architect/Lead Programmer, Greystone Inc.

Programming in Scala is probably one of the best programming books I've ever read. I like the writing style, the brevity, and the thorough explanations. The book seems to be answer every question as it enters my mind&emdash;it's always one step ahead of me. The authors don't just give you some code and take things for granted. They give you the meat so you really understand what's going on. I really like that.

- Ken Egervari, Chief Software Architect

Programming in Scala by Martin Odersky, Lex Spoon, and Bill Venners: in times where good programming books are rare, this excellent introduction for intermediate programmers really stands out. You’ll find everything here you need to learn this promising language.

- Christian Neukirchen

Copyright © 2021 Artima, Inc. All rights reserved.