Scala for Java Developers

Retired

This book is no longer available for sale.

Scala for Java Developers

A Practical Primer

About the Book

Scala is a concise, statically typed scripting language that runs on the Java Virtual Machine. It is both a functional programming language and object-oriented language but its emphasis on functional programming sets it apart from Java.

Learn Scala: A Practical Primer for Java Developers is for Java developers looking to transition to programming Scala. The book will help you translate the Java you already know into Scala and kick-start your productivity.

What's Inside

  • Tour Scala and learn the basic syntax, constructs and how to use the REPL
  • Translate Java syntax that you already know into Scala
  • Learn what Scala offers over and above Java, functional programming concepts and idioms
  • Tips and advice useful when transitioning existing Java projects to Scala

Paperback now available on Amazon.

About the Author

Toby Weston
Toby Weston

Toby is an independent consultant based in London. He specialises in agile enablement, training and modern software development.

http://baddotrobot.com

Table of Contents

  •  
    • Prologue
    • Preface
  • I. Scala Tour
    • The Scala Language
      • As a Functional Programming Language
      • The Past
      • The Future
    • Installing Scala
      • The Scala Interpreter
      • Scala Scripts
      • scalac
    • Some Basic Syntax
      • Defining Values and Variables
      • Defining Functions
      • Operator Overloading and Infix Notation
      • Collections
      • Tuples
      • Java Interoperability
      • Primitive Types
    • Scala’s Class Hierarchy
      • AnyVal
      • Unit
      • AnyRef
      • Bottom Types
    • ScalaDoc
    • Language Features
      • Working with Source Code
      • Working with Methods
      • Functional Programming
    • Summary
  • II. Key Syntactical Differences
    • Classes and Fields
      • Creating Classes
      • Derived Setters and Getters
      • Redefining Setters and Getters
      • Summary
    • Classes and Objects
      • Classes Without Constructor Arguments
      • Additional Constructors
      • Singleton Objects
      • Companion Objects
    • Classes and Functions
      • Anonymous Functions
      • Anonymous Classes
      • First-class Functions
      • Function Types
      • Functions vs. Methods
      • Lambdas vs. Closures
    • Inheritance
      • Subtype Inheritance
      • Anonymous Classes
      • Interfaces / Traits
      • Abstract Classes
      • Polymorphism
      • Deciding Between the Options
    • Control Structures
      • Conditionals
      • Looping Structures: do, while and for
      • Breaking Control Flow (break and continue)
      • Exceptions
    • Generics
      • Parametric Polymorphism
      • Bounded Classes
      • Variance
  • III. Beyond Java to Scala
    • Faking Function Calls
      • The apply Method
      • The update Method
      • Summary
    • Faking Language Constructs
      • Curly Braces (and Function Literals)
      • Currying
      • Summary
    • Pattern Matching
      • Switching
      • Patterns
      • Literal Matches
      • Constructor Matches
      • Type Query
      • Deconstruction Matches and unapply
      • Guard Conditions
    • Map and FlatMap
      • Mapping Functions
      • FlatMap
      • Not Just for Collections
    • Monads
      • Basic Definition
      • Option
      • More Formal Definition
      • Summary
    • For Comprehensions
      • Where We Left Off
      • Using Null Checks
      • Using flatMap with Option
      • How For Comprehensions Work
      • Finally, Using a For Comprehension for Shipping Labels
      • Summary
  • IV. Adopting Scala in Java Teams
    • Adopting Scala
      • Avoid Not Enough
      • Don’t Do Too Much
      • Purely Functional FTW?
    • What to Expect
      • The Learning Curve
      • The Learning Continuum
    • Tips
      • Be Clear
      • Get Guidance
      • Have a Plan
    • Convert Your Codebase
    • Manage Your Codebase
      • Conventions
      • What to Avoid
      • Other Challenges
  • Appendices
    • Code Listings
      • Inheritance
      • Generics
      • Pattern Matching
      • Map
    • Syntax Cheat Sheet
    • Index
  • Notes

The Leanpub 60 Day 100% Happiness Guarantee

Within 60 days of purchase you can get a 100% refund on any Leanpub purchase, in two clicks.

Now, this is technically risky for us, since you'll have the book or course files either way. But we're so confident in our products and services, and in our authors and readers, that we're happy to offer a full money back guarantee for everything we sell.

You can only find out how good something is by trying it, and because of our 100% money back guarantee there's literally no risk to do so!

So, there's no reason not to click the Add to Cart button, is there?

See full terms...

Earn $8 on a $10 Purchase, and $16 on a $20 Purchase

We pay 80% royalties on purchases of $7.99 or more, and 80% royalties minus a 50 cent flat fee on purchases between $0.99 and $7.98. You earn $8 on a $10 sale, and $16 on a $20 sale. So, if we sell 5000 non-refunded copies of your book for $20, you'll earn $80,000.

(Yes, some authors have already earned much more than that on Leanpub.)

In fact, authors have earnedover $13 millionwriting, publishing and selling on Leanpub.

Learn more about writing on Leanpub

Free Updates. DRM Free.

If you buy a Leanpub book, you get free updates for as long as the author updates the book! Many authors use Leanpub to publish their books in-progress, while they are writing them. All readers get free updates, regardless of when they bought the book or how much they paid (including free).

Most Leanpub books are available in PDF (for computers) and EPUB (for phones, tablets and Kindle). The formats that a book includes are shown at the top right corner of this page.

Finally, Leanpub books don't have any DRM copy-protection nonsense, so you can easily read them on any supported device.

Learn more about Leanpub's ebook formats and where to read them

Write and Publish on Leanpub

You can use Leanpub to easily write, publish and sell in-progress and completed ebooks and online courses!

Leanpub is a powerful platform for serious authors, combining a simple, elegant writing and publishing workflow with a store focused on selling in-progress ebooks.

Leanpub is a magical typewriter for authors: just write in plain text, and to publish your ebook, just click a button. (Or, if you are producing your ebook your own way, you can even upload your own PDF and/or EPUB files and then publish with one click!) It really is that easy.

Learn more about writing on Leanpub