Scala for Java Developers


Scala for Java Developers
eBook: $26.99
Formats: PDF, PacktLib, ePub and Mobi formats
$22.95
save 15%!
Print + free eBook + free PacktLib access to the book: $71.98    Print cover: $44.99
$67.94
save 6%!
Free Shipping!
UK, US, Europe and selected countries in Asia.
Also available on:
Overview
Table of Contents
Author
Reviews
Support
Sample Chapters
  • Learn the syntax interactively to smoothly transition to Scala by reusing your Java code
  • Leverage the full power of modern web programming by building scalable and reactive applications
  • Easy to follow instructions and real world examples to help you integrate java code and tackle big data challenges

Book Details

Language : English
Paperback : 282 pages [ 235mm x 191mm ]
Release Date : April 2014
ISBN : 1783283637
ISBN 13 : 9781783283637
Author(s) : Thomas Alexandre
Topics and Technologies : All Books, Application Development, Open Source


Table of Contents

Preface
Chapter 1: Programming Interactively within Your Project
Chapter 2: Code Integration
Chapter 3: Understanding the Scala Ecosystem
Chapter 4: Testing Tools
Chapter 5: Getting Started with the Play Framework
Chapter 6: Database Access and the Future of ORM
Chapter 7: Working with Integration and Web Services
Chapter 8: Essential Properties of Modern Applications – Asynchrony and Concurrency
Chapter 9: Building Reactive Web Applications
Chapter 10: Scala Goodies
Index
  • Chapter 1: Programming Interactively within Your Project
    • Advantages of using Scala for Java projects
      • More concise and expressive
      • Increased productivity
      • Natural evolution from Java
      • Better fit for asynchronous and concurrent code
    • Learning Scala through the REPL
      • Declaring val/var variables
      • Defining classes
      • Explaining case classes
    • Operations on collections
      • Transforming collections containing primitive types
      • Collections of more complex objects
        • Filter and partition
        • Dealing with tuples
        • Introducing Map
        • Introducing the Option construct
        • A glimpse at pattern matching
        • The map method
        • Looking at String Interpolation
        • The groupBy method
        • The foldLeft method
    • Summary
  • Chapter 2: Code Integration
    • Creating a REST API from an existing database
      • The sample database
      • Setting up a Maven project
      • Creating JPA entities and REST web service
      • Running and testing the project
    • Adding a test in Scala
    • Setting up Scala within a Java Maven project
    • Scala and Java collaboration
      • Converting between collection types
      • JavaBean-style properties
      • Scala and Java object orientation
      • Scala traits as enhanced Java interfaces
      • Declaring objects
      • Introducing companion objects
      • Handling exceptions
    • Differences in style between Java and Scala code
      • Adjusting the code layout
      • Naming conventions
    • Summary
  • Chapter 3: Understanding the Scala Ecosystem
    • Inheriting Java Integrated Development Environments (IDEs)
    • Building with Simple Build Tool (SBT)
      • Getting started with SBT
        • Creating a sample project
        • Importing the project in Eclipse, IntelliJ IDEA, and NetBeans
        • Creating a web application that runs on a servlet container
      • Using sbt-assembly to build a single .jar archive
      • Formatting code with Scalariform
    • Experimenting with Scala Worksheets
    • Working with HTTP
      • Scala's for comprehension
    • Taking advantage of Typesafe Activator
      • Creating an application based on activator templates
    • The REPL as a scripting engine
    • Summary
  • Chapter 4: Testing Tools
    • Writing tests with ScalaTest
      • BDD-style testing
      • Functional testing
      • Mocking with ScalaMock
    • Testing with ScalaCheck
    • Summary
  • Chapter 5: Getting Started with the Play Framework
    • Getting started with the classic Play distribution
    • Getting started with the Typesafe Activator
    • Architecture of a Play application
      • Visualizing the framework stack
      • Exploring the request-response lifecycle
      • Handling a request in the controller
      • Rendering the view
    • Playing with authentication
    • Practical tips when using Play
      • Debugging with Play
      • Dealing with version control
    • Summary
  • Chapter 6: Database Access and the Future of ORM
    • Integrating an existing ORM – Hibernate and JPA
      • Making JPA available in Scala
    • Dealing with persistence in the Play Framework
      • A simple example using Anorm
    • Replacing ORM
    • Learning about Slick
    • Scaffolding a Play application
      • Importing test data
      • Visualizing the database in the H2-browser
      • Exploring the code behind the app generation
      • Limitations of the playcrud utility
    • Summary
  • Chapter 7: Working with Integration and Web Services
    • Binding XML data in Scala
      • Running scalaxb from a SOAP web service
    • Working with XML and JSON
      • Manipulating XML
      • Manipulating JSON
      • Using Play JSON
    • Handling Play requests with XML and JSON
      • Mocking Play responses with JSON
      • Calling web services from Play
    • Summary
  • Chapter 9: Building Reactive Web Applications
    • Describing reactive applications
    • Handling streams reactively
      • Understanding Iteratees in Play
      • Adapting Enumerator with Enumeratee
    • Experimenting with WebSockets and Iteratees in Play
    • Learning from activator templates
      • Reactive stocks
      • Reactive real-time search
      • The Play-Akka-Angular-WebSocket template
    • Playing with the Actor Room
    • Summary
  • Chapter 10: Scala Goodies
    • Exploring MongoDB
      • Entering Casbah
      • Applying MapReduce transformations
    • Scratching the surface of Big Data
    • Introducing DSLs in Scala
      • Observing Internal DSLs
      • Tackling external DSLs through parser combinators
    • Introducing Scala.js
    • Final tips
      • Copy and paste in the REPL
      • Timing code execution in the REPL
    • Summary

