Scala is a type-safe JVM language that incorporates both object-oriented and functional programming into an extremely concise, logical, and extraordinarily powerful language. Some may be surprised to know that Scala is not quite as new as they may have thought, having first been introduced in 2003. However, it is in the past few years in particular that Scala has begun to develop a significant following.
This book enables you to build and contribute to Scala programs, recognizing common patterns and techniques used with the language.
This is a practical book which provides you with a lot of hands-on experience with Scala.
This book is for developers who are interested in learning about the advanced features of the Scala language. Basic knowledge of the Scala programming language is required to follow the instructions in this book.
Chapter 1, Setting up the Development Environment, shows you how to set up your development environment. You'll learn the basics of Scala, such as what the simple Scala program looks like and what a typical developer flow is. It'll also cover some aspects of testing your Scala program by using unit testing.
Chapter 2, Basic Language Features, covers classes and objects, traits, pattern matching, case class, and so on. You'll also implement your chatbot application by applying the object oriented concepts.
Chapter 3, Functions, covers functional programming with Scala and how object- oriented and functional approaches complete each other. You'll identify generic classes and also identify how to create user-defined pattern matching and why is it useful.
Chapter 4, Scala Collections, teaches you how to work with lists. Then, it covers some more relevant data structures. Finally, you'll look at how collections relate to monads and how you can use that knowledge to make some powerful abstractions in your code.
Chapter 5, Scala Type System, covers the type system and polymorphism. It'll also enable you to identify the different types of variance, which provides a way to constrain parameterized types. Then, you'll cover some advanced types such as abstract type members and option.
Chapter 6, Implicits, covers implicit parameters and implicit conversions. You'll be learning about how they work, how to use them, and what kind of benefits and perils they provide.
Chapter 7, Functional Idioms, covers the core concepts of functional programming like Pure functions, immutability, and higher-order functions. It'll also cover two popular functional programming libraries called Cats and Doobie, and use them to write some interesting programs.
Chapter 8, Domain Specifc Languages, covers how Scala makes it possible to write powerful DSLs by providing a few interesting language features. Then, it'll cover a DSL that you'll very likely be using if you're going to work with Scala professionally.
Finally, you'll implement your own DSL.
The minimum hardware requirements are as follows:
Intel Core i3 processor
2 GB RAM
An Internet connection
Please ensure you have the following software installed on your machine:
Microsoft Windows 10/8/7 (64 bit)
JDK 8
IntelliJ + Scala plugin
Mac
macOS 10.5 or higher (64-bit)
JDK 8
IntelliJ + Scala plugin
Linux
Linux 64-bit
KDE, GNOME, or Unity DE desktop
JDK 8
IntelliJ + Scala plugin
In this book, you will find a number of text styles that distinguish between different kinds of information. Here are some examples of these styles and an explanation of their meaning.
Code words in text, database table names, folder names, filenames, file extensions, pathnames, dummy URLs, user input, and Twitter handles are shown as follows:
Here, we define an immutable value with the name name, which keeps the user's
stdin
.
The main method is an essential part of any Scala program.
A block of code is set as follows:
package com.packt.courseware import scala.io.StdIn object Chatbot1 { def main(args: Array[String]):Unit = { // do something } }
New terms and important words are shown in bold. Words that you see on the screen, for example, in menus or dialog boxes, appear in the text like this: " Select Run sbt-test."
Important new programming terms are shown in bold. Conceptual terms are shown in italics.
Visit https://www.jetbrains.com/idea/ in your browser.
Click on the DOWNLOAD button on the web page.
Choose your appropriate OS and, under Community, click on the Download option.
Follow the steps in the installer and that's it! Your IntelliJ IDE is ready.
Open IntelliJ IDEA.
Go to
File Menu
.In the file menu, select
Plugins
.Click on
Browse
repositories
button and enterScala
.Select
Scala
plugin to install it.
Feedback from our readers is always welcome. Let us know what you think about this book—what you liked or disliked. Reader feedback is important for us as it helps us develop titles that you will really get the most out of.
To send us general feedback, simply e-mail
<[email protected]>
, and mention the book's title in the subject of your message.
If there is a topic that you have expertise in and you are interested in either writing or contributing to a book, see our author guide at www.packtpub.com/authors.
Now that you are the proud owner of a Packt book, we have a number of things to help you to get the most from your purchase.
You can download the example code files from your account at http://www.packtpub.com for all the Packt Publishing books you have purchased. If you purchased this book elsewhere, you can visit http://www.packtpub.com/support and register to have the files e-mailed directly to you.
Although we have taken every care to ensure the accuracy of our content, mistakes do happen. If you find a mistake in one of our books—maybe a mistake in the text or the code—we would be grateful if you could report this to us. By doing so, you can save other readers from frustration and help us improve subsequent versions of this book. If you find any errata, please report them by visiting http://www.packtpub.com/submit-errata, selecting your book, clicking on the Errata Submission Form link, and entering the details of your errata. Once your errata are verified, your submission will be accepted and the errata will be uploaded to our website or added to any list of existing errata under the Errata section of that title.
To view the previously submitted errata, go to https://www.packtpub.com/books/content/support and enter the name of the book in the search field. The required information will appear under the Errata section.
Piracy of copyrighted material on the Internet is an ongoing problem across all media. At Packt, we take the protection of our copyright and licenses very seriously. If you come across any illegal copies of our works in any form on the Internet, please provide us with the location address or website name immediately so that we can pursue a remedy.
Please contact us at
<[email protected]>
with a link to the suspected pirated material.
We appreciate your help in protecting our authors and our ability to bring you valuable content.
If you have a problem with any aspect of this book, you can contact us at
<[email protected]>
, and we will do our best to address the problem.