Get up to speed on Scala, the JVM language that offers all the benefits of a modern object model, functional programming, and an advanced type system. Packed with code examples, this comprehensive book shows you how to be productive with the language and ecosystem right away, and explains why Scala is ideal for today's highly scalable, data-centric applications that support concurrency and distribution. This second edition covers recent language features, with new chapters on pattern matching, comprehensions, and advanced functional programming. You’ll also learn about Scala’s command-line tools, third-party tools, libraries, and language-aware plugins for editors and IDEs. This book is ideal for beginning and advanced Scala developers alike. Program faster with Scala’s succinct and flexible syntax Dive into basic and advanced functional programming (FP) techniques Build killer big-data apps, using Scala’s functional combinators Use traits for mixin composition and pattern matching for data extraction Learn the sophisticated type system that combines FP and object-oriented programming concepts Explore Scala-specific concurrency tools, including Akka Understand how to develop rich domain-specific languages Learn good design techniques for building scalable and robust Scala applications
Grok and perform effective functional programming in Scala About This Book Understand functional programming patterns by comparing them with the traditional object-oriented design patterns Write robust, safer, and better code using the declarative programming paradigm An illustrative guide for programmers to create functional programming patterns with Scala Who This Book Is For If you have done Java programming before and have a basic knowledge of Scala and its syntax, then this book is an ideal choice to help you to understand the context, the traditional design pattern applicable, and the Scala way. Having previous knowledge of design patterns will help, though it is not strictly necessary. What You Will Learn Get to know about functional programming and the value Scala's FP idioms bring to the table Solve day-to-day programming problems using functional programming idioms Cut down the boiler-plate and express patterns simply and elegantly using Scala's concise syntax Tame system complexity by reducing the moving parts Write easier to reason about concurrent code using the actor paradigm and the Akka library Apply recursive thinking and understand how to create solutions without mutation Reuse existing code to compose new behavior Combine the object-oriented and functional programming approaches for effective programming using Scala In Detail Scala is used to construct elegant class hierarchies for maximum code reuse and extensibility and to implement their behavior using higher-order functions. Its functional programming (FP) features are a boon to help you design “easy to reason about” systems to control the growing software complexities. Knowing how and where to apply the many Scala techniques is challenging. Looking at Scala best practices in the context of what you already know helps you grasp these concepts quickly, and helps you see where and why to use them. This book begins with the rationale behind patterns to help you understand where and why each pattern is applied. You will discover what tail recursion brings to your table and will get an understanding of how to create solutions without mutations. We then explain the concept of memorization and infinite sequences for on-demand computation. Further, the book takes you through Scala's stackable traits and dependency injection, a popular technique to produce loosely-coupled software systems. You will also explore how to currying favors to your code and how to simplify it by de-construction via pattern matching. We also show you how to do pipeline transformations using higher order functions such as the pipes and filters pattern. Then we guide you through the increasing importance of concurrent programming and the pitfalls of traditional code concurrency. Lastly, the book takes a paradigm shift to show you the different techniques that functional programming brings to your plate. This book is an invaluable source to help you understand and perform functional programming and solve common programming problems using Scala's programming patterns. Style and approach This is a hands-on guide to Scala's game-changing features for programming. It is filled with many code examples and figures that illustrate various Scala idioms and best practices.
Why learn Scala? You don’t need to be a data scientist or distributed computing expert to appreciate this object-oriented functional programming language. This practical book provides a comprehensive yet approachable introduction to the language, complete with syntax diagrams, examples, and exercises. You’ll start with Scala's core types and syntax before diving into higher-order functions and immutable data structures. Author Jason Swartz demonstrates why Scala’s concise and expressive syntax make it an ideal language for Ruby or Python developers who want to improve their craft, while its type safety and performance ensures that it’s stable and fast enough for any application. Learn about the core data types, literals, values, and variables Discover how to think and write in expressions, the foundation for Scala's syntax Write higher-order functions that accept or return other functions Become familiar with immutable data structures and easily transform them with type-safe and declarative operations Create custom infix operators to simplify existing operations or even to start your own domain-specific language Build classes that compose one or more traits for full reusability, or create new functionality by mixing them in at instantiation
This full-color booklet contains chapter notes, hints, solutions to exercises, addenda, and errata for the book "Functional Programming in Scala" by Paul Chiusano and Runar Bjarnason. This material is freely available online, but is compiled here as a convenient companion to the book itself. All code is colorfully syntax-highlighted.
Save time and trouble when using Scala to build object-oriented, functional, and concurrent applications. With more than 250 ready-to-use recipes and 700 code examples, this comprehensive cookbook covers the most common problems you’ll encounter when using the Scala language, libraries, and tools. It’s ideal not only for experienced Scala developers, but also for programmers learning to use this JVM language. Author Alvin Alexander (creator of DevDaily.com) provides solutions based on his experience using Scala for highly scalable, component-based applications that support concurrency and distribution. Packed with real-world scenarios, this book provides recipes for: Strings, numeric types, and control structures Classes, methods, objects, traits, and packaging Functional programming in a variety of situations Collections covering Scala's wealth of classes and methods Concurrency, using the Akka Actors library Using the Scala REPL and the Simple Build Tool (SBT) Web services on both the client and server sides Interacting with SQL and NoSQL databases Best practices in Scala development
This book gives an introduction to the programming language Scala. It presents it from a functional programming perspective. The book explains with detail functional programming and recursivity, and includes chapters on lazy and eager evaluation, streams, higher-order functions (including map, fold, reduce, and aggregate), and algebraic data types. The book also describes the object-oriented aspects of Scala, as they are a fundamental part of the language. In addition, the book includes a chapter on parallelism in Scala, giving an overview of the actor model.
Scala is a new programming language developed by Martin Odersky and his team at the EPFL. The name Scala is derived from Sca(lable) La(nguage). Scala is a multi-paradigm language, incorporating object oriented approaches with functional programming. Although some familiarity with standard computing concepts is assumed (such as the idea of compiling a program and executing this compiled form, etc.) and with basic procedural language concepts (such as variables and allocation of values to variables) the early chapters of the book do not assume any familiarity with object orientation nor functional programming. These chapters also step through other concepts with which the reader may not be familiar (such as list processing). From this background, John Hunt provides a practical introduction to object and functional technology using Scala, one of the newest and most interesting programming languages available. A variety of concepts are introduced through practical experience taking the reader beyond the level of the language syntax to the philosophy and practice of object-oriented development and functional programming. Students, and those actively involved in the software industry will find this comprehensive introduction to Scala and to object orientation and functional programming, invaluable.
Author: Christos K. K. Loverdos
Publisher: Cambridge University Press
Release Date: 2010-09-23
Scala is a highly expressive, concise and scalable language. It is also the most prominent method of the new and exciting methodology known as object-functional programming. In this book, the authors show how Scala grows to the needs of the programmer, whether professional or hobbyist. They teach Scala with a step-by-step approach and explain how to exploit the full power of the industry-proven JVM technology. Readers can then dive into specially chosen design challenges and implementation problems, inspired by the trials of real-world software engineering. It also helps readers to embrace the power of static typing and automatic type inference. In addition, the book shows how to use the dual-object and functional-oriented natures combined at Scala's core, and so write code that is less 'boilerplate', giving a genuine increase in productivity.
Software development today is embracing functional programming (FP), whether it's for writing concurrent programs or for managing Big Data. Where does that leave Java developers? This concise book offers a pragmatic, approachable introduction to FP for Java developers or anyone who uses an object-oriented language. Dean Wampler, Java expert and author of Programming Scala (O'Reilly), shows you how to apply FP principles such as immutability, avoidance of side-effects, and higher-order functions to your Java code. Each chapter provides exercises to help you practice what you've learned. Once you grasp the benefits of functional programming, you’ll discover that it improves all of the code you write. Learn basic FP principles and apply them to object-oriented programming Discover how FP is more concise and modular than OOP Get useful FP lessons for your Java type design—such as avoiding nulls Design data structures and algorithms using functional programming principles Write concurrent programs using the Actor model and software transactional memory Use functional libraries and frameworks for Java—and learn where to go next to deepen your functional programming skills
Author: Janek Bogucki
Publisher: John Wiley & Sons
Release Date: 2016-06-13
Professional Scala provides experienced programmers with fast track coverage aimed at supporting the use of Scala in professional production applications. Skipping over the basics and fundamentals of programming, the discussion launches directly into practical Scala topics with the most up-to-date coverage of the rapidly-expanding language and related tools. Scala bridges the gap between functional and object-oriented programming, and this book details that link with clear a discussion on both Java compatibility and the read-eval-print loop used in functional programming. You'll learn the details of tooling for build and static analysis. You’ll cover unit testing with ScalaTest, documentation with Scaladoc, how to handle concurrency, and much more as you build the in-demand skill set required to use Scala in a real-world production environment. Java-compliant with functional programming properties, Scala's popularity is growing quickly—especially in the rapidly expanding areas of big data and cluster computing. This book explains everything professional programmers need to start using Scala and its main tools quickly and effectively. Master Scala syntax, the SBT interactive build tool, and the REPL workflow Explore functional design patterns, concurrency, and testing Work effectively with Maven, Scaladoc, Scala.js, and more Dive into the advanced type system Find out about Scala.js A working knowledge of Scala puts you in demand. As both the language and applications expand, so do the opportunities for experienced Scala programmers—and many positions are going unfilled. Twitter, Comcast, Netflix, and other major enterprises across industries are using Scala every day, in a number of different applications and capacities. Professional Scala helps you update your skills quickly to start advancing your career.
Write modern, scalable, and reactive applications with the power of Scala About This Book Delves into the intricacies of functional reactive programming with Scala Explores frameworks like Akka, Play and Slick used to develop efficient applications A step by step guide with plenty of examples showing practical implementation of essential concepts Who This Book Is For If you are a Java or JVM developer who wants to use Scala to build reactive functional applications for the JVM platform, then this book is for you. Prior knowledge of Java or functional programing would help. No Scala knowledge is required. What You Will Learn Use Akka to create a chat service for your app Equip yourself with the techniques and tools to build reports and build database persistence with Scala and Slick Develop a customer-facing Rest API that makes use of Scala and Spray Make use of the Scala web development principles and scale up the architecture of your application Get familiar with the core principles and concepts of Functional Programming Use the Play framework to create models, controllers, and views Develop reactive backing frameworks by writing code with RxScala Discover what proper testing entails with Scala using behavior-driven development In Detail Scala is known for incorporating both object-oriented and functional programming into a concise and extremely powerful package. However, creating an app in Scala can get a little tricky because of the complexity the language has. This book will help you dive straight into app development by creating a real, reactive, and functional application. We will provide you with practical examples and instructions using a hands-on approach that will give you a firm grounding in reactive functional principles. The book will take you through all the fundamentals of app development within Scala as you build an application piece by piece. We've made sure to incorporate everything you need from setting up to building reports and scaling architecture. This book also covers the most useful tools available in the Scala ecosystem, such as Slick, Play, and Akka, and a whole lot more. It will help you unlock the secrets of building your own up-to-date Scala application while maximizing performance and scalability. Style and approach This book takes a step-by-step approach to app development with Scala. It will place special emphasis on functional language. It will teach you the core benefits of Scala and the fundamentals of functional programming by developing a robust application.
Functional and Reactive Domain Modeling teaches readers how to think of the domain model in terms of pure functions and how to compose them to build larger abstractions. It begins with the basics of functional programming and gradually progresses to the advanced concepts and patterns needed to implement complex domain models. The book demonstrates how advanced FP patterns like algebraic data types, typeclass based design, and isolation of side-effects can make models compose for readability and verifiability. On the subject of reactive modeling, the book focuses on higher order concurrency patterns like actors and futures. It uses the Akka framework as the reference implementation and demonstrates how advanced architectural patterns like event sourcing and CQRS can be put to great use in implementing scalable models. It offers techniques that are radically different from the standard RDBMS based applications that are based on mutation of records. It also shares important patterns like using asynchronous messaging for interaction based on non blocking concurrency and model persistence, which delivers the speed of in- memory processing along with suitable guarantees of reliability.