www.allaboutscala.com
Source Code For Scala Tutorials FromIntroduction
The Scala programming language is rapidly growing in popularity! Sadly, most of the online tutorials do not provide a step-by-step guide :(
At www.allaboutscala.com, we provide a complete beginner's tutorial to help you learn Scala in small, simple and easy steps.
- Tutorials are organized such that they allow you to learn gradually.
- Tutorials are written by taking into account the complete beginner.
- Tutorials will make you proficient with the same professional tools used by the Scala experts.
Get Our Books
Scala For Beginners
This book provides a step-by-step guide for the complete beginner to learn Scala. It is particularly useful to programmers, data scientists, big data engineers, students, or just about anyone who wants to get up to speed fast with Scala (especially within an enterprise context). You get to build a real-world Scala multi-project with Akka HTTP.
You can buy the book at https://leanpub.com/scalaforbeginners/
Our Online Tutorials
Scala Introduction: A general overview of Scala
- 1: Introduction
- 2: What is Scala programming language
- 3: Scala functional programming features and more!
Chapter 1: Getting familiar with the IntelliJ IDEA
- 1: Introduction
- 2: Scala Environment Setup – Install Java Development Kit (JDK)
- 3: Scala Environment Setup – How to install the IntelliJ IDE
- 4: Scala Environment Setup – How to install Scala plugin in IntelliJ
- 5: Scala Tutorial – Your first Scala Hello World application
- 6: Where is the main method to launch Scala application
- 7: IntelliJ Run Configuration – Running Your Scala application
- 8: IntelliJ Debug Configuration – Debugging Your Scala Application
- 9: IntelliJ Project Structure – Getting Started With Scala Project
- 10: IntelliJ Project Structure – Scala Project Classpath
- 11: IntelliJ Import Dependencies – Getting Started With build.sbt
- 12: IntelliJ Import Dependencies – SBT Dependencies And Maven
- 13: IntelliJ Manage Configurations – Settings, Preferences
- 14: IntelliJ Keyboard Shortcuts – Navigation Shortcuts
- 15: IntelliJ Keyboard Shortcuts – Search Shortcuts
- 16: IntelliJ Keyboard Shortcuts – Compile, Debug, Run
Chapter 2: Learning the basic foundation of Scala
- 1: Introduction
- 2: Scala Basic Tutorial – How To Declare Variables And Types
- 3: Scala String Interpolation – Print And Format Variables
- 4: Scala – How To Escape Characters And Create Multi-line String
- 5: An Overview Of Scala Type Inference
- 6: How To Use If Else Statement And Expression
- 7: Learn How To Use For Comprehension
- 8: Learn How To Use Range
- 9: Learn How To Use While And Do While Loop
- 10: Learn How To Use Pattern Matching
- 11: Learn How To Use Tuples
- 12: Learn How To Use Option – Avoid Null
- 13: Learn The Scala Class And Type Hierarchy
- 14: Learn How To Create And Use Enumerations
Chapter 3: Thinking In Terms Of Functions
- 1: Introduction
- 2: Learn How To Create And Use Functions
- 3: Learn How To Create Function With Parameters
- 4: Learn How To Use Option In Function Parameters
- 5: Learn How To Create Function With Option Return Type
- 6: Learn How To Create Function With Implicit Parameter
- 7: Learn How To Create Implicit Function
- 8: Learn How To Create Typed Function
- 9: Learn How To Create Polymorphic Function With Generic Return Type
- 10: Learn How To Create Variable Argument Function
- 11: Learn How To Create Functions As Symbols
- 12: Learn How To Create Function Currying With Parameter Groups
- 13: Learn How To Create Higher Order Function - Function As Parameter
- 14: Learn How To Create Higher Order Function - Call By Name Function
- 15: Learn How To Create Higher Order Function - With Callback Parameter
- 16: Learn How To Create Function Using The Val Keyword Instead Of Def
- 17: Learn Function Composition Using AndThen
- 18: Learn Function Composition Using Compose
- 19: Learn How To Create Tail Recursive Function - @annotation.tailrec
- 20: Learn How To Create Tail Recursive Function - scala.util.control.TailCalls._
- 21: Learn How To Create Trampoline Tail Recursive Function Using scala.util.control.TailCalls._
- 22: Learn How To Create Partial Function Using the PartialFunction Trait
- 23: Learn How To Create Nested Function
Chapter 4: Think you know Object Oriented using classes?
- 1: Introduction
- 2: Learn How To Create Classes And Objects In Scala
- 3: Learn How To Create And Use Companion Objects
- 4: Learn How To Use Companion Objects' Apply Method As A Factory (Class Hierarchy Via Inheritance)
- 5: Learn How To Declare Values And Fields In Companion Object
- 6: Learn How To Declare And Use Singleton Object
- 7: Learn How To Define And Use Case Class
- 8: Learn How To Use Type Alias: Type Aliasing Versus Case Class
- 9: Learn How To Use Implicit Class - Extension Methods
- 10: Learn How To Use Package Object
- 11: Learn How To Extend Class - Class Inheritance
- 12: Learn How To Extend Case Class - Case Class Inheritance
- 13: Learn How To Create Type Class
- 14: Learn How To Create Covariance Type Class
- 15: Learn How To Create Contra-Variance Type Class
Chapter 5: Dependency Injection reinvented using traits
- 1: Introduction
- 2: Learn How To Create And Extend Trait In Scala
- 3: Learn How To Create Trait With Type Parameters
- 4: Learn How To Extend Multiple Traits
- 5: Learn How To Use Traits For Dependency Injection
- 6: Learn How To Use Traits For Dependency Injection Part 2 - Avoid Cake Pattern
- 7: Traits, Companion Object, Factory Pattern
Chapter 6: Immutable Collection
- 1: Introduction
- 2: Learn How To Use Scala's Immutable List
- 3: Learn How To Use Scala's Immutable ListSet
- 4: Learn How To Use Scala's Immutable ListMap
- 5: Learn How To Use Scala's Immutable Map
- 6: Learn How To Use Scala's Immutable HashMap
- 7: Learn How To Use Scala's Immutable TreeMap
- 8: Learn How To Use Scala's Immutable Queue
- 9: Learn How To Use Scala's Immutable Sequence
- 10: Learn How To Use Scala's Immutable Set
- 11: Learn How To Use Scala's Immutable HashSet
- 12: Learn How To Use Scala's Immutable TreeSet
- 13: Learn How To Use Scala’s Immutable SortedSet
- 14: Learn How To Use Scala's Immutable BitSet
- 15: Learn How To Use Scala's Immutable Stack
- 16: Learn How To Use Scala's Immutable Stream
- 17: Learn How To Use Scala's Immutable Vector
Chapter 7: Mutable Collection
- 1: Introduction
- 2: Learn How To Use Scala's Mutable Array
- 3: Learn How To Use Scala's Mutable ArrayBuffer
- 4: Learn How To Use Scala's Mutable ArrayStack
- 5: Learn How To Use Scala's Mutable ListBuffer
- 6: Learn How To Use Scala's Mutable Map
- 7: Learn How To Use Scala's Mutable HashMap
- 8:Learn How To Use Scala's Mutable ListMap
- 9: Learn How To Use Scala's Mutable LinkedHashMap
- 10: Learn How To Use Scala's Mutable Queue
- 11: Learn How To Use Scala's Mutable PriorityQueue
- 12: Learn How To Use Scala's Mutable Set
- 13: Learn How To Use Scala's Mutable HashSet
- 14: Learn How To Use Scala's Mutable SortedSet
- 15: Learn How To Use Scala's Mutable TreeSet
- 16: Learn How To Use Scala's Mutable LinkedHashSet
- 17: Learn How To Use Scala's Mutable BitSet
Chapter 8: Collection Functions
- 1: Introduction
- 2: Learn How To Use Aggregate Function
- 3: Learn How To Use Collect Function
- 4: Learn How To Use Diff Function
- 5: Learn How To Use Drop Function
- 6: Learn How To Use DropWhile Function
- 7: Learn How To Use Exists Function
- 8: Learn How To Use Filter And FilterNot Functions
- 9: Learn How To Use Find Function
- 10: Learn How To Use FlatMap Function
- 11: Learn How To Use Flatten Function
- 12: Learn How To Use Fold Function With Examples
- 13: Learn How To Use FoldLeft Function With Examples
- 14: Learn How To Use FoldRight Function With Examples
- 15: Learn How To Use Foreach Function With Examples
- 16: Learn How To Use GroupBy Function With Examples
- 17: Learn How To Use Head Function With Examples
- 18: Learn How To Use IsEmpty Function With Examples
- 19: Learn How To Use Intersect Function With Examples
- 20: Learn How To Use Last Function With Examples
- 21: Learn How To Use Map Function With Examples
- 22: Learn How To Use Max Function With Examples
- 23: Learn How To Use MaxBy Function With Examples
- 24: Learn How To Use Min Function With Examples
- 25: Learn How To Use MinBy Function With Examples
- 26: Learn How To Use MkString Function With Examples
- 27: Learn How To Use NonEmpty Function With Examples
- 28: Learn How To Use Par Function With Examples
- 29: Learn How To Use Partition Function With Examples
- 30: Learn How To Use Reduce Function With Examples
- 31: Learn How To Use ReduceLeft Function With Examples
- 32: Learn How To Use ReduceRight Function With Examples
- 33: Learn How To Use Reverse Function With Examples
- 34: Learn How To Use ReverseIterator Function With Examples
- 35: Learn How To Use Scan Function With Examples
- 36: Learn How To Use ScanLeft Function With Examples
- 37: Learn How To Use ScanRight Function With Examples
- 38: Learn How To Use Size Function With Examples
- 39: Learn How To Use Slice Function With Examples
- 40: Learn How To Use SortBy Function With Examples
- 41: Learn How To Use Sorted Function With Examples
- 42: Learn How To Use SortWith Function With Examples
- 43: Learn How To Use Tail Function With Examples
- 44: Learn How To Use Take Function With Examples
- 45: Learn How To Use TakeRight Function With Examples
- 46: Learn How To Use TakeWhile Function With Examples
- 47: Learn How To Use Transpose Function With Examples
- 48: Learn How To Use Union Function With Examples
- 49: Learn How To Use Unzip Function With Examples
- 50: Learn How To Use Unzip3 Function With Examples
- 51: Learn How To Use View Function With Examples
- 52: Learn How To Use WithFilter Function With Examples
- 53: Learn How To Use Zip Function With Examples
- 54: Learn How To Use ZipWithIndex Function With Examples
Chapter 9: Futures
- 1: Method with future as return type
- 2: Non blocking future result
- 3: Chain futures using flatMap
- 4: Chain futures using for comprehension
- 5: Future option with for comprehension
- 6: Future option with map
- 7: Composing futures
- 8: Future sequence
- 9: Future traverse
- 10: Future foldLeft
- 11: Future reduceLeft
- 12: Future firstCompletedOf
- 13: Future zip
- 14: Future zipWith
- 15: Future andThen
- 16: Future configure threadpool
- 17: Future recover
- 18: Future recoverWith
- 19: Future fallbackTo
- 20: Future promise
Chapter 10: Cheatsheet and Scala Test
ScalaTest
- Introduction
- Add ScalaTest as dependency to build.sbt
- Create a test class using FlatSpec and Matchers
- Equality Test
- Length Test
- Boolean Test
- Collection Test
- Type Test
- Exception Test
- Private Method Test
- Future Method Test
Collection
General
- Add line break
- Convert multi-line string into single line
- Check value of an Option
- Read file content as a String
- Create enum using sealed trait
- Int division and return float
Futures
Chapter 11: Learn SBT
Install SBT
sbt run
sbt test
- Run all tests
- Run only one specific test
- Run all integration tests
- Run a specific integration test
- Run one method in a test class
sbt debugging
sbt resources
Chapter 12: Learn Apache Spark 2
Chapter 12 - Part 1
Project Setup
DataFrame SQL Query
- DataFrame Introduction
- Create a DataFrame from reading a CSV file
- DataFrame schema
- Select columns from a dataframe
- Filter by column value of a dataframe
- Count rows of a dataframe
- SQL like query
- Multiple filter chaining
- SQL IN clause
- SQL Group By
- SQL Group By with filter
- SQL order by
- Cast columns to specific data type
- Operate on a filtered dataframe
- DataFrame Join
- Join and select columns
- Join on explicit columns
- Inner Join
- Left Outer Join
- Right Outer Join
- Distinct
Chatper 12 - Part 2
Spark SQL
- Spark SQL Introduction
- Register temp table from dataframe
- List all tables in Spark's catalog
- List catalog tables using Spark SQL
- Select columns
- Filter by column value
- Count number of rows
- SQL like
- SQL where with and clause
- SQL IN clause
- SQL Group By
- SQL Group By with having clause
- SQL Order by
- Typed columns, filter and create temp table
- SQL Inner Join
- SQL Left Outer Join
- SQL Right Outer Join
- SQL Distinct
- Register User Defined Function (UDF)
Chapter 12 - Part 3
DataFrame Statistics
- DataFrame Statistics Introduction
- Create DataFrame from CSV
- Average
- Maximum
- Minimum
- Mean
- Sum
- Group by query with statistics
- DataFrame Statistics using describe() method
- Correlation
- Covariance
- Frequent Items
- Crosstab
- Stratified sampling using sampleBy
- Approximate Quantile
- Bloom Filter
- Count Min Sketch
- Sampling With Replacement
Chapter 12 - Part 4
DataFrame Operations
- DataFrame Operations Introduction
- Setup DataFrames
- Convert DataFrame row to Scala case class
- DataFrame row to Scala case class using map()
- Create DataFrame from collection
- DataFrame Union
- DataFrame Intersection
- Append column to DataFrame using withColumn()
Spark Functions
- Create DataFrame from Tuples
- Get DataFrame column names
- DataFrame column names and types
- Nested Json into DataFrame using explode method
- Concatenate DataFrames using join() method
- Search DataFrame column using array_contains() method
- Check DataFrame column exists
- Split DataFrame Array column
- Rename DataFrame column
- Create DataFrame constant column
- DataFrame new column with User Defined Function (UDF
- DataFrame first row
- Format DataFrame column
- DataFrame column hashing
- DataFrame String functions
- DataFrame drop null
Chapter 13 - Learn Akka
Introduction
Akka Actors
- Actor System Introduction
- Tell Pattern
- Ask Pattern
- Ask Pattern mapTo
- Ask Pattern pipeTo
- Actor Hierarchy
- Actor Lookup
- Child Actors
- Actor Lifecycle
- Actor PoisonPill
- Error Kernel Supervision
Akka Routers
Akka Dispatchers
- Akka Default Dispatcher
- Akka Lookup Dispatcher
- Fixed Thread Pool Dispatcher
- Resizable Thread Pool Dispatcher
- Pinned Thread Pool Dispatcher
Akka FSM
- Actor FSM become()
- Actor FSM unbecome()
- Actor FSM protocol
- Actor LoggingFSM
- Actor LoggingFSM Part Two
- Actor LoggingFSM Part Three
- Actor LoggingFSM Part Four
- Actor LoggingFSM Part Five
- Actor LoggingFSM Part Six
- Actor FSM Scheduler
Akka TestKit
- Testing Actor FSM
- Testing Actor
- Testing Akka HTTP POST
- Testing Query Parameter
- Testing Required Query Parameter
- Testing Optional Query Parameter
- Testing Typed Query Parameter
- Testing CSV Query Parameter
Akka HTTP
- Akka HTTP project setup build.sbt
- Start Akka HTTP Server
- HTTP GET plain text
- HTTP GET JSON response
- JSON encoding
- JSON pretty print
- HTTP POST JSON payload
- Could not find implicit value
- HTTP DELETE restriction
- Future onSuccess
- Future onComplete
- Complete with an HttpResponse
- Try failure using an HttpResponse
- Global rejection handler
- Global exception handler
- Load HTML from resources
- RESTful URLs with segment
- RESTful URLS with regex
- RESTful URLS with multiple segments
- Query parameter
- Optional query parameter
- Typed query parameters
- CSV query parameter
- Query parameter to case class
- HTTP request headers
- HTTP client GET
- Unmarshal HttpResponse to case class
- HTTP client POST JSON
Chapter 14 - Learn Cassandra
Introduction
- What is Apache Cassandra
- Install Apache Cassandra
- Using nodetool
- cassandra.yaml
- cqlsh
- Load CQL statements from file
- Partition keys
- Clustering keys
- Cassandra CQL is not SQL!
- Multiple clustering keys
- Clustering keys restrictions
- Secondary index
- Create materialized view
Chapter 15 - Scala Exercises
Chapter 16 - Data Science
Stay in touch via LinkedIn, Facebook and Twitter for upcoming tutorials!
Contact
Nadim Bahadoor at http://allaboutscala.com/contact/
License
Apache 2.0 License - see the LICENSE.TXT file