See: Hello, Scala: Learn Scala fast with small, easy lessons, by Alvin Alexander, Publisher : CreateSpace Independent Publishing Platform (September 8, 2018)
- https://smile.amazon.com/Hello-Scala-Learn-small-lessons-ebook/dp/B079WK8P1X
- https://alvinalexander.com/misc/how-to-learn-scala-cheaply-freely-books-resources
- https://alvinalexander.com/hello-scala
Update: In July, 2021, the price of this Kindle book has been drastically reduced so you can learn Scala as inexpensively as possible.
In his latest book, Alvin Alexander, author of the Scala Cookbook and Functional Programming, Simplified, brings you a swift introduction to the Scala programming language. In a little over 200 fast-paced pages, Mr. Alexander demonstrates that Scala is a beautiful, modern, expressive programming language. The book is broken down into 56 short chapters to help you easily find what you need. Lessons include:
- An introduction to Scala’s two types of variables, `val` and `var`
- Scala control structures, including powerful `for` expressions and `match` expressions
- An overview of Scala collections classes and methods
- Object-oriented programming (OOP), including features of Scala classes and methods
- Functional programming (FP), including pure functions, using functions as variables, case classes, match expressions, functional error handling, and more
- Modular programming with traits
- How to build Scala projects with SBT
- How to write TDD and BDD unit tests with ScalaTest
- Programming concurrency with Akka actors and Scala futures
To help get you started with Scala as fast as possible, the book shares many source code examples, including several open source Github projects that you can run immediately. All examples in the book have been written with Scala 2.12, and represent 2018’s “best practices” for Scala programming.
About the Author
Alvin took the circuitous route to software development. He managed to get a degree in Aerospace Engineering from Texas A&M University, while all he was really trying to do was play baseball. Once he became a practicing engineer, he realized he liked software and programming more than engineering. So in approximate order he taught himself Fortran, C, Unix, network administration, sed, awk, Lisp, Perl, Java, JavaScript, Python, Ruby, JRuby, PHP, and Scala. During this process he started a software consulting firm, grew it to fifteen people, sold it, and moved to Alaska. After returning to the “Lower 48,” he self-published two books (“How I Sold My Business: A Personal Diary”, and “Zen and the Art of Consulting”), and then wrote the “Scala Cookbook” for O’Reilly. He also created alvinalexander.com, which receives millions of page views every year.
Table of Contents:
Table of Contents
Copyright
Preface
Prelude: A Taste of Scala
Getting started
The Scala Programming Language
Hello, World
Hello, World (Version 2)
The Scala REPL
Two Types of Variables
The Type is Optional
A Few Built-In Types
Two Notes About Strings
Command-Line I/O
Control Structures
The if/then/else Construct
for Loops
for Expressions
match Expressions
try/catch/finally Expressions
Classes
Auxiliary Class Constructors
Supplying Default Values for Constructor Parameters
A First Look at Methods
Enumerations (and a Complete Pizza Class)
Traits and Abstract Classes
Using Traits as Interfaces
Using Traits Like Abstract Classes
Abstract Classes
Collections Classes
ArrayBuffer Class
List Class
Vector Class
Map Class
Set Class
Anonymous Functions
Common Methods on Sequences
Common Map Methods
A Few Miscellaneous Items
Tuples
Scala and Swing
An OOP Example
A Scala + JavaFX Example
SBT and ScalaTest
The Scala Build Tool (SBT)
Using ScalaTest with SBT
Writing BDD-style tests with ScalaTest and SBT
Functional Programming
Pure Functions
Passing Functions Around
No Null Values
Companion Objects
Case Classes
Case Objects
Functional Error Handling
Concurrency
Akka Actors
Akka Actor Examples
Futures
Summary
Preface:
- Preface
Have you ever fallen in love with a programming language? I still remember when I first saw the book, The C Programming Language, and how I fell in love with its simple syntax and the ability to interact with a computer at a low level. In 1996 I loved Java because it made OOP simple. A few years later I found Ruby and loved its elegance.
Then in 2011 I was aimlessly wandering around Alaska and stumbled across the book, Programming in Scala, and I was stunned by its remarkable marriage of Ruby and Java:
The syntax was as elegant and concise as Ruby
It feels dynamic, but it’s statically typed
It compiles to class files that run on the JVM
You can use the thousands of Java libraries in existence with your Scala code
In the first edition of the book, Beginning Scala, David Pollak states that Scala will change the way you think about programming, and that’s a good thing. Learning Scala has not only been a joy, but it’s led me on a journey to appreciate concepts like modular programming, immutability, referential transparency, and functional programming, and most importantly, how those ideas help to dramatically reduce bugs in my code.
Is Scala DICEE?
DICEE is an acronym that was coined by Guy Kawasaki, who became famous as a developer evangelist for the original Apple Macintosh team. He says that great products are DICEE, meaning Deep, Indulgent, Complete, Elegant, and Emotive:
Deep: The product doesn’t run out of features and functionality after a few weeks of use. Its creators have anticipated what you’ll need once you come up to speed. As your demands get more sophisticated, you won’t need a different product.
Indulgent: A great product is a luxury. It makes you feel special when you buy it (and use it).
Complete: A great product is more than a physical thing. Documentation counts. Customer service counts. Tech support counts.
Elegant: A great product has an elegant user interface. Things work the way you’d think they would. A great product doesn’t fight you, it enhances you.
Emotive: A great product incites you to action. It is so deep, indulgent, complete, and elegant that it compels you to tell other people about it. You’re bringing the good news to help others, not yourself.
Two years after discovering Scala — way back in 2013 — I came to the conclusion that it meets the definition of DICEE, and I think it’s just as true today:
Scala is deep: After all these years I continue to learn new techniques to write better code.
Scala is indulgent: Just like Ruby, I feel special and fortunate to use a language that’s so well thought out.
Scala is complete: The documentation is excellent, terrific frameworks exist, and the support groups are terrific.
Scala is elegant: Once you grasp its main concepts you’ll fall in love with how it works just like you expect it to.
Scala is emotive: Everyone who works with it wants to tell you how special it is. Myself, I had never written a programming book in my life, but by 2012 I was eagerly mailing people at O’Reilly to tell them how much I wanted to write the Scala Cookbook.
As I write this book many years later I hope to share not just the nuts and bolts of the Scala language, but also its elegance and the joy of using it.
Alvin Alexander
alvinalexander.com