Scala For Beginners
Scala For Beginners
About the Book
Who Should Read This Book
This book is designed from the ground up with the complete beginner in mind, as well as focusing on day-to-day real-world Scala programming especially within an enterprise context. Therefore, you will find that this book contains more than enough of the basics, in addition to the practical stuff - and of course the content is introduced in a step-by-step way.
This book is also a great guide for experienced programmers from different backgrounds, such as, Java, .NET, C++, and others. It is outright true whilst working in large enterprise projects - whose ecosystem typically comprises of numerous programming languages - and as a result you may need to get up to speed fast so as to work on a Scala project, or alongside a Scala team.
Likewise, data scientists and big data engineers who already code in, say, Python, R, or Java, will have a better understanding of Scala in general and its development environment. This increased awareness will no doubt help to interface with a number of tools from the Scala ecosystem, such as, Apache Spark - a popular big data technology for data analytics, and machine learning.
Naturally, this book is equally intended for the typical programmer, or student, or anyone who wants to quickly learn a modern programming language such as Scala.
Book Structure and Content Organization
The chapters in this book are organized in such a way to gradually and incrementally learn Scala. In fact, each section is logically ordered with a fast-track, or crash course, perspective, such that you can get familiar with Scala in just about 7 days. Nevertheless, it goes without saying that the 7 days time frame is somewhat arbitrary, and will very much depend on your experience level and time commitment. Needless to say that you can skip certain chapters if you are already aware with the content, or decide to follow along, or cherry-pick specific sections, or even carry on at your own pace.
It is worth mentioning, though, that each chapter provides a natural ordering to help you easily build-up your knowledge of the various Scala features. For instance, you will be shown how to use Pattern Matching before being able to apply it within, say, a map(), or a flatMap() function. Of course, I would not recommend cramming the content in just one day - having said that, you can do the whole thing in a short amount of time. The best thinking however is to take the first leap and get started!
In the first chapter - Day One: Scala Overview, Development Environment, And Essentials - you will be provided with a general overview of the Scala programming language, along with step-by-step instructions for setting up your Scala coding environment. You will then be introduced to some of the essential components as prerequisites for the upcoming chapters.
In the second chapter - Day Two: Learn Functions, Classes and Objects - you will create and use functions, classes and objects. Generally speaking, the features that we illustrate in this chapter will somewhat form a large part in your typical day-to-day Scala coding.
In the third chapter - Day Three: Learn Traits, and Akka HTTP Scala Single Project - you will be introduced to traits, and how to use sbt (the build tool for Scala), and begin to create a real-world Scala application.
In the fourth chapter - Day Four: Scala's Immutable and Mutable collections - we start off by reviewing some of the basic data structures in computer science, and then proceed with numerous examples in using Scala's Immutable and Mutable collections.
In the fifth chapter - Day Five: Scala's Ready To Use Collection Functions - we go over the wide range of functions, which Scala provides out-of-the-box to facilitate the everyday interactions with collection data structures.
In the sixth chapter - Day Six: Asynchronous Programming, and Testing Your Scala Application - you will make use of Scala Futures for writing non-blocking code. It will also be time to introduce ScalaTest - a prominent tool for testing Scala applications.
In the final seventh chapter - Day Seven: Your Step-By-Step Scala Application - we put together a Scala application from the concepts that we've learned in this book. In particular, the Scala application will be a multi-project, which is quintessential to most enterprise platforms by having various parts of the system encapsulated in small, and reusable, projects.
Acknowledgements
I would like to take this opportunity to express my sincere appreciation to all the readers at our http://allaboutscala.com blog for their invaluable feedback and comments over the past years. These have greatly shaped up the structure of this book to take into account the true beginner who wants to quickly learn Scala.
Reader Testimonials
Below is what our readers are saying about the tutorials at http://allaboutscala.com
Nadim, your articles are great. I’m on my way to learn Scala and surely this site will be one of my sources. Thank you!
Vinicius Abreu
Thanks for these Nadim Bahadoor! - I find them very valuable!!
Kevin Lawrence
Thanks a lot!!! It saved me !!
Syed Saad
I have to concur with Tree_Ed on that compliment. Especially appreciated is that you take into account the true beginner, not taking for granted anything that we might already know. I have been doing database development for 30 years, and wanted to get to know scala on my way to getting to know spark. These tutorials are excellent and thanks Nadim!
Vic Kirkpatrick
Best tutorials found so far. Thanks for writing in a simple way.
Nikhil Jaitak
Your all articles are good
Vivek Kale
One of the best online tutorial about Scala...I love it ..Im from Python Back around..Fantastic job mr.Author of the site..Looking fwd your real time proj explanation and your book as well, I m going to recommend your site to my friends and scala beginners ... Good job...
Baranidharan Ragupathi
Fantastic site - really useful for someone like me coming from python, C and C#. So many of the tutorials I have seen assume a java background but the tutorials here make it really easy for me to get into the meat of scala. I'm looking forward to the book!
Steve Gailey
Thank you for the content! Having completed most of the chapters, I think it was one of the best learning experiences for me!
Daniel Stoica
This is one stop place for learning spark and scala. Waiting for kafka tutorial eagerly :)
Debashish Das
Table of Contents
-
Preface
- Who Should Read This Book
- Book Structure and Content Organization
- Prerequisites, Source Code and Notation
- What We Do Not Cover
- About The Author
- Acknowledgements
- Contact
- Day One: Scala Overview, Development Environment, And Essentials
- Day One: Introduction
-
Day One: General Overview Of Scala
- What Is Scala?
- How Do Scala Applications Run?
- Scala Features
-
Day One: Setup Scala Development Environment
- Install Java Development Kit (JDK)
- Install IntelliJ IDEA
- Install IntelliJ’s Scala Plugin
- Install SBT
-
Day One: Getting Familiar With IntelliJ IDEA
- Your First Hello World Scala Application
- Scala Project Structure And Classpath
- Hello World With Arguments
- Hello World With Main Method
- Debugging Your Scala Application
- Importing External Libraries Using sbt
- IntelliJ Settings And Preferences
- IntelliJ Keyboard Shortcuts
-
Day One: Introducing The Core Scala Essentials
- Values, Variables And Types
- Scala’s Class And Type Hierarchy
- Scala Type Inference
- String Interpolation
- Comments, Escape Characters And Multi-Line String
- If And Else
- Range
- For Comprehension And Loops
- Pattern Matching
- Tuples
- Option
- Your First Scala Class
- Bringing Together Scala And Java Code
- Day One: Summary
- Day Two: Learn Functions, Classes and Objects
- Day Two: Introduction
-
Day Two: Functions
- Create and Use Functions
- Functions Fun: Variable Args, Symbols, Partially Applied, Nested
- Higher Order Functions
- Value Functions and Composition
- Partial Functions And Composition
- Function Polymorphism
- Functions and Options
- Recursive Functions
-
Day Two: Classes and Objects
- Classes and Inheritance
- Case Class And Type Alias
- Extend An Abstract Class And A Case Class
- Singleton And Package Objects
- Implicit Function, Implicit Class And Package Object
- Type Parameters: Covariance, Contravariance, Invariance
- Type Bounds
- Day Two: Summary
- Day Three: Learn Traits And Akka HTTP Scala Single Project
- Day Three: Introduction
-
Day Three: Traits
- Extend A Trait
- A Trait With Type Parameter
- Extend Multiple Traits
- Built-in Dependency Injection
- Dependency Injection With A Single Façade
- Trait Mixin And Linearization
- Enums And Algebraic Data Types (ADT)
- Traits, Companion Object, And The Factory Pattern
- Type Class For Ad-hoc Polymorphism
- The Magnet Pattern For Type-Safe Overloaded Methods
- Challenge: The Functor Trait From Cats
-
Day Three: Akka HTTP Scala Single Project
- Objectives
- Create A Scala Project In IntelliJ IDEA
- build.sbt
- Package Structure
- Bootstrapping Akka HTTP Server
- Akka HTTP Routes
- Configurations
- Logging
- REST Endpoints
- Day Three: Summary
- Day Four: Scala’s Immutable and Mutable Collections
- Day Four: Introduction
- Day Four: Review Of Basic Data Structures
-
Day Four: Immutable Collections
- List
- ListSet
- ListMap
- Map
- HashMap
- TreeMap
- SortedMap
- Queue
- Sequence
- Set
- HashSet
- TreeSet
- SortedSet
- BitSet
- Stack
- Stream
- Vector
-
Day Four: Mutable Collections
- Array
- ArrayBuffer
- Stack
- ListBuffer
- Map
- HashMap
- ListMap
- LinkedHashMap
- Queue
- PriorityQueue
- Set
- HashSet
- SortedSet
- TreeSet
- LinkedHashSet
- BitSet
- Day Four: Summary
- Day Five: Scala’s Ready To Use Collection Functions
- Day Five: Introduction
- Day Five: Scala 2.13 Collection Redesign
-
Day Five: Collection Functions
- collect
- diff
- drop
- dropWhile
- exists
- filter And filterNot
- find
- flatMap
- flatten
- fold
- foldLeft
- foldRight
- foreach
- groupBy
- head
- isEmpty
- intersect
- last
- map
- max
- maxBy
- min
- minBy
- mkString
- nonEmpty
- par
- aggregate
- partition
- reduce
- reduceLeft
- reduceRight
- reverse
- reverseIterator
- scan
- scanLeft
- scanRight
- size
- slice
- sortBy
- sorted
- sortWith
- tail
- take
- takeRight
- takeWhile
- transpose
- union
- unzip
- unzip3
- view
- withFilter
- zip And zipAll
- zipWithIndex
- Day Five: Summary
- Day Six: Asynchronous Programming And Testing Your Scala Application
- Day Six: Introduction
-
Day Six: Asynchronous Programming
- Using The Future Type For Asynchronous Computation
- Configure Thread Pools
- Handling Of Failures When Using Future
- Linking Up Transformations With Future
- Chaining Future
- Many Futures In Parallel
- Practical Extra Future Functions
- Future and Promise
-
Testing Your Scala Application
- Using ScalaTest
- Day Six: Summary
- Day Seven: Your Step-By-Step Scala Application
- Day Seven: Introduction
-
Day Seven: Akka HTTP Scala Single Project
- Objectives
- Donut ADT And JSON Support
- Data API
- CRUD REST Endpoints
- Client Application
- Running The Application
-
Day Seven: Akka HTTP Scala Multi-Project
- Objectives
- Project Structure
- build.sbt
- Common Sub-Project
- Config Sub-Project
- Data Sub-Project
- HttpClient Sub-Project
- HttpServer Sub-Project
- Running The Application
- Sbt Command Line Fun With Multi-Project
- Day Seven: Summary
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...
Earn $8 on a $10 Purchase, and $16 on a $20 Purchase
We pay 80% royalties on purchases of $7.99 or more, and 80% royalties minus a 50 cent flat fee on purchases between $0.99 and $7.98. You earn $8 on a $10 sale, and $16 on a $20 sale. So, if we sell 5000 non-refunded copies of your book for $20, you'll earn $80,000.
(Yes, some authors have already earned much more than that on Leanpub.)
In fact, authors have earnedover $13 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