Thomas Alexandre

Thomas Alexandre is a senior consultant at DevCode, specializing in Java and Scala software development. He is passionate about technology, enthusiastic about sharing knowledge, and is always looking for ways to code more effectively through the adoption of new open source software and standards. In addition to 15 years of Java development, he has focused these past few years on emerging languages and web frameworks such as Groovy and Scala. He also has a Ph.D. in Computer Science from the University of Lille, France, and has spent two years as a postdoc with Carnegie Mellon University in the fields of Security and E-commerce.

Thomas is a certified trainer by Typesafe, the creators of Scala.

Code Downloads

Download the code and support files for this book.


Submit Errata

Please let us know if you have found any errors not listed on this list by completing our errata submission form. Our editors will check them and add them to this list. Thank you.


Errata

- 1 submitted: last submission 30 Jul 2014

Errata Category: Code | Page No: 115

Second paragraph under the code:

For instance, accessing the http://localhost:9000/hello URL in the browser matches the following route:

GET / controllers.Application.index

Should be:

For instance, accessing the http://localhost:9000/hello URL in the browser matches the following route:

GET / hello controllers.Application.sayHello 

Sample chapters

You can view our sample chapters and prefaces of this title on PacktLib or download sample chapters in PDF format.

Frequently bought together

Scala for Java Developers +    Haskell Data Analysis Cookbook =
50% Off
the second eBook
Price for both: $41.55

Buy both these recommended eBooks together and get 50% off the cheapest eBook.

What you will learn from this book

  • Apply and control the Scala Ecosystem
  • Migrate Java code to Scala
  • Discover Play Framework web development
  • Test data using Scala's testing frameworks
  • Manipulate XML and JSON in Scala
  • Learn the Scala syntax interactively
  • Integrate Java projects in Scala
  • Build reactive web apps using the Typesafe stack
  • Use new systems including the Akka framework, the Play web framework, and the emerging Slick framework
  • Tackle big data challenges

In Detail

Scala for Java Developers is a step-by-step guide full of easy-to-follow code taken from real-world examples explaining the migration and integration of Scala in a Java project.

With this book, you will first get comfortable with the Scala syntax and its Java-like ecosystem, and then dive into new ways of building reactive web apps using the Typesafe stack including the actor-based Akka framework, the Play web framework, and the emerging Slick framework for persistence. The book will then teach you how to review useful tools for unit, integration, and functional testing; demonstrate how integrating with external systems applies to the Scala world and what its benefits are.

From learning the Scala syntax interactively to writing modern, scalable, reactive applications, this book will help you to take your skills to the next level by solving complex problems in a concise and maintainable way.

Approach

This step-by-step guide is full of easy-to-follow code taken from real-world examples explaining the migration and integration of Scala in a Java project.

Who this book is for

If you are a Java developer or a Java architect working with Java EE-based solutions and want to start using Scala in your daily programming, then this book is ideal for you. This book will get you up and running quickly by adopting a pragmatic approach with real-world code samples. No prior knowledge of Scala is required.

Code Download and Errata
Packt Anytime, Anywhere
Register Books
Print Upgrades
eBook Downloads
Video Support
Contact Us
Awards Voting Nominations Previous Winners
Judges Open Source CMS Hall Of Fame CMS Most Promising Open Source Project Open Source E-Commerce Applications Open Source JavaScript Library Open Source Graphics Software
Resources
Open Source CMS Hall Of Fame CMS Most Promising Open Source Project Open Source E-Commerce Applications Open Source JavaScript Library Open Source Graphics Software