Scala Programming Projects
Build real world projects using popular Scala frameworks like Play, Akka, and Spark
Mikal Valot
Nicolas Jorand
BIRMINGHAM - MUMBAI
Scala Programming Projects
Copyright 2018 Packt Publishing
All rights reserved. No part of this book may be reproduced, stored in a retrieval system, or transmitted in any form or by any means, without the prior written permission of the publisher, except in the case of brief quotations embedded in critical articles or reviews.
Every effort has been made in the preparation of this book to ensure the accuracy of the information presented. However, the information contained in this book is sold without warranty, either express or implied. Neither the author(s), nor Packt Publishing or its dealers and distributors, will be held liable for any damages caused or alleged to have been caused directly or indirectly by this book.
Packt Publishing has endeavored to provide trademark information about all of the companies and products mentioned in this book by the appropriate use of capitals. However, Packt Publishing cannot guarantee the accuracy of this information.
Commissioning Editor: Aaron Lazar
Acquisition Editor: Alok Dhuri
Content Development Editor: Zeeyan Pinheiro
Technical Editor: Gaurav Gala
Copy Editor: Safis Editing
Project Coordinator: Vaidehi Sawant
Proofreader: Safis Editing
Indexer: Tejal Daruwale Soni
Graphics: Alishon Mendonsa
Production Coordinator: Nilesh Mohite
First published: September 2018
Production reference: 1280918
Published by Packt Publishing Ltd.
Livery Place
35 Livery Street
Birmingham
B3 2PB, UK.
ISBN 978-1-78839-764-3
www.packtpub.com
mapt.io
Mapt is an online digital library that gives you full access to over 5,000 books and videos, as well as industry leading tools to help you plan your personal development and advance your career. For more information, please visit our website.
Why subscribe?
Spend less time learning and more time coding with practical eBooks and videos from over 4,000 industry professionals
Improve your learning with Skill Plans built especially for you
Get a free eBook or video every month
Mapt is fully searchable
Copy and paste, print, and bookmark content
Packt.com
Did you know that Packt offers eBook versions of every book published, with PDF and ePub files available? You can upgrade to the eBook version at www.packt.com and as a print book customer, you are entitled to a discount on the eBook copy. Get in touch with us at customercare@packtpub.com for more details.
At www.packt.com , you can also read a collection of free technical articles, sign up for a range of free newsletters, and receive exclusive discounts and offers on Packt books and eBooks.
Contributors
About the authors
Mikal Valot is Principal Software Engineer at IHS Markit in London, UK. He is the lead developer of a strategic market risk solution for banking regulation.
He has over 15 years of experience in the financial industry of the UK, Switzerland, and France. He has a Diplme d'Ingnieur in Computing (equivalent to an M.Sc.) from Telecom Nancy, France.
After years of working with Java, he started developing professionally with Scala in 2010, and never looked back. He was a speaker at Scala Exchange 2015.
When he is not coding in Scala, Mikal likes to dabble with Haskell, the Robotic Operating System, and deep learning.
He strongly believes that functional programming with strong typing skills is the best way to write safe and scalable programs.
I dedicate this book to my parents Yvette & Francis, who helped me pursue the education that made all of this possible.
I express my gratitude to my wife, Anne, my children, Charline & Lucile, for their continued support, and to Nicolas, for the great contribution and fun, he brought to this project.
I thank all the people who helped write this book:
Christopher Chane-Yook, Qiong Lee, Gaurav Gala, Titos Matsakos, Zeeyan Pinheiro, Jean Zottner
Nicolas Jorand is a senior developer. He worked for the finance industry for about 15 years before switching to the energy industry. He is a freelancer enjoying a partial time at Romande Energy, a Swiss utility company providing exclusively green electricity. Nicolas is a full-stack developer, playing with microcontrollers, developing standard web user and 3D interfaces on Unity, developing software to animate a humanoid robot (Nao) and finally, working with Scala on integration and backend software. All these projects are done with the same leitmotif; "In the dev process, get the issues as early as possible."
I would like to thank my wife, Luisa, and my children Natsumi and Yuuta for the unconditional support, Jacques Couvreur, Franois Leytens, Gaurav Gala and Zeeyan Pinheiro who helped in writing this book, last but not least, Mikal for his kindness and the motivation he brought in this adventure.
About the reviewer
Vlad Patryshev is currently working as a Lead Data Engineer at Salesforce; he is also a professor of Logic at Santa Clara University.
He is an organizer of two meetups, Bay Area Categories and Types, and Scala Bay, the latter dedicated to Scala language.
Vlad's education is in math, but he spent most of his life working in software. 7 years at Borland, 3.5 years at Google.
I'd also like to thank the author for the opportunity to read and review this wonderful book, which, I hope, will serve the wide range of beginning and mid-level Scala developers around the world to get fast into our beautiful world of Scala.
Packt is searching for authors like you
If you're interested in becoming an author for Packt, please visit authors.packtpub.com and apply today. We have worked with thousands of developers and tech professionals, just like you, to help them share their insight with the global tech community. You can make a general application, apply for a specific hot topic that we are recruiting an author for, or submit your own idea.
Preface
Scala is a type-safe JVM language that incorporates object-oriented programming (OOP) and functional programming (FP) aspects. This book gets you started with the essentials of software development by guiding you through the different aspects of Scala programming, helping you bridge the gap between learning and implementing. You will learn about the unique features of Scala through diverse applications and encounter simple yet powerful approaches for software development. You will see how to use the basic tools, set up the environment, and write Scala programs.
Scala Programming Projects will help you build a number of applications, beginning with a simple project, such as a financial independence calculator, and advancing to other projects, such as a shopping application or a Bitcoin transaction analyzer. You will be able to use various Scala features, such as its OOP and FP capabilities, and learn ways to write concise, reactive, and concurrent applications in a type-safe manner. You will also learn how to use top-notch libraries, such as Akka and Play, and integrate Scala applications with Kafka, Spark, and Zeppelin; plus, you'll explore deploying applications on cloud platforms.
Next page