Read "Learning Concurrent Programming in Scala - Second Edition" by Aleksandar Prokopec available from Rakuten Kobo. Sign up today and get $5 off your. Editorial Reviews. About the Author. Aleksandar Prokopec Aleksandar Prokopec, who also eBook features: Highlight, take notes .. Download Audiobooks. Learning Concurrent Programming in Scala [Aleksandar Prokopec] on Amazon. com. Paperback: pages; Publisher: Packt Publishing - ebooks Account.
|Language:||English, Spanish, Japanese|
|ePub File Size:||16.34 MB|
|PDF File Size:||18.31 MB|
|Distribution:||Free* [*Free Regsitration Required]|
Take a look at Learning Concurrent Programming in Scala by Aleksandar Prokopec. Get free access to the biggest Tech and Business online library. Enjoy Read Learning Concurrent Programming in Scala - Second Edition by Aleksandar Prokopec by Aleksandar Prokopec Read eBook on the web, iPad, iPhone and Android. Download the free Scribd mobile app to read anytime, anywhere. Selection from Learning Concurrent Programming in Scala [Book] You can download the example code files for all Packt books you have purchased from your account at http://www. Support files, eBooks, discount offers, and more.
This book will give you an insight into the best practices necessary to build concurrent programs in Scala using modern, high-level concurrency libraries. It starts by introducing you to the foundations of concurrent programming on the JVM, outlining the basics of the Java Memory Model, and then shows some of the classic building blocks of concurrency, such as the atomic variables, thread pools, and concurrent data structures, along with the caveats of traditional concurrency. It then walks you through different high-level concurrency abstractions, each tailored toward a specific class of programming tasks. Finally, the book presents an overview of when to use which concurrency library and demonstrates how they all work together. Downloading the example code for this book. You can download the example code files for all Packt books you have purchased from your account at http:
Lukas Rytz is a compiler engineer working in the Scala team at Typesafe. She has conducted research on various areas, such as testing concurrent programs and in particular actor programs, patterns in parallel programming, and verification of component-based systems. I would like to thank my husband and mom for their endless love and support.
Get the most in-demand software skills with Mapt. Mapt gives you full access to all Packt books and video courses, as well as industry-leading tools to help you plan your personal development and advance your career. Thanks for purchasing this Packt book.
At Packt, quality is at the heart of our editorial process. To help us improve, please leave us an honest review on this book's Amazon page at https: If you'd like to join our team of regular reviewers, you can email us at customerreviews packtpub.
We award our regular reviewers with free eBooks and videos in exchange for their valuable feedback. Help us be relentless in improving our products! Concurrency is everywhere.
With the rise of multicore processors in the consumer market, the need for concurrent programming has overwhelmed the developer world.
Where it once served to express asynchronously in programs and computer systems and was largely an academic discipline, concurrent programming is now a pervasive methodology in software development.
As a result, advanced concurrency frameworks and libraries are sprouting at an amazing rate. Recent years have witnessed a renaissance in the field of concurrent computing.
As the level of abstraction grows in modern languages and concurrency frameworks, it is becoming crucial to know how and when to use them.
Having a good grasp of the classical concurrency and synchronization primitives, such as threads, locks, and monitors, is no longer sufficient. High-level concurrency frameworks, which solve many issues of traditional concurrency and are tailored towards specific tasks, are gradually overtaking the world of concurrent programming.
This book describes high-level concurrent programming in Scala. It presents detailed explanations of various concurrency topics and covers the basic theory of concurrent programming. Simultaneously, it describes modern concurrency frameworks, shows their detailed semantics, and teaches you how to use them. Its goal is to introduce important concurrency abstractions and, at the same time, show how they work in real code.
We are convinced that, by reading this book, you will gain both a solid theoretical understanding of concurrent programming and develop a set of useful practical skills that are required to write correct and efficient concurrent programs.
These skills are the first steps toward becoming a modern concurrency expert. This book is organized into a sequence of chapters with various topics on concurrent programming. The book covers the fundamental concurrent APIs that are a part of the Scala runtime, introduces more complex concurrency primitives, and gives an extensive overview of high-level concurrency abstractions.
Chapter 1, Introduction , explains the need for concurrent programming and gives some philosophical background.
At the same time, it covers the basics of the Scala programming language that are required for understanding the rest of this book. This chapter will teach you how to use threads and how to protect access to shared memory and introduce the Java Memory Model. Chapter 3, Traditional Building Blocks of Concurrency , presents classic concurrency utilities, such as thread pools, atomic variables, and concurrent collections, with a particular focus on the interaction with the features of the Scala language.
The emphasis in this book is on the modern, high-level concurrent programming frameworks. Consequently, this chapter presents an overview of traditional concurrent programming techniques, but it does not aim to be extensive. Chapter 4, Asynchronous Programming with Futures and Promises , is the first chapter that deals with a Scala-specific concurrency framework. This chapter presents the futures and promises API and shows how to correctly use them when implementing asynchronous programs.
Chapter 5, Data-Parallel Collections , describes the Scala parallel collections framework. In this chapter, you will learn how to parallelize collection operations, when it is allowed to parallelize them, and how to assess the performance benefits of doing so. Chapter 6, Concurrent Programming with Reactive Extensions , teaches you how to use the Reactive Extensions framework for event-based and asynchronous programming.
You will see how the operations on event streams correspond to collection operations, how to pass events from one thread to another, and how to design a reactive user interface using event streams.
Chapter 7, Software Transactional Memory , introduces the ScalaSTM library for transactional programming, which aims to provide a safer, more intuitive, shared-memory programming model. In this chapter, you will learn how to protect access to shared data using scalable memory transactions and, at the same time, reduce the risk of deadlocks and race conditions. Chapter 8, Actors , presents the actor programming model and the Akka framework.
In this chapter, you will learn how to transparently build message-passing distributed programs that run on multiple machines. Chapter 9, Concurrency in Practice , summarizes the different concurrency libraries introduced in the earlier chapters. In this chapter, you will learn how to choose the correct concurrency abstraction to solve a given problem, and how to combine different concurrency abstractions together when designing larger concurrent applications. Chapter 10, Reactors , presents the reactor programming model, whose focus is improved composition in concurrent and distributed programs.
This emerging model enables separation of concurrent and distributed programming patterns into modular components called protocols. While we recommend that you read the chapters in the order in which they appear, this is not strictly necessary.
Learning Concurrent Programming in Scala - Second Edition by Aleksandar Prokopec - Read Online
If you are well acquainted with the content in Chapter 2, Concurrency on the JVM and the Java Memory Model , you can study most of the other chapters directly. The only chapters that rely on the content from all the preceding chapters are Chapter 9, Concurrency in Practice , where we present a practical overview of the topics in this book, and Chapter 10, Reactors , for which it is helpful to understand how actors and event streams work.
In this section, we describe some of the requirements that are necessary to read and understand this book. We explain how to install the Java Development Kit, which is required to run Scala programs and show how to use Simple Build Tool to run various examples.
We will not require an IDE in this book. Scala programs are not compiled directly to the native machine code, so they cannot be run as executables on various hardware platforms. Instead, the Scala compiler produces an intermediate code format called the Java bytecode. To run this intermediate code, your computer must have the Java Virtual Machine software installed.
In this section, we explain how to download and install the Java Development Kit, which includes the Java Virtual Machine and other useful tools. There are multiple implementations of the JDK that are available from different software vendors. We recommend that you use the Oracle JDK distribution.
To download and install the Java Development Kit, follow these steps: Open the following URL in your web browser: Once you find the link for the Java SE, download on the Oracle website, download the appropriate version of JDK 7 for your operating system: If you are using the Windows operating system, simply run the installer program.
You should now be able to run the java and javac commands in the terminal. It is possible that your operating system already has JDK installed.
To verify this, simply run the javac command, as we did in the last step in the preceding description. Its purpose is to compile Scala code, manage dependencies, continuous compilation and testing, deployment, and many other uses. Throughout this book, we will use SBT to manage our project dependencies and run example code. Download the installation file for your platform.
If you are running on Windows, this is the msi installer file.
If you are running on Linux or OS X, this is the zip or tgz archive file. Install SBT. If you are running on Windows, simply run the installer file. If you are running on Linux or OS X, unzip the contents of the archive in your home directory. You are now ready to use SBT. In the following steps, we will create a new SBT project: Now, use your editor to create a build definition file named build. This file defines various project properties.
Create it in the root directory of the project scala-concurrency-examples. Add the following contents to the build definition file note that the empty lines are mandatory: Finally, go back to the terminal and run SBT from the root directory of the project: Now, you can start writing Scala programs.
Open your editor, and create a source code file named HelloWorld. Add the following contents to the HelloWorld. Now, go back to the terminal window with the SBT interactive shell and run the program with the following command: These steps are sufficient to run most of the examples in this book.
Occasionally, we will rely on external libraries when running the examples. These libraries are resolved automatically by SBT from standard software repositories. For some libraries, we will need to specify additional software repositories, so we add the following lines to our build. Now that we have added all the necessary software repositories, we can add some concrete libraries. By adding the following line to the build.
After changing the build.
Join Kobo & start eReading today
In the SBT interactive shell, we need to enter the following command: This enables SBT to detect any changes in the build definition file and download additional software packages when necessary.
Different Scala libraries live in different namespaces called packages. To obtain access to the contents of a specific package, we use the import statement. When we use a specific concurrency library in an example for the first time, we will always show the necessary set of import statements. On subsequent uses of the same library, we will not repeat the same import statements.
Similarly, we avoid adding package declarations in the code examples to keep them short. Instead, we assume that the code in a specific chapter is in the similarly named package. Source code files for the examples presented in that chapter begin with the following code: Finally, this book deals with concurrency and asynchronous execution. Many of the examples start a concurrent computation that continues executing after the main execution stops.
To make sure that these concurrent computations always complete, we will run most of the examples in the same JVM instance as SBT itself. We add the following line to our build. In the examples, where running in a separate JVM process is required, we will point this out and give clear instructions. In this case, there is no need to install SBT, as described in the previous section.
There is an important caveat when running the examples in this book using an IDE: As mentioned in the previous section, certain concurrent computations continue executing after the main execution stops. To make sure that they always complete, you will sometimes need to add the sleep statements at the end of the main execution, which slow down the main execution.
In most of the examples in this book, the sleep statements are already added for you, but in some programs, you might have to add them yourself. This book is primarily intended for developers who have learned how to write sequential Scala programs, and wish to learn how to write correct concurrent programs. The book assumes that you have a basic knowledge of the Scala programming language. Throughout this book, we strive to use the simple features of Scala in order to demonstrate how to write concurrent programs.
Even with an elementary knowledge of Scala, you should have no problem understanding various concurrency topics. This is not to say that the book is limited to Scala developers. Whether you have experience with Java, come from a. NET background, or are generally a programming language aficionado, chances are that you will find the content in this book insightful.
A basic understanding of object-oriented or functional programming should be a sufficient prerequisite. Finally, this book is a good introduction to modern concurrent programming in the broader sense. Even if you have the basic knowledge about multithreaded computing, or the JVM concurrency model, you will learn a lot about modern, high-level concurrency utilities. Many of the concurrency libraries in this book are only starting to find their way into mainstream programming languages, and some of them are truly cutting-edge technologies.
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: The next lines of code read the link and assign it to the to the BeautifulSoup function.
When we wish to draw your attention to a particular part of a code block, the relevant lines or items are set in bold: 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: 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.
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 for this book from your account at http: If you purchased this book elsewhere, you can visit http: Once the file is downloaded, please make sure that you unzip or extract the folder using the latest version of: The code bundle for the book is also hosted on GitHub at https: We also have other code bundles from our rich catalog of books and videos available at https: Open Preview See a Problem?
Details if other: Thanks for telling us about the problem. Return to Book Page. Key Features Make the most of Scala by understanding its philosophy and harnessing the power of multicores Get acquainted with cutting-edge technologies in the field of concurrency, through practical, real-world applications Get this step-by-step guide packed with pragmatic examples Book Description Scala is a modern, multiparadigm programming language designed to express Key Features Make the most of Scala by understanding its philosophy and harnessing the power of multicores Get acquainted with cutting-edge technologies in the field of concurrency, through practical, real-world applications Get this step-by-step guide packed with pragmatic examples Book Description Scala is a modern, multiparadigm programming language designed to express common programming patterns in a concise, elegant, and type-safe way.
What you will learn Get to grips with the fundamentals of concurrent programming on modern multiprocessor systems Build high-performance concurrent systems from simple, low-level concurrency primitives Express asynchrony in concurrent computations with futures and promises Seamlessly accelerate sequential programs by using data-parallel collections Design safe, scalable, and easy-to-comprehend in-memory transactional data models Transparently create distributed applications that scale across multiple machines Integrate different concurrency frameworks together in large applications Develop and implement scalable and easy-to-understand concurrent applications in Scala 2.
Get A Copy. Kindle Edition , pages. More Details Other Editions 1. Friend Reviews. To see what your friends thought of this book, please sign up. Lists with This Book. This book is not yet featured on Listopia.
Community Reviews. Showing Rating details. Sort order. Good overview of concurrency abstractions in Scala. Goes into enough details to be useful. The last chapter introduces http: Ivano rated it it was amazing Dec 28, Lorgath rated it really liked it Jan 04, Kuba Piszczek rated it it was ok Mar 14, Robert Dawson rated it it was amazing Sep 12, Dmitry rated it really liked it May 03, Vikash Sharma rated it it was amazing Apr 16, Fatih marked it as to-read Feb 25, Anatoly Leonov marked it as to-read Jun 12, Bogdan marked it as to-read Jun 13, Ihor Lozinsky marked it as to-read Oct 03, Iulian Dumitru marked it as to-read Oct 04, Mariusz marked it as to-read Nov 13, Helio Costa marked it as to-read Nov 19, Aniket Joshi marked it as to-read Nov 26, Victor Tsvetkov marked it as to-read Dec 07, Sergiy marked it as to-read Jan 11, Vladislav Gangan marked it as to-read Feb 07, Oleg Zinovev marked it as to-read Mar 18, Andrey marked it as to-read Sep 30,