Search icon
Subscription
0
Cart icon
Close icon
You have no products in your basket yet
Arrow left icon
All Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Newsletters
Free Learning
Arrow right icon
Learning Scala Programming

You're reading from  Learning Scala Programming

Product type Book
Published in Jan 2018
Publisher Packt
ISBN-13 9781788392822
Pages 426 pages
Edition 1st Edition
Languages
Author (1):
Vikash Sharma Vikash Sharma
Profile icon Vikash Sharma

Table of Contents (21) Chapters

Title Page
Packt Upsell
Contributors
Preface
1. Getting Started with Scala Programming 2. Building Blocks of Scala 3. Shaping our Scala Program 4. Giving Meaning to Programs with Functions 5. Getting Familiar with Scala Collections 6. Object-Oriented Scala Basics 7. Next Steps in Object-Oriented Scala 8. More on Functions 9. Using Powerful Functional Constructs 10. Advanced Functional Programming 11. Working with Implicits and Exceptions 12. Introduction to Akka 13. Concurrent Programming in Scala 14. Programming with Reactive Extensions 15. Testing in Scala 1. Other Books You May Enjoy Index

Preface

Scala, despite being a general purpose JVM-based language like Java, provides an edge with functional programming primitives. Scala has a rich type system, which makes it more expressive. Using type systems, developers can write applications that are less error prone at runtime. Once you have spent enough time learning and practicing concepts, working with Scala is fun. Rich constructs and abstractions have made it powerful, and even framework and library developers enjoy working with Scala.

Keeping these points in mind, this book provides you with all the essentials you need to write programs using Scala. It has all the basic building blocks someone new to Scala might want to know about it, along with the reasons for using it. One of the major goals of this book is to enable you to choose a particular construct above another.

This book will be a companion on your journey towards learning and writing good software using Scala. We believe it'll be a fun journey for you all.

Who this book is for

This book is for programmers who want to get to grips with Scala to write concurrent, scalable, and reactive programs. No prior experience with any programming language is required to learn the concepts explained in this book. However, knowledge of any programming language will help the reader to understand concepts more quickly.

What this book covers

Chapter 1, Getting Started with Scala Programming, introduces you to programming paradigms and explains why choosing Scala gives you an edge over other languages. This chapter ends with demonstrating our first Scala program.

Chapter 2, Building Blocks of Scala, explains the basic constructs required to write a simple program. We'll discuss data types, variables, and literals, with a little bit on type inference.

Chapter 3, Shaping our Scala Program, takes you through looping constructs, control structures, and, most importantly, pattern matching.

Chapter 4, Give Meaning to Programs with Functions, discusses the important functions, function literals, and function call mechanisms. We'll end the chapter with a discussion on partial functions.

Chapter 5, Getting Familiar with Scala Collections, introduces you to Scala's rich collections. We'll discuss mutable and immutable collections, and talk about choosing the most suitable collection.

Chapter 6, Object-Oriented Scala Basics, introduces you to object-oriented Scala. We'll talk about objects, classes, and case classes.

Chapter 7, Next Steps in Object-Oriented Scala, talks about default and parameterized constructors. We will also be introduced to class fields, inheritance, and traits.

Chapter 8, More on Functions, differentiates between functions and methods. We'll talk about partially applied functions, closures, and higher-order functions.

Chapter 9, Using Powerful Functional Constructs, covers some of the important topics in Scala, such as tail-call optimization and currying. Then, we'll discuss combinators and end the chapter with an introduction to parameterized types.

Chapter 10, Advanced Functional Programming, takes you into depth of variance and types. We'll also discuss abstract versus parameterized types.

Chapter 11, Working with Implicits and Exceptions, discusses these two important topics, though they are not related, but are essential to the language. An introduction to implicits and understanding how they work will be the key points of this chapter. We'll also discuss the way we handle exceptions in Scala.

Chapter 12, Introduction to Akka, discusses one of the most talked about toolkits the Scala ecosystem provides. Akka is based on the Actor Model, and that's the main attraction of this chapter.

Chapter 13, Concurrent programming in Scala, takes you deeper into concurrent programming. We'll also cover asynchronous programming using Futures and Promises.

Chapter 14, Programming with Reactive Extensions, talks about reactive programming and the API available in Scala for reactive programming. We'll discuss RxScala, a reactive extension, with a few examples.

Chapter 15, Testing in Scala, covers testing. Our approach will be test-driven. We'll use ScalaTest and try out the library to write test cases for our Scala programs.

To get the most out of this book

This book is an introduction to the Scala language, where you start from learning the basic building blocks of the language and end up learning about frameworks written in Scala. Regardless of whether Scala is your first or second programming language, you're going to enjoy the book. No prior programming knowledge is required. This book has been written with the intention that its chapters are read sequentially, but if you're aware of some of the concepts and want to go skip a particular topic, feel free to do so.

Download the example code files

You can download the example code files for this book from your account at www.packtpub.com. If you purchased this book elsewhere, you can visit www.packtpub.com/support and register to have the files emailed directly to you.

You can download the code files by following these steps:

  1. Log in or register at www.packtpub.com.
  2. Select the SUPPORT tab.
  3. Click on Code Downloads & Errata.
  4. Enter the name of the book in the Search box and follow the onscreen instructions.

Once the file is downloaded, please make sure that you unzip or extract the folder using the latest version of:

  • WinRAR/7-Zip for Windows
  • Zipeg/iZip/UnRarX for Mac
  • 7-Zip/PeaZip for Linux

The code bundle for the book is also hosted on GitHub at https://github.com/PacktPublishing/Learning-Scala-Programming. We also have other code bundles from our rich catalog of books and videos available at https://github.com/PacktPublishing/. Check them out!

Conventions used

There are a number of text conventions used throughout this book.

CodeInText: Indicates code words in text, database table names, folder names, filenames, file extensions, pathnames, dummy URLs, user input, and Twitter handles. Here is an example: "In Scala, Unit is the same as the void, it does not represent any type."

A block of code is set as follows:

object First {
  def main(args: Array[String]): Unit = {
  val double: (Int => Int) = _ * 2
    (1 to 10) foreach double .andThen(println)
  }
}

When we wish to draw your attention to a particular part of a code block, the relevant lines or items are set in bold:

package lsp

object FirstApp extends App {
  val double: (Int => Int) = _ * 2
  (1 to 10) foreach double .andThen(print)
}

Any command-line input or output is written as follows:

sbt console

Bold: Indicates a new term, an important word, or words that you see onscreen. For example, words in menus or dialog boxes appear in the text like this. Here is an example: "Click on the Create New Project function."

Note

Warnings or important notes appear like this.

Note

Tips and tricks appear like this.

Get in touch

Feedback from our readers is always welcome.

General feedback: Email feedback@packtpub.com and mention the book title in the subject of your message. If you have questions about any aspect of this book, please email us at questions@packtpub.com.

Errata: Although we have taken every care to ensure the accuracy of our content, mistakes do happen. If you have found a mistake in this book, we would be grateful if you would report this to us. Please visit www.packtpub.com/submit-errata, selecting your book, clicking on the Errata Submission Form link, and entering the details.

Piracy: If you come across any illegal copies of our works in any form on the Internet, we would be grateful if you would provide us with the location address or website name. Please contact us at copyright@packtpub.com with a link to the material.

If you are interested in becoming an author: If there is a topic that you have expertise in and you are interested in either writing or contributing to a book, please visit authors.packtpub.com.

Reviews

Please leave a review. Once you have read and used this book, why not leave a review on the site that you purchased it from? Potential readers can then see and use your unbiased opinion to make purchase decisions, we at Packt can understand what you think about our products, and our authors can see your feedback on their book. Thank you!

For more information about Packt, please visit packtpub.com.

 

 

lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at €14.99/month. Cancel anytime